Tag-driven PyPI release workflow (OIDC, no tokens) - #31
Open
joshlin111 wants to merge 1 commit into
Open
Conversation
- .github/workflows/release.yml fires on `v*` tags and runs a 4-job pipeline: offline test gate → build sdist+wheel → publish to PyPI → attach artefacts to a GitHub Release. - PyPI upload uses OIDC trusted publishing (pypa/gh-action-pypi-publish) bound to a `pypi` GitHub Environment — no long-lived token in repo secrets. The Environment can carry Required reviewers, so each release gates on a human approval click before the upload step runs. - Build job rejects any tag whose name doesn't match the version in pyproject.toml, so accidental "tagged v3.4.1 but forgot to bump" is caught before anything ships. - README documents the release flow and the one-time PyPI Trusted Publisher + GitHub Environment setup the workflow expects.
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
Adds
.github/workflows/release.yml— a 4-job pipeline triggered byv*tag pushes:make teston the tagged commit so a stale or off-maintag can't ship a broken release.pyproject.toml'sversion(catches "taggedv3.4.1but forgot to bump").pypa/gh-action-pypi-publishwith OIDC trusted publishing. No long-lived PyPI token in repo secrets. Bound to apypiGitHub Environment so a Required reviewer can gate every release.One-time setup required before the first release tag works
This PR is safe to merge as-is — the workflow does nothing until a
v*tag is pushed. But the first tag will fail unless these are configured:On PyPI
Go to https://pypi.org/manage/project/apexomni/settings/publishing/ → Add a new trusted publisher:
ApeX-Protocolapexpro-openapirelease.ymlpypi(If the PyPI project page isn't accessible because no maintainer here owns it on PyPI, that's a blocker — sort the ownership first.)
On GitHub
Settings → Environments → New environment named exactly
pypi:mainso a tag pushed from a feature branch can't trigger a release.How to cut a release after setup is done
The PyPI URL, the GitHub Release page, and a cached wheel artifact all appear within ~5 minutes.
Test plan
v3.4.0vsversion = \"3.4.0\") and failing (v9.9.9) cases.make testgreen via pre-push hook.