This document describes how to publish new versions of tom-swe to PyPI.
Trusted Publishing is the modern, secure way to publish to PyPI without managing API tokens. It uses OpenID Connect (OIDC) to authenticate GitHub Actions directly with PyPI.
-
Create a PyPI account (if you don't have one):
- Go to https://pypi.org/account/register/
- Verify your email
-
Set up Trusted Publishing:
- Go to https://pypi.org/manage/account/publishing/
- Click "Add a new pending publisher"
- Fill in the form:
- PyPI Project Name:
tom-swe - Owner:
All-Hands-AI - Repository name:
ToM-SWE - Workflow name:
publish-to-pypi.yml - Environment name:
pypi
- PyPI Project Name:
- Click "Add"
-
Configure GitHub Environment (optional but recommended):
- Go to your GitHub repository settings
- Navigate to "Environments"
- Create a new environment named
pypi - Add protection rules (e.g., require reviewers for production releases)
Before publishing to the main PyPI, you can test with TestPyPI:
-
Set up TestPyPI Trusted Publishing:
- Go to https://test.pypi.org/manage/account/publishing/
- Follow the same steps as above, but use environment name
testpypi
-
Manually trigger test publish:
- Go to Actions tab in GitHub
- Select "Publish to PyPI" workflow
- Click "Run workflow"
- Check "Publish to TestPyPI instead of PyPI"
- Click "Run workflow"
-
Test installation:
pip install --index-url https://test.pypi.org/simple/ --extra-index-url https://pypi.org/simple/ tom-swe
Edit pyproject.toml and update the version:
[project]
name = "tom-swe"
version = "1.0.1" # Update thisVersion numbering convention (Semantic Versioning):
MAJOR.MINOR.PATCH(e.g.,1.0.1)- MAJOR: Breaking changes
- MINOR: New features, backwards compatible
- PATCH: Bug fixes, backwards compatible
Document what changed in this release.
git add pyproject.toml
git commit -m "Bump version to 1.0.1"
git push origin maingit tag v1.0.1
git push origin v1.0.1- Go to https://github.com/All-Hands-AI/ToM-SWE/releases/new
- Choose the tag you just created (
v1.0.1) - Set the release title (e.g.,
v1.0.1) - Write release notes describing:
- New features
- Bug fixes
- Breaking changes
- Any migration steps needed
- Click "Publish release"
Once you publish the GitHub release:
- The
publish-to-pypi.ymlworkflow will automatically trigger - It will build the package
- It will publish to PyPI using trusted publishing
- You can monitor progress in the Actions tab
Check that your package is available:
- Visit https://pypi.org/project/tom-swe/
- Install it:
pip install tom-swe
If you get this error when setting up trusted publishing:
- The package might already exist on PyPI
- You may need to claim ownership or contact PyPI support
- For first-time publishing, use the "pending publisher" feature
- Verify the environment name in the workflow matches what you set up on PyPI
- Check that the repository name and owner are correct
- Ensure the workflow file name is exactly
publish-to-pypi.yml
# Test the build locally
python -m pip install build
python -m build
# Check the dist/ directory
ls -la dist/If PyPI rejects because the version already exists:
- You cannot re-upload the same version
- Increment the version number (even for fixes)
- Consider using version suffixes for testing:
1.0.1rc1,1.0.1a1
If you need to publish manually:
# Install build tools
pip install build twine
# Build the package
python -m build
# Upload to PyPI (requires API token)
twine upload dist/*However, always prefer the automated workflow as it's more secure and consistent.
- Never reuse version numbers - Each release must have a unique version
- Follow semantic versioning - Makes it clear what changed
- Tag all releases in git - Makes it easy to track what was released
- Write clear release notes - Helps users understand what changed
- Test with TestPyPI first - Catch issues before production release
If users install directly from GitHub:
pip install git+https://github.com/All-Hands-AI/ToM-SWE.gitThis causes issues with:
- Binary builds (PyInstaller, cx_Freeze)
- Reproducible builds
- Dependency resolution
- Version pinning
Always recommend installing from PyPI instead:
pip install tom-swe