feat(ci): PyPI publish workflow on tag via OIDC Trusted Publisher#21
Merged
Conversation
Fires on tag push matching v* (e.g. v0.5.0rc3, v0.5.0, v0.6.0). Two jobs: build (sdist + wheel + twine check + tag-vs-version sanity check) and publish (downloads the artifact + uploads via pypa/gh-action-pypi-publish using PyPI's OIDC Trusted Publisher). No API token lives in repo secrets — the action exchanges the short-lived GitHub OIDC token for PyPI publish creds, scoped to this exact workflow on this exact repo. Token rotation hygiene becomes automatic. `workflow_dispatch` with a `ref` input is included as a manual re-publish fallback for cases where the tag-push event was missed or the artifact needs to be rebuilt from a known ref. The build job verifies that the tag (refs/tags/vX.Y.Z) matches the built wheel's version metadata before handoff to publish, so a forgotten flow_doctor/__init__.py / pyproject.toml bump fails the release loud at the tag push instead of shipping a stale version. The publish job runs under a `pypi` GitHub environment so an optional manual approval gate can be added later (Settings → Environments → pypi → Required reviewers) without changing the workflow. One-time PyPI-side setup required before this workflow can publish: 1. https://pypi.org/manage/project/flow-doctor/settings/publishing/ 2. Add a new pending publisher: - PyPI Project Name: flow-doctor - Owner: cipher813 - Repository name: flow-doctor - Workflow filename: release.yml - Environment name: pypi Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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.ymlso future PyPI releases happen automatically on tag push instead of needing manualtwine upload.Trigger: push of a tag matching
v*(e.g.v0.5.0rc3,v0.5.0,v0.6.0). Manualworkflow_dispatchwith arefinput is included as a re-publish fallback.Pipeline:
build— checkout → setup Python 3.12 → installbuild+twine→python -m build→twine check→ verify tag version matches built wheel version (catches a forgotten__init__.py/pyproject.tomlbump) → upload artifact.publish— download artifact →pypa/gh-action-pypi-publish@release/v1withid-token: write. OIDC token exchange handles auth; no API token in repo secrets.The publish job runs under a
pypiGitHub environment so a manual approval gate can be added later (Settings → Environments → pypi → Required reviewers) without changing the workflow.One-time PyPI-side setup (required before the workflow can publish)
flow-doctorcipher813flow-doctorrelease.ymlpypiAfter that, the release flow is just:
Test plan
__init__.py; the build job should fail loudly.🤖 Generated with Claude Code