ci: use PyPI Trusted Publishing (OIDC) for releases#4088
Open
madhavcodez wants to merge 1 commit into
Open
Conversation
|
Hi, I’m Jit, a friendly security platform designed to help developers build secure applications from day zero with an MVS (Minimal viable security) mindset. In case there are security findings, they will be communicated to you as a comment inside the PR. Hope you’ll enjoy using Jit. Questions? Comments? Want to learn more? Get in touch with us. |
Replace the long-lived PYPI_API_TOKEN with OpenID Connect trusted publishing. Adds id-token:write to the publish job, runs it in a dedicated pypi environment, drops the static token from CI, and pins the publish action to a commit SHA. Closes redis#4008.
c90f02a to
5e96e0f
Compare
Collaborator
|
Hi @madhavcodez, thank you for your contribution! When we are ready with the additional steps, this PR will be merged. |
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 PyPI publishing from a long-lived
PYPI_API_TOKENsecret to Trusted Publishing (OpenID Connect), as requested in #4008.Trusted Publishing removes the static API token from CI entirely — there is no credential to leak or exfiltrate — and lets PyPI cryptographically verify that a release was built by this repository's workflow. It also unlocks PEP 740 attestations so users can confirm a published artifact matches what GitHub CI produced.
Changes (
.github/workflows/pypi-publish.yaml)permissions: id-token: write(mandatory for OIDC) alongsidecontents: read(still required because the job runsactions/checkout).pypideployment environment (recommended by the PyPA docs for an extra protection boundary).with: user/passwordblock — with OIDC the action authenticates automatically, so no credentials are passed.pypa/gh-action-pypi-publishto a commit SHA (cef2210=v1.14.0).The publish action is SHA-pinned (rather than tag-pinned like the other actions in this repo) specifically because a malicious tag move on the release action is a supply-chain risk — which is the exact threat this issue is about. Happy to align the other actions to SHA pins in a follow-up if you'd prefer consistency, or to revert this one to
@release/v1if you'd rather keep the repo uniform.This PR is the CI half of the migration. Two one-time maintainer steps are needed for it to publish successfully (a release run before these are done will fail at the publish step):
https://pypi.org/manage/project/redis/settings/publishing/, with exactly:redisredisredis-pypypi-publish.yamlpypipypiGitHub Environment (Settings → Environments → New environment →pypi). Optional: add required reviewers for release gating.After the first successful OIDC publish, the old
PYPI_API_TOKENsecret can be deleted from repo secrets and revoked on PyPI.Closes #4008
Note
Medium Risk
Release publishing depends on correct PyPI/GitHub OIDC and environment setup; misconfiguration blocks releases until fixed, but runtime library behavior is unchanged.
Overview
The PyPI publish workflow now uses Trusted Publishing (OIDC) instead of a static
PYPI_API_TOKEN.The
build_and_packagejob getsid-token: writepluscontents: read, runs in apypiGitHub Environment (with PyPI project URL), and the publish step no longer passesuser/password.pypa/gh-action-pypi-publishis pinned to commitcef2210(v1.14.0) instead of@release/v1.Maintainer setup (PyPI trusted publisher +
pypienvironment) is required before releases succeed; the old API token can be removed after the first OIDC publish.Reviewed by Cursor Bugbot for commit 5e96e0f. Bugbot is set up for automated code reviews on this repo. Configure here.