Use PyPI Trusted Publishing (OIDC) in publish.yml instead of an API token#31
Merged
Conversation
Replace the API-token-based poetry publish with the official pypa/gh-action-pypi-publish action, which authenticates via OIDC now that GitHub Actions is configured as a Trusted Publisher on PyPI. The job's permissions are now declared explicitly to grant id-token: write, restoring contents/issues/pull-requests access the release steps relied on implicitly.
publish.yml instead of an API token
|
Review the following changes in direct dependencies. Learn more about Socket for GitHub.
|
dbertram
previously approved these changes
Jul 2, 2026
Comment on lines
+19
to
+20
| issues: write # comment on PRs included in the release | ||
| pull-requests: write |
Member
There was a problem hiding this comment.
Suggested change
| issues: write # comment on PRs included in the release | |
| pull-requests: write | |
| issues: write | |
| pull-requests: write # comment on PRs included in the release |
?
Also, just curious, but what is the issues: write needed for?
Member
Author
There was a problem hiding this comment.
Good question - I confirmed and issues: write isn't needed at all. Commenting on a PR via the issues.createComment API keys its permission off the target resource, so pull-requests: write covers it. We never comment on a real issue here, so I dropped issues: write entirely and moved your comment onto pull-requests: write in 9fd31c1. Thanks!
Member
There was a problem hiding this comment.
Follow-up nit: can/should we drop the issues: write permission from that ynab-sdk-ruby GH workflow as well then?
Commenting on PRs via the issues API keys its permission off the target resource, so pull-requests: write covers it. The workflow never comments on a real issue, so issues: write was unnecessary.
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.


I've configured GitHub Actions as a Trusted Publisher for this project on PyPI, so the publish workflow no longer needs a long-lived API token. This swaps the token-based
poetry publishstep for the officialpypa/gh-action-pypi-publishaction, which authenticates via OIDC. Poetry itself doesn't speak OIDC, but it still handles the build; the action just publishes whateverpoetry buildput indist/, which is its default package directory.The job now declares an explicit
permissionsblock to grantid-token: write(required for OIDC). Since declaring permissions drops everything else tonone, the block also restorescontents: write(creating the GitHub Release) andissues/pull-requests: write(the step that comments on PRs included in the release). The commit-and-push step is unaffected because it uses theGH_API_TOKENPAT. The new action is pinned by commit SHA to match the rest of the workflow.The Trusted Publisher on PyPI is configured against this repo and the
publish.ymlfilename, with no environment restriction.A similar change was made for the Ruby SDK here.
Follow-ups after the first successful publish
POETRY_PYPI_TOKEN_PYPIrepo secret