-
Notifications
You must be signed in to change notification settings - Fork 0
chore: add publishing workflow and pin action SHA #22
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,114 @@ | ||
| name: Release | ||
|
|
||
| # Publishes to PyPI via Trusted Publishing (OIDC) | ||
| # Two paths: | ||
| # | ||
| # * Push a tag `vX.Y.Z` -> validate, build, verify, publish to PyPI. | ||
| # * Run manually (workflow_dispatch) -> validate, build, verify, publish to | ||
| # TestPyPI, for a dry run of the whole pipeline against a throwaway index. | ||
| # | ||
| # A pending publisher must be registered on the target index (PyPI and/or | ||
| # TestPyPI) pointing at this repo + release.yml + the matching environment. | ||
| # That is a one-time web step and cannot be done here. | ||
| # | ||
| # Third-party actions are pinned to full commit SHAs (version in a comment). | ||
| # This job graph carries `id-token: write`, so a moving tag on a compromised | ||
| # action could exfiltrate the OIDC token or tamper with the artifact. | ||
|
|
||
| on: | ||
| push: | ||
| tags: | ||
| - "v*" | ||
| workflow_dispatch: | ||
|
|
||
| permissions: | ||
| contents: read | ||
|
|
||
| jobs: | ||
| # Run the full PR gate -- lint, type-check, the 3-version test matrix, and | ||
| # the packaging check -- before anything is published. Publishing is | ||
| # irreversible per version, and a tag can point at any commit, including one | ||
| # that never went through CI. Reused from ci.yml rather than duplicated, so | ||
| # the release gate cannot drift from the everyday one. | ||
| checks: | ||
| uses: ./.github/workflows/ci.yml | ||
| permissions: | ||
| contents: read | ||
|
|
||
| build: | ||
| name: Build and verify distributions | ||
| needs: checks | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4 | ||
| with: | ||
| persist-credentials: false | ||
|
|
||
| - name: Install uv | ||
| # No build cache: this build becomes an unremovable public artifact, so | ||
| # it is produced from a clean environment rather than a restored cache. | ||
| uses: astral-sh/setup-uv@d4b2f3b6ecc6e67c4457f6d3e41ec42d3d0fcb86 # v5 | ||
|
|
||
| # Guard against the one mistake tags make: a vX.Y.Z tag whose number does | ||
| # not match pyproject. PyPI would publish whatever pyproject says, under a | ||
| # version the tag does not describe -- and it could never be corrected. | ||
| - name: Tag matches package version | ||
| if: startsWith(github.ref, 'refs/tags/v') | ||
| run: | | ||
| tag="${GITHUB_REF_NAME#v}" | ||
| pkg="$(python -c "import tomllib; print(tomllib.load(open('pyproject.toml','rb'))['project']['version'])")" | ||
| echo "tag=$tag pyproject=$pkg" | ||
| if [ "$tag" != "$pkg" ]; then | ||
| echo "::error::tag v$tag does not match pyproject version $pkg" | ||
| exit 1 | ||
| fi | ||
|
|
||
| - name: Build sdist and wheel | ||
| run: uv build | ||
|
|
||
| # Same guard CI runs on every PR: required data ships, no test fixtures | ||
| # or signing material leak. Doubly worth it here -- this build is the one | ||
| # that becomes an unremovable public artifact. | ||
| - name: Verify distribution contents | ||
| run: uv run --no-project python scripts/check_dist.py | ||
|
|
||
| - uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4 | ||
| with: | ||
| name: release-dist | ||
| path: dist/ | ||
|
|
||
| publish-testpypi: | ||
| name: Publish to TestPyPI (dry run) | ||
| if: github.event_name == 'workflow_dispatch' | ||
| needs: build | ||
| runs-on: ubuntu-latest | ||
| environment: testpypi | ||
| permissions: | ||
| id-token: write # OIDC token for Trusted Publishing; no stored secret. | ||
| steps: | ||
| - uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4 | ||
| with: | ||
| name: release-dist | ||
| path: dist/ | ||
|
|
||
| - name: Publish | ||
| uses: pypa/gh-action-pypi-publish@ba38be9e461d3875417946c167d0b5f3d385a247 # release/v1 | ||
| with: | ||
| repository-url: https://test.pypi.org/legacy/ | ||
|
|
||
| publish-pypi: | ||
| name: Publish to PyPI | ||
| if: startsWith(github.ref, 'refs/tags/v') | ||
| needs: build | ||
| runs-on: ubuntu-latest | ||
| environment: pypi | ||
| permissions: | ||
| id-token: write | ||
| steps: | ||
| - uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4 | ||
| with: | ||
| name: release-dist | ||
| path: dist/ | ||
|
|
||
| - name: Publish | ||
| uses: pypa/gh-action-pypi-publish@ba38be9e461d3875417946c167d0b5f3d385a247 # release/v1 | ||
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.