IT-6150: switch PyPI publishing to trusted publishing (OIDC) - #375
Conversation
Replace token-based twine upload with pypa/gh-action-pypi-publish using GitHub Actions OIDC. Adds id-token: write permission and the pypi environment; removes the PYPI_USERNAME/PYPI_PASSWORD secrets usage. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
Workflow change looks fine to me. Has the trusted publishing already been set up on the PyPI side? |
|
I've set up trusted publishing on the PyPI side, and added the appropriate environment here. Test run: https://github.com/enthought/apptools/actions/runs/30286226427 That test run should fail as a result of the release already existing, but every step up to that should pass. |
Verified: the test run failed with: And it's clear from the log that pypa/gh-action-pypi-publish is being used, so I definitely tested with the version of the workflow from this branch, not from main. |
There was a problem hiding this comment.
Pull request overview
Updates the PyPI publishing workflow to use GitHub Actions OIDC “trusted publishing” instead of long-lived PyPI credentials, aligning releases with modern tokenless authentication.
Changes:
- Add job
environment: pypiand requestid-token: writefor OIDC. - Replace
twine upload(username/password secrets) withpypa/gh-action-pypi-publishpinned to a commit. - Keep
twine check --strictas a separate validation step.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
We need "contents: read" for the checkout action to succeed. It works implicitly at the moment because the repo is public, but both Claude and Copilot recommended making it explicit. Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
|
Merging. Thanks, @jychuah! |
Part of IT-6150 — move PyPI release uploads to GitHub Actions OIDC trusted publishing, removing the long-lived
PYPI_USERNAME/PYPI_PASSWORDtoken from repo secrets.What changed (
.github/workflows/publish-on-pypi.yml)permissions: id-token: write(required for OIDC).environment: pypi(must match the Environment field in the PyPI trusted-publisher config).twine uploadstep — which usedsecrets.PYPI_USERNAME/secrets.PYPI_PASSWORD— withpypa/gh-action-pypi-publish(pinned tov1.14.1).twine check --strictas its own step.This workflow only authenticates after a trusted publisher is configured on the PyPI project. Because this PR removes the token auth, merging it before PyPI is configured will break the next release.
Required order:
enthought, this repository, workflow filenamepublish-on-pypi.yml, environmentpypi.Kept as a draft until step 1 is done. /cc @mdickinson