🚀 Add tag-driven release workflow with PyPI Trusted Publishers#13
Merged
Conversation
- Add .github/workflows/release.yml triggered by v*.*.* tags. - Route tag shape to destination: final tags (v0.1.0) publish to PyPI; prerelease tags (rc/a/b) publish to TestPyPI, enabling dry runs without burning a real version. - Verify tag matches pyproject.toml version before building. - Publish via OIDC (pypa/gh-action-pypi-publish). No stored credentials. Requires PyPI-side Trusted Publisher + GitHub environments (pypi, testpypi) with approval gates. - Create GitHub Release with built artifacts and the matching CHANGELOG section as release notes on final tags only. - Read devol.__version__ dynamically from package metadata so pyproject.toml is the single source of truth. - Document the release flow in CONTRIBUTING.md.
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.
What does this PR do?
Adds a tag-driven release workflow that publishes
devolto PyPI (or TestPyPI for prereleases) via GitHub Actions using Trusted Publishers (OIDC), so no API tokens are stored anywhere. The tag's shape picks the destination, version consistency is enforced againstpyproject.toml, and both destinations are gated by GitHub Environments that require manual approval.Details
.github/workflows/release.ymltriggers on tags matchingv*.*.*(PyPI),v*.*.*rc*,v*.*.*a*,v*.*.*b*(TestPyPI).validatejob classifies the tag and fails fast if the tag version does not matchpyproject.toml.buildjob runsuv buildandtwine check, uploads artifacts for downstream jobs.publish-testpypi/publish-pypijobs publish viapypa/gh-action-pypi-publish@release/v1using OIDC; each is attached to its own GitHub Environment for approval gating.github-releasejob extracts the matchingCHANGELOG.mdsection and publishes a GitHub Release with the sdist + wheel attached (final tags only).devol.__version__now reads fromimportlib.metadata.version("devol")with a dev-checkout fallback, makingpyproject.tomlthe single source of truth.CONTRIBUTING.mddocuments the release flow and the "bump → cut changelog → tag → approve" sequence.Manual setup required before the first release
These steps can only be done through the PyPI and GitHub web UIs — automation cannot create the trust relationship from scratch. Complete them before pushing the first tag:
devolLabStrangeLoopdevolrelease.ymltestpypipypi.testpypiandpypi. For each, enable "Required reviewers" and add yourself.Suggested first release
Dry run against TestPyPI first:
Once the TestPyPI upload looks right, bump to the final tag: