CI: switch PyPI publish to Trusted Publishing (OIDC) - #835
Merged
Conversation
The username/password (secrets.PYPI_USERNAME/PYPI_PASSWORD) upload in the v0.3.11 release attempt failed with "403 Forbidden" from PyPI - password-based twine uploads are no longer accepted now that PyPI requires token/OIDC-based auth for uploads. Switch to the official pypa/gh-action-pypi-publish action with OIDC Trusted Publishing, which needs no stored secrets at all: PyPI verifies the workflow's identity directly via GitHub's OIDC token. Requires a one-time, PyPI-side config: add this repo/workflow as a Trusted Publisher on the `textattack` PyPI project (PyPI account -> Manage project -> Publishing -> Add a new publisher), owner "QData", repo "TextAttack", workflow "publish-to-pypi.yml", environment left blank (this workflow doesn't use one). The old PYPI_USERNAME/PYPI_PASSWORD secrets are no longer read by this workflow and can be removed once trusted publishing is confirmed working. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
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
.github/workflows/publish-to-pypi.ymlfrom username/password (twine uploadwithsecrets.PYPI_USERNAME/PYPI_PASSWORD) to PyPI's Trusted Publishing via the officialpypa/gh-action-pypi-publishaction.Why
The
v0.3.11release attempt just failed at the upload step with403 Forbiddenfromhttps://upload.pypi.org/legacy/. The build itself succeeded (textattack-0.3.11-py3-none-any.whlbuilt correctly); PyPI rejected the upload, which is what a stale/deprecated username+password credential looks like — PyPI no longer accepts basic-auth uploads for accounts with 2FA enabled (now effectively mandatory for established projects).Trusted Publishing removes the credential problem entirely: no secrets are stored in the repo at all. GitHub's OIDC token is exchanged directly with PyPI at publish time, scoped to this exact repo + workflow file.
Required one-time setup (PyPI side, not in this repo)
Before this will work, someone with owner/maintainer access to the
textattackPyPI project needs to add a Trusted Publisher:QDataTextAttackpublish-to-pypi.ymlOnce that's configured, the old
PYPI_USERNAME/PYPI_PASSWORDrepo secrets are no longer read by this workflow and can be deleted.Test plan
yaml.safe_load)🤖 Generated with Claude Code