PyPI Trusted Publishing from GitHub Actions¶
This project uses OpenID Connect (OIDC) trusted publishing to release to PyPI without storing PyPI API tokens in GitHub secrets.
What is configured in this repository¶
Workflow file:
.github/workflows/publish-pypi.ymlTrigger: Git tag pushes matching
v*(for examplev0.0.2)Build job: creates
sdist+wheeland runstwine checkPublish job: uses
pypa/gh-action-pypi-publishwithid-token: write
One-time setup in PyPI¶
Create the
umimicproject on PyPI if it does not exist yet.In PyPI project settings, open
Publishing.Add a
Trusted Publisherwith:Owner: your GitHub org/user
Repository:
python-release-readiness(or the final repo name)Workflow:
publish-pypi.ymlEnvironment:
pypi
Save the trusted publisher.
Use exact repository/workflow/environment names to match GitHub Actions claims.
One-time setup in GitHub¶
In GitHub repository settings, create an environment named
pypi.Optionally require manual approvals for the
pypienvironment.Ensure workflow permissions are not restricted from OIDC token issuance.
No PyPI token secrets are required with trusted publishing.
Release process¶
Ensure package version is updated in:
pyproject.tomlumimic/__init__.py
Run release checks locally:
pytest -q
python -m build
python -m twine check dist/*
Commit and push changes.
Create and push a version tag:
git tag v0.0.2
git push origin v0.0.2
Watch
Publish to PyPIworkflow in GitHub Actions.Verify the new release appears on PyPI.
Troubleshooting¶
Workflow builds artifacts but publish is skipped/blocked¶
Check pypi environment protection rules in GitHub and approve if required.
PyPI rejects upload due to existing version¶
PyPI versions are immutable. Increment version and push a new tag.