This guide explains how to complete the setup for automated daily releases and publishing to TestPyPI.
Both pixie-sdk-py and pixie-examples now use setuptools-scm for automatic version management based on git tags.
How it works:
- Version is automatically generated from git tags and commit history
- Format:
X.Y.Z.devN+gHASH(e.g.,0.1.0.dev5+g1a2b3c4) - When you create a tag like
v0.1.0, the version becomes0.1.0
Two workflows have been created:
- pixie-sdk-py: Daily release at 2:00 AM UTC (
.github/workflows/daily-release.yml) - pixie-examples: Daily release at 3:00 AM UTC (
.github/workflows/daily-release.yml)
Each workflow:
- Runs on a daily schedule (can also be triggered manually)
- Generates a version using setuptools-scm
- Creates and pushes a git tag
- Builds the package
- Publishes to TestPyPI
- Creates a GitHub release
-
Create a TestPyPI account (if you don't have one):
- Go to https://test.pypi.org/account/register/
- Complete the registration process
- Verify your email
-
Create API tokens for each project:
- Go to https://test.pypi.org/manage/account/token/
- Click "Add API token"
- Name:
pixie-sdk-py-github-actions - Scope: "Entire account" (initially, then narrow it down after first upload)
- Click "Add token"
- IMPORTANT: Copy the token immediately (starts with
pypi-) - You'll need to create separate tokens or use the same token for both repos
-
After first successful upload, create project-specific tokens:
- Go back to https://test.pypi.org/manage/account/token/
- Create new tokens with scope limited to specific projects
- Delete the account-wide token for security
For pixie-sdk-py repository:
- Go to https://github.com/yiouli/pixie-sdk-py/settings/secrets/actions
- Click "New repository secret"
- Name:
TEST_PYPI_API_TOKEN - Value: Paste the API token you copied from TestPyPI
- Click "Add secret"
For pixie-examples repository:
- Go to https://github.com/yiouli/pixie-examples/settings/secrets/actions
- Click "New repository secret"
- Name:
TEST_PYPI_API_TOKEN - Value: Paste the API token (can be the same or different)
- Click "Add secret"
For setuptools-scm to work properly, you need at least one git tag in each repository.
For pixie-sdk-py:
cd /home/yiouli/repo/pixie-sdk-py
git add .
git commit -m "Setup setuptools-scm and daily releases"
git tag -a v0.1.0 -m "Initial release with setuptools-scm"
git push origin main
git push origin v0.1.0For pixie-examples:
cd /home/yiouli/repo/pixie-examples
git add .
git commit -m "Setup setuptools-scm and daily releases"
git tag -a v0.1.0 -m "Initial release with setuptools-scm"
git push origin main
git push origin v0.1.0You can manually trigger the workflow to test it before the scheduled run:
-
Go to the Actions tab in each repository:
-
Click on "Daily Release and Publish" workflow
-
Click "Run workflow" button
-
Select the branch (main) and click "Run workflow"
-
Monitor the workflow execution for any errors
After a successful run, verify:
-
New tag created: Check the tags page in each repo
-
Package published: Check TestPyPI
-
GitHub Release created: Check releases page
To test installing your packages from TestPyPI:
# Install pixie-sdk from TestPyPI
pip install -i https://test.pypi.org/simple/ --extra-index-url https://pypi.org/simple/ pixie-sdk
# Install pixie-examples from TestPyPI
pip install -i https://test.pypi.org/simple/ --extra-index-url https://pypi.org/simple/ pixie-examplesNote: The --extra-index-url is needed because dependencies will be pulled from the regular PyPI.
Once you've tested with TestPyPI and are ready to publish to production PyPI:
-
Create PyPI account and tokens:
- Register at https://pypi.org/account/register/
- Create API tokens at https://pypi.org/manage/account/token/
-
Update GitHub secrets:
- Add a new secret named
PYPI_API_TOKEN(keepTEST_PYPI_API_TOKENfor testing)
- Add a new secret named
-
Update the workflows:
- Change
TWINE_PASSWORD: ${{ secrets.TEST_PYPI_API_TOKEN }} - To:
TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }} - Change
twine upload --repository testpypi dist/* --verbose - To:
twine upload dist/* --verbose
- Change
-
Update release notes:
- Change TestPyPI URLs to PyPI URLs
- Remove the
-i https://test.pypi.org/simple/from install commands
TestPyPI (and PyPI) doesn't allow uploading the same version twice. Each release must have a unique version number.
Solution: setuptools-scm automatically generates unique versions based on commits, so this shouldn't happen unless you're re-running the workflow on the same commit without new changes.
Cause: setuptools-scm couldn't determine the version from git history.
Solution:
- Ensure you have at least one git tag
- Ensure
fetch-depth: 0is set in the checkout action (already configured)
Cause: Invalid or missing API token.
Solution:
- Verify the token is correctly copied (no extra spaces)
- Verify the secret name matches exactly:
TEST_PYPI_API_TOKEN - Regenerate the token if necessary
- pixie-sdk-py: Releases daily at 2:00 AM UTC
- pixie-examples: Releases daily at 3:00 AM UTC (1 hour after SDK)
The staggered schedule ensures pixie-sdk is published before pixie-examples (in case of dependencies).
With setuptools-scm, versions follow this pattern:
- Tagged commit:
1.0.0 - After tag:
1.0.1.dev1+g1234567(1 commit after 1.0.0) - Many commits:
1.0.1.dev42+g7654321(42 commits after 1.0.0)
This ensures every build has a unique, meaningful version number.