Add a gated release workflow publishing to PyPI via Trusted Publishing - #2
Merged
Conversation
Publishing runs on a published GitHub Release and uses OIDC rather than a PyPI API token, so no long-lived credential exists in this repository to steal. The name 'codesnake' is free on PyPI; the pending publisher still has to be registered there before the first release (see docs/RELEASING.md). The workflow is split so that code and publishing rights never share a job: build has contents:read, no OIDC, and produces the artifacts; publish has id-token:write, never checks out the repository, and only uploads what build handed it. Every action is pinned to a commit SHA, and permissions are deny-by-default at the workflow level. The build job refuses to publish when the release tag and _version.py disagree, so a v1.3.0 tag cannot ship a 1.2.0 artifact. The 'pypi' environment is created and restricted to v* tags. Its required- reviewer rule -- the control that actually makes publishing need a human -- could not be added: environment protection rules need a paid plan on private repositories. docs/RELEASING.md records the one command to run once the repository is public, and is explicit that until then a published Release ships without a second gate. Verified locally before committing: the package builds sdist and wheel, twine check passes both, the wheel contains only the package, and the tag/version guard accepts a matching tag and rejects a mismatched one. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0114gUUe4CxYr8W8oC95ffmD
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.
Publishing runs on a published GitHub Release and uses OIDC rather than a
PyPI API token, so no long-lived credential exists in this repository to
steal. The name 'codesnake' is free on PyPI; the pending publisher still has
to be registered there before the first release (see docs/RELEASING.md).
The workflow is split so that code and publishing rights never share a job:
build has contents:read, no OIDC, and produces the artifacts; publish has
id-token:write, never checks out the repository, and only uploads what build
handed it. Every action is pinned to a commit SHA, and permissions are
deny-by-default at the workflow level.
The build job refuses to publish when the release tag and _version.py
disagree, so a v1.3.0 tag cannot ship a 1.2.0 artifact.
The 'pypi' environment is created and restricted to v* tags. Its required-
reviewer rule -- the control that actually makes publishing need a human --
could not be added: environment protection rules need a paid plan on private
repositories. docs/RELEASING.md records the one command to run once the
repository is public, and is explicit that until then a published Release
ships without a second gate.
Verified locally before committing: the package builds sdist and wheel, twine
check passes both, the wheel contains only the package, and the tag/version
guard accepts a matching tag and rejects a mismatched one.
Co-Authored-By: Claude Opus 5 noreply@anthropic.com
Claude-Session: https://claude.ai/code/session_0114gUUe4CxYr8W8oC95ffmD