Repository navigation
feat(release): one command to lock a released branch, and prove it locked - #46
Merged
Merged
Conversation
…cked `lock-released-branch.yml` cannot run: it needs a `BRANCH_LOCK_TOKEN` secret, `GITHUB_TOKEN` cannot be granted the `Administration` scope, and only a PAT or fine-grained token can hold it. The secret does not exist, so the workflow has failed on every release and no release branch has ever been locked automatically — v3.8.54 shipped with its branch still writable and was locked by hand afterwards. Creating that token is the repository owner's action, so this is the fallback, and it is a script rather than a line in a runbook for one reason: the failure Hard Rule #18 exists to prevent was a SILENT one. In the v3.8.3 incident six commits landed on an already-shipped version because nobody checked the lock had applied. A raw `gh api` PUT that half-works looks exactly like one that worked. So the script always re-reads the protection from GitHub afterwards and exits non-zero unless `lock_branch` and `enforce_admins` both come back true. A green exit means the branch is genuinely read-only — not that a request was accepted. npm run release:lock -- 3.8.54 # lock and verify npm run release:lock -- 3.8.54 --check # verify only npm run release:lock -- 3.8.54 --unlock # reopen It accepts `3.8.54`, `v3.8.54` or `release/v3.8.54`, refuses anything that is not a version rather than guessing at a branch name, and percent-encodes the slash — an unencoded one makes GitHub read the branch as a nested path. The tests assert the behaviour that matters: that a branch GitHub reports as unlocked is never reported as locked, and that the read-back actually queries the protection endpoint instead of echoing what was sent. Verification (isolated DATA_DIR/HOME/USERPROFILE/APPDATA): tests/unit/release-lock-branch-script.test.ts 7 pass / 0 fail eslint --max-warnings=0 exit 0 prettier clean Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
|
Important
This repository does not receive automatic reviews because it has fewer than 10 stars. ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Advanced Run ID: Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
This was referenced Sep 19, 2026
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.
lock-released-branch.ymlcannot run. It needs aBRANCH_LOCK_TOKENsecret;GITHUB_TOKENcannot be granted theAdministrationscope, and only a PAT or fine-grained token can hold it. The secret does not exist, so the workflow has failed on every release and no release branch has ever been locked automatically — v3.8.54 shipped with its branch still writable and was locked by hand afterwards.Creating that token is the repository owner's action. This is the fallback until it exists.
Why a script and not a line in the runbook
The failure Hard Rule #18 exists to prevent was a silent one. In the v3.8.3 incident six commits landed on an already-shipped version because nobody checked the lock had applied. A raw
gh apiPUT that half-works looks exactly like one that worked.So the script always re-reads the protection from GitHub afterwards and exits non-zero unless
lock_branchandenforce_adminsboth come back true. A green exit means the branch is genuinely read-only — not that a request was accepted.It accepts
3.8.54,v3.8.54orrelease/v3.8.54, refuses anything that is not a version rather than guessing at a branch name, and percent-encodes the slash — an unencoded one makes GitHub read the branch as a nested path.Tests
They assert the behaviour that matters, not that a PUT was sent:
latest,main,3.8, empty) are refused.tests/unit/release-lock-branch-script.test.tseslint --max-warnings=0Run with isolated
DATA_DIR/HOME/USERPROFILE/APPDATA.🤖 Generated with Claude Code