feat: enable Trusted Publishing for PyPI uploads#1593
Open
AliSharjeell wants to merge 1 commit into
Open
Conversation
Replace manual PYPI_TOKEN approach with OIDC-based authentication using pypa/gh-action-pypi-publish. This eliminates the need to manage and rotate API tokens, improving security posture. The workflow now triggers on release publication and uses GitHub's OIDC to authenticate with PyPI directly. Closes anthropics#1568
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
Replace manual
PYPI_TOKENapproach with OIDC-based authentication usingpypa/gh-action-pypi-publish. This eliminates the need to manage and rotate API tokens, improving security posture and reducing supply chain attack risk.Changes
.github/workflows/publish-pypi.yml:workflow_dispatchtoreleasewithtypes: [published]permissions: id-token: writefor OIDC authenticationbash ./bin/publish-pypiwithpypa/gh-action-pypi-publish@release/v1PYPI_TOKENsecret dependencyWhy Trusted Publishing?
From PyPI documentation:
Benefits:
Setup Requirements
For this to work, the repo needs to be registered as a Trusted Publisher on PyPI:
anthropicpackageRelated Issue
Closes #1568 — Use Trusted Publishing to upload to PyPI
Risk
Low. This is additive — the old workflow still works manually for recovery scenarios. After testing, the old token can be deleted.