Repository navigation
Publish releases from GitHub Actions with PyPI provenance - #1802
Merged
Merged
Conversation
PyPI only accepts PEP 740 attestations on files uploaded by a Trusted Publisher, so a local upload with an API token can't carry provenance. Add a publish.yml workflow that builds the tagged release and uploads it to PyPI or TestPyPI with pypa/gh-action-pypi-publish, which signs and uploads attestations. The build runs in a separate job with read-only permissions, and only the upload job can request an OIDC token. make publish and make publish-test now start that workflow on the tag at HEAD with the GitHub CLI and wait for the run, after checking that the tag on origin matches the local one. uv-publish is no longer used, so drop it from the dev dependency group. Document the release flow and the one-time setup: the Trusted Publishers, the pypi/testpypi environments (tag-only, cmd2-admins approval, no admin bypass), and the ruleset limiting release tags to cmd2-admins.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #1802 +/- ##
=======================================
Coverage 99.75% 99.75%
=======================================
Files 23 23
Lines 6593 6593
=======================================
Hits 6577 6577
Misses 16 16
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
PyPI only accepts PEP 740 attestations (provenance) on files uploaded by a Trusted Publisher running in CI. A local upload with an API token can't carry them, so this moves the upload into GitHub Actions.
.github/workflows/publish.yml, started by hand on a release tag:buildjob checks the tag withscripts/validate_tag.py, runsuv build, and uploadsdist/as an artifact. It has read-only permissions and no uv cache.publishjob downloadsdist/and uploads it withpypa/gh-action-pypi-publish, whichsigns and uploads the attestations by default. It runs in the
pypiortestpypienvironment,and it's the only job that can request an OIDC token.
make publish/make publish-teststill check the tag first. They then confirm the tag onorigin matches the local one, start the workflow with
gh workflow run, and follow it withgh run watch --exit-status. The release checklist doesn't change.uv-publishis removed from thedevdependency group because nothing uses it anymore..github/CONTRIBUTING.mddocuments the new flow and the one-time setup.Already configured outside this PR
publish.ymlwith environmentspypi/testpypipypiandtestpypi:*.*.*cmd2-adminsrequired as reviewers, with administrator bypass turned offcmd2-adminscan create, move, or delete*.*.*tagsTesting
make check,make test, andmake docs-testpasspublish.ymlghto check the normal run, a missing run URL, a failedrun, and a tag that isn't on origin
make publish-teston the next release tag.
Notes
original upload, and uploaded files can't be changed.
mainbefore the next release is tagged, becauseghruns the copyof
publish.ymlinside the tagged commit.