Skip to content

Add a gated release workflow publishing to PyPI via Trusted Publishing - #2

Merged
bitWarrior merged 1 commit into
mainfrom
release/trusted-publishing
Sep 1, 2026
Merged

Add a gated release workflow publishing to PyPI via Trusted Publishing#2
bitWarrior merged 1 commit into
mainfrom
release/trusted-publishing

Conversation

@bitWarrior

Copy link
Copy Markdown
Owner

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

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
@bitWarrior
bitWarrior merged commit b8d7c37 into main Sep 1, 2026
4 checks passed
@bitWarrior
bitWarrior deleted the release/trusted-publishing branch September 1, 2026 19:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant