feat(action): support PyPI Trusted Publishing via OIDC#116
Conversation
When publishing a Python package, mint a short-lived PyPI API token by exchanging the GitHub Actions OIDC ID token at PyPI's `_/oidc/mint-token` endpoint, when: - `pypi-token` input is empty - the workflow has `permissions: id-token: write` This lets users publish to PyPI without storing a long-lived static API token, by registering a Trusted Publisher on the PyPI project that matches their workflow. Behavior is fully backwards-compatible: if `pypi-token` is provided, it is used as before; if neither is configured, the publish falls through to its existing 'no token' handling.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 092485cba8
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| if: | | ||
| steps.check.outputs.hasChangelogs == 'false' && | ||
| (inputs.ecosystem == 'python' || inputs.pypi-token != '') |
There was a problem hiding this comment.
Enable OIDC auth when ecosystem is auto-detected
The new Configure PyPI auth guard only runs when inputs.ecosystem == 'python' or inputs.pypi-token is non-empty, so a Python repo that relies on auto-detection (documented default) and uses Trusted Publishing (pypi-token unset, id-token: write) will skip this step entirely. In that common path TWINE_PASSWORD is never set, so publish falls back to the existing “no token” behavior instead of minting a PyPI token, which breaks the new feature unless users explicitly set ecosystem: python.
Useful? React with 👍 / 👎.
The `Configure PyPI auth` and Python setup steps were guarded on `inputs.ecosystem == 'python' || inputs.pypi-token != ''`. A Python repo relying on the documented auto-detection (no explicit `ecosystem`) and using Trusted Publishing (no `pypi-token`, `id-token: write` granted) skipped these steps entirely, so `TWINE_PASSWORD` was never minted and twine was never installed. - Drop the gate on `Configure PyPI auth` entirely. It runs on the publish path; setting `TWINE_PASSWORD` is a no-op for non-Python publishes. - Extend the Python setup/build-tools steps to also run when `env.ACTIONS_ID_TOKEN_REQUEST_TOKEN` is present (OIDC available).
wevm/changelogs now natively supports PyPI Trusted Publishing (OIDC) as of tempoxyz/changelogs#116. When pypi-token is empty and the workflow has id-token: write, it mints a short-lived PyPI API token by exchanging the GitHub OIDC ID token at PyPI's _/oidc/mint-token endpoint, removing the need for a long-lived static API token. Pin to the merge commit (de02501) until a new changelogs release is cut, and grant id-token: write + environment: release to the release job so the OIDC mint flow runs and matches the registered Trusted Publisher (tempoxyz/pympp + publish.yml + release).
wevm/changelogs now natively supports PyPI Trusted Publishing (OIDC) as of tempoxyz/changelogs#116. When pypi-token is empty and the workflow has id-token: write, it mints a short-lived PyPI API token by exchanging the GitHub OIDC ID token at PyPI's _/oidc/mint-token endpoint, removing the need for a long-lived static API token. Pin to the merge commit (de02501) until a new changelogs release is cut, and grant id-token: write + environment: release to the release job so the OIDC mint flow runs and matches the registered Trusted Publisher (tempoxyz/pympp + publish.yml + release).
Releases since v0.5.0 have failed with 403 Forbidden because wevm/changelogs ran twine upload with no token (no pypi-token input was provided), and the separate publish job using pypa/gh-action-pypi-publish never ran since the release job errored first. wevm/changelogs now natively supports PyPI Trusted Publishing (OIDC) as of tempoxyz/changelogs#116. When pypi-token is empty and the workflow has id-token: write, it mints a short-lived PyPI API token by exchanging the GitHub OIDC ID token at PyPI's _/oidc/mint-token endpoint. Collapse the two-job workflow into a single release job that: - pins to the changelogs commit with OIDC support (de02501) - grants id-token: write + environment: pypi so the OIDC mint flow matches the registered Trusted Publisher entry on PyPI.
What
Adds support for PyPI Trusted Publishing (OIDC) to the action's Python publish flow.
When
pypi-tokenis empty and the workflow haspermissions: id-token: write, the action mints a short-lived PyPI API token by exchanging the GitHub OIDC ID token at PyPI's_/oidc/mint-tokenendpoint, and uses it asTWINE_PASSWORDfor the existing publish step.