Skip to content

👷 ci(release): mint app tokens instead of a PAT - #3301

Merged
gaborbernat merged 1 commit into
pypa:mainfrom
gaborbernat:ci/release-app-token
Sep 23, 2026
Merged

gaborbernat merged 1 commit into
pypa:mainfrom
gaborbernat:ci/release-app-token

Conversation

@gaborbernat

@gaborbernat gaborbernat commented Sep 22, 2026 •

Copy link
Copy Markdown
Contributor

pre-release.yaml and release.yaml authenticate with GH_RELEASE_TOKEN, a long-lived personal access token. Pre-release uses it to push the release commit and tag to main through the admin bypass on the rulesets, and to read /user for the git identity. The publish job uses it to push the new zipapp to pypa/get-virtualenv. 🔑 Anyone holding a leaked copy keeps the owner's access until a maintainer revokes it.

Each job mints a GitHub App installation token with actions/create-github-app-token, scoped through owner and repositories to the repository it writes (virtualenv or get-virtualenv) and to permission-contents: write. The steps identify the app through client-id, since create-github-app-token v3.2.0 deprecates app-id, and the action revokes the token when the job ends. Pre-release takes its git identity from the app bot user (<slug>[bot] with <id>+<slug>[bot]@users.noreply.github.com), because an installation token cannot read /user. The app token pushes the release commit and tag, so the pre-release job's GITHUB_TOKEN drops from contents: write to contents: read, which setup-uv uses to download uv.

get-virtualenv protects main with required signatures. GitHub accepts unsigned pushes from the PAT because its owner is an admin and enforce_admins is off. The app has no admin role, and a ruleset there blocks force pushes, so the publish job drops git push. It creates the blob, tree and commit through the Git Data API without custom author or committer fields, and GitHub signs the commit as the app. The job moves main with a PATCH on the ref and force=false, so the update must fast-forward.

⚠️ This stays a draft until the setup exists, since both workflows fail without it. The setup needs a GitHub App with Contents read and write access and no organization permissions, installed on pypa/virtualenv and pypa/get-virtualenv; the RELEASE_APP_CLIENT_ID and RELEASE_APP_PRIVATE_KEY secrets in the release environment; and the app as a bypass actor on the default and protect-release-tags rulesets of pypa/virtualenv. We revoke the GH_RELEASE_TOKEN PAT after the first release that uses the app.

@gaborbernat gaborbernat added the security Fixes a vulnerability or hardens the supply chain, CI or release label Sep 22, 2026
@gaborbernat
gaborbernat force-pushed the ci/release-app-token branch 2 times, most recently from 1382420 to 58af853 Compare September 23, 2026 00:18
@gaborbernat gaborbernat changed the title ci(release): mint app tokens instead of a PAT 👷 ci(release): mint app tokens instead of a PAT Sep 23, 2026
@gaborbernat
gaborbernat force-pushed the ci/release-app-token branch 4 times, most recently from 95cb218 to 0639f75 Compare September 23, 2026 01:20
Pre-release and release authenticate with GH_RELEASE_TOKEN, a long-lived
personal access token that pushes to main through the admin ruleset
bypass and writes to pypa/get-virtualenv. Anyone holding a leaked copy
keeps the owner's access until a maintainer revokes it.

Each job mints a GitHub App installation token scoped to the repository
it writes and to write access on contents, and create-github-app-token
revokes the token when the job ends. The pre-release commit takes its
git identity from the app bot user, because an installation token cannot
read /user. The steps identify the app by its Client ID, since the
action deprecates app-id. The app token pushes the release commit and
tag, so the pre-release job holds read access on contents for
GITHUB_TOKEN, which setup-uv uses to download uv.

The app has no admin role on get-virtualenv. Its main branch requires
signed commits and rejects force pushes, so the release job builds the
commit through the Git Data API, where GitHub signs it as the app, and
moves main with a force=false ref update.
@gaborbernat
gaborbernat marked this pull request as ready for review September 23, 2026 01:43
@gaborbernat
gaborbernat merged commit 4608b9d into pypa:main Sep 23, 2026
65 checks passed
@gaborbernat
gaborbernat deleted the ci/release-app-token branch October 3, 2026 15:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

security Fixes a vulnerability or hardens the supply chain, CI or release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant