Skip to content

ci: scope release credentials to release environments - #336

Merged
thomson-t merged 1 commit into
mainfrom
ci/release-environments
Nov 2, 2026
Merged

thomson-t merged 1 commit into
mainfrom
ci/release-environments

Conversation

@thomson-t

@thomson-t thomson-t commented Nov 2, 2026 •

Copy link
Copy Markdown
Contributor

Why

Release automation should hold its release powers only on the branches we release from. This change ties the credentials that open release pull requests, and the right to publish, to the main branch and to maintenance branches named one by one, instead of to the repository as a whole and to a branch-name pattern.

Programme

Standalone change, no programme.

What changes

  • Release – Draft runs in a new release environment. Its GitHub App credentials come from that environment's secrets, and the environment allows only main and maintenance/5.x. A run from any other branch stops before its first step. The branch check inside the workflow stays as a second line.
  • Maintenance – Trunk Upgrade no longer creates a GitHub App token. That token was already being thrown away: Actions skips a job output that holds a secret, so the shared trunk-upgrade workflow has been running on github.token. Its behaviour is unchanged, and the pull requests it opens still do not start CI on their own, as before.
  • RELEASING.md: cutting a maintenance branch now means adding it by its exact name to the npm-publish and release environments, instead of allowing maintenance/*.

No changelog entry, because nothing in the published package changes. Left alone: the publishing workflow itself, and maintenance/4.x, whose older workflows are a separate decision.

Linked work

Depends on: the repository settings in Rollout, which were applied on 2 November 2026.
Unblocks: #337, the same workflow change on maintenance/5.x.

Rollout

Path: CI only; nothing is published. Where each step stands on 2 November 2026:

  1. Done: the release environment allows only main and maintenance/5.x and holds SDK_RELEASE_GITHUB_CLIENT_ID and SDK_RELEASE_GITHUB_APP_PRIVATE_KEY as its secrets. The npm-publish environment now allows only main and maintenance/5.x, in place of main and maintenance/*.
  2. Done: the repository-level copies of the two secrets have been removed. Until this pull request merges, Release – Draft on main cannot get its credentials and fails at its token step.
  3. Next: merge this pull request, then ci: scope release credentials to release environments (5.x) #337 for maintenance/5.x. Merge this one before 1 December, when the monthly Trunk Upgrade runs, or that run fails at its token step too.

Feature flags: none.
Turning it off: revert this pull request, which takes minutes. Because the repository-level secrets are gone, they must be added again first, or Release – Draft and Trunk Upgrade fail at their token step.
What we watch: the next Release – Draft run on main and on maintenance/5.x opens its release pull request, and the 1 December Trunk Upgrade run succeeds. A failure at the "Generate a token" step means the environment's secrets are wrong or missing.

Risks

  • Release – Draft on main and maintenance/5.x fails until this pull request and ci: scope release credentials to release environments (5.x) #337 merge, because the repository-level secrets are already removed; merging both closes it; we would see Release – Draft fail at its token step.
  • The environment secrets hold a wrong value, so the first real run fails; not testable without opening a real release pull request; we would see the next Release – Draft run fail at its token step.
  • A new maintenance branch is cut without being added to both environments, so drafting and publishing from it fail; RELEASING.md now lists the step; we would see the first run on that branch fail before its first step.
  • Trunk Upgrade behaves differently without the token job; the 1 November run log shows the token output was skipped and the shared workflow ran on github.token; we would see the 1 December run fail.
  • With the repository-level private key removed, maintenance/4.x can no longer draft releases, because its older workflows read that key; not addressed here, as that branch's future is a separate decision; we would see Release – Draft fail on that branch.

Risk class: low.

Who

Written by: an automated coding agent (Claude Code), at an engineer's request.
Code reviewed before opening: an independent review agent reviewed the commit on 2 November 2026 and found no blocking issues; no person has reviewed it yet.
Design reviewed before opening: no one.
Decision this implements: an engineer's request on 2 November 2026 to limit release credentials and publishing to release branches; internal, cannot be linked.
Checked: on 2 November 2026, before opening: the repository's lint checks passed on the changed files and both workflows parse, and the 1 November Trunk Upgrade run log was read. After the settings were applied: both environments' deployment branches and secret names were read through the GitHub API, and a Release – Draft run started from this branch was refused by the release environment before its first step (run 41519367427).
Not checked: a successful Release – Draft run in the new environment, which would open a real release pull request; the next release checks it.

Size

Hand-written: 4 lines added and 20 removed across 3 files.
Generated: none.

Notes for reviewers

From the 1 November scheduled Trunk Upgrade run, in the token job:

##[warning]Skip output 'generated-token' since it may contain secret.

The shared workflow's token input is optional and falls back to github.token, so the removed job had no effect.

🤖 Generated with Claude Code

Release – Draft now runs in the `release` environment. Once the release
GitHub App credentials are stored only as that environment's secrets,
they reach only runs on the branches the environment allows.

Maintenance – Trunk Upgrade no longer mints an app token. Actions drops
a job output that contains a secret, so the token never reached the
reusable workflow, which has been running on github.token. Removing the
job keeps that behaviour: the pull requests it opens still do not start
CI on their own, as before.

RELEASING.md now says to add each maintenance branch to the npm-publish
and release environments by its exact name, not by a pattern.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@thomson-t
thomson-t marked this pull request as ready for review November 2, 2026 20:08
@thomson-t
thomson-t requested a review from a team as a code owner November 2, 2026 20:08
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 2, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-02T20:10:29.212879Z 1281eb5 Draft marked ready
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@claude claude Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I reviewed this PR and found no bugs. It changes how release credentials and publish rights are scoped, every changed file has a CODEOWNER, and it only works once an admin has set up the environments first, so a human look is still worthwhile.

What was reviewed:

  • After this change, only release-draft.yml reads the two App secrets, and that job now runs in the release environment. No other workflow on this branch reads them.
  • Trunk Upgrade now calls the shared workflow with no token input and no needs. The workflow-level permissions are unchanged.
  • The RELEASING.md step now asks for exact-name deployment branches on both npm-publish and release, which matches the environment the publish job already uses.
Extended reasoning...

This change edits two GitHub Actions workflows and RELEASING.md. It moves where the release GitHub App credentials are read from and drops an unused token-minting job. That puts it on a security-sensitive surface: which branches can get release credentials and publish. CODEOWNERS assigns all three changed files to the SDK engineering team. It also relies on repository environment settings and secret moves that an admin makes outside the diff, which this review cannot check.

@jaissica12 jaissica12 left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PR REVIEW: #336 ci: scope release credentials to release environments
Head: 1281eb5
Verdict: Approve
Risk: low. CI and docs only, and nothing published changes. Until this merges, Release – Draft on main fails at its token step, because the repository-level credentials are already removed.
Scope: .github/workflows/release-draft.yml (+1), .github/workflows/maintenance-trunk-upgrade.yml (-18), RELEASING.md.

What it does: Runs Release – Draft in the release environment, so its GitHub App credentials come from that environment and only main and maintenance/5.x can use them. It removes the Trunk Upgrade token job, whose output was already discarded. It updates the maintenance-branch steps to add branches by exact name.

Findings:

None blocking or non-blocking.

Checked:

  • Head 1281eb59: the diff, and the full release-draft.yml. Adding environment: release to publish-draft-release makes secrets.SDK_RELEASE_GITHUB_CLIENT_ID and secrets.SDK_RELEASE_GITHUB_APP_PRIVATE_KEY resolve from the environment. The in-workflow branch check stays as a second line.
  • The release environment's deployment branches are exactly main and maintenance/5.x, and it holds those two secret names. npm-publish also allows exactly main and maintenance/5.x. No repository-level copy of either secret remains.
  • Both main and maintenance/5.x have rules requiring pull requests and status checks and blocking force-pushes, so the branch-scoped environment isn't weakened by direct pushes.
  • The Trunk Upgrade token job:
    • The 1 November scheduled run logged Skip output 'generated-token' since it may contain secret..
    • The shared trunk-upgrade.yml at the pinned commit takes an optional token and uses inputs.token || github.token for checkout and the pull request.
    • So removing the job changes nothing.
  • On main and maintenance/5.x, the only other readers of these secrets were these two workflows. Release – Publish already uses environment: npm-publish.
  • CI on this head passes.

Not verified:

  • A successful Release – Draft run in the new environment (it would open a real release pull request).
  • maintenance/4.x drafting, which the description calls out as no longer working and out of scope.

thomson-t added a commit that referenced this pull request Nov 2, 2026
Backport of #336 to maintenance/5.x.

Release – Draft now runs in the `release` environment. Once the release
GitHub App credentials are stored only as that environment's secrets,
they reach only runs on the branches the environment allows.

Maintenance – Trunk Upgrade no longer mints an app token. Actions drops
a job output that contains a secret, so the token never reached the
reusable workflow, which has been running on github.token. Removing the
job keeps that behaviour: the pull requests it opens still do not start
CI on their own, as before.

RELEASING.md now says to add each maintenance branch to the npm-publish
and release environments by its exact name, not by a pattern.

Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@thomson-t
thomson-t merged commit 4849d17 into main Nov 2, 2026
14 of 15 checks passed
@thomson-t
thomson-t deleted the ci/release-environments branch November 2, 2026 20:43

This branch had an error being deployed

1 failed deployment
release — 1281eb59 Deployed Nov 2, 2026 by thomson-t via publish-draft-release #7
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants