ci: switch PyPI publish to trusted publishing (OIDC)#59
Merged
Conversation
Stop using a long-lived PyPI API token; instead mint a short-lived OIDC token per release via PyPI's trusted publisher integration. - Remove MATURIN_PYPI_TOKEN env (secret has been deleted) - Add `environment: pypi-release` at release job level so the job runs in a protected GitHub environment, narrowing the OIDC claim and enabling deployment protection rules (manual approval, tag pattern, etc.) - `id-token: write` permission was already present for build provenance attestation; it now also covers PyPI publishing Prerequisites before next release tag is pushed: 1. Configure PyPI trusted publisher for `cedarpy` at https://pypi.org/manage/project/cedarpy/settings/publishing/ with repo `k9securityio/cedar-py`, workflow `CI.yml`, and environment `pypi-release`. 2. Create the `pypi-release` GitHub environment in repo settings and configure deployment protection rules (recommended: restrict to tags matching `v*`, require manual approval). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
93bb390 to
66d7e07
Compare
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
Switches
cedarpy's PyPI publish step from a long-lived API token to PyPI's Trusted Publishing (OIDC). Aligns with our supply-chain hardening work; thePYPI_API_TOKENsecret has already been deleted.Changes in
.github/workflows/CI.ymlenv: MATURIN_PYPI_TOKEN: ${{ secrets.PYPI_API_TOKEN }}from thePublish to PyPIstep —PyO3/maturin-action@v1auto-detects OIDC whenid-token: writeis present and no token env is setenvironment: pypito thereleasejob so it runs in a protected GitHub environment, which:id-token: writewas already present (used for build provenance) and now also covers PyPI publishing.Prerequisites (must be done before the next
v*tag push)These are manual user actions — this PR only stages the workflow side.
1. Configure PyPI trusted publisher
At https://pypi.org/manage/project/cedarpy/settings/publishing/ add a publisher with:
cedarpyk9securityiocedar-pyCI.ymlpypi2. Create the
pypiGitHub environmentIn repo Settings → Environments → New environment:
pypiv*Why this is safer than a PyPI API token
Test plan
🤖 Generated with Claude Code