Skip to content

Commit a338aec

Browse files
cliffhallclaude
andcommitted
fix: release the verified commit by SHA; queue every release run; count the needs context read whole
- The release skill targets the merge PR's merge commit by SHA for the notes and the Release, so the tag lands on the tree the ledger verified even if main has moved since. - release.yml uses queue: max, so a waiting release run is kept rather than replaced by a later one. - verify:action-pins counts any use of the needs context except a job's result as reading that job's outputs, including toJSON(needs). Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Signed-off-by: cliffhall <cliff@futurescale.com>
1 parent 4db2c4e commit a338aec

5 files changed

Lines changed: 98 additions & 24 deletions

File tree

‎.claude/skills/release/SKILL.md‎

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -386,6 +386,13 @@ REPO=modelcontextprotocol/servers
386386
NOTES=$(mktemp -d)
387387
git fetch origin main --tags
388388

389+
# The commit being released is the merge PR's merge commit, by SHA. `main` is
390+
# a moving name: if anything else landed on it since, "main" would be a tree
391+
# the ledger never saw. Everything below targets the SHA.
392+
MERGE_SHA=$(gh pr view <MERGE_PR> --repo "$REPO" --json mergeCommit --jq .mergeCommit.oid) || MERGE_SHA=
393+
[ -n "$MERGE_SHA" ] || echo "the merge PR has no merge commit: stop" >&2
394+
git rev-parse "$MERGE_SHA^{tree}" # must be the tree hash the ledger recorded
395+
389396
# The previous release is the latest PUBLISHED Release, asked of GitHub rather
390397
# than sorted out of the tag list: this repo's tags mix date stamps
391398
# (2026.8.31), milestone names (vX.Y.Z) and older per-package tags, and no
@@ -422,7 +429,7 @@ echo "$PREV → $MILESTONE" # sanity-check both
422429

423430
# 2. What's Changed, exactly as the UI generates it.
424431
gh api "repos/$REPO/releases/generate-notes" -f tag_name="$MILESTONE" \
425-
-f target_commitish=main -f previous_tag_name="$PREV" --jq .body > "$NOTES/changed.md"
432+
-f target_commitish="$MERGE_SHA" -f previous_tag_name="$PREV" --jq .body > "$NOTES/changed.md"
426433

427434
# 5. Reporter credit: the author of every issue a listed PR closes, minus
428435
# maintainers (admin/maintain/write) and bots.
@@ -447,9 +454,9 @@ cat "$NOTES/packages.md" <(echo) "$NOTES/changed.md" "$NOTES/thanks.md" > "$NOTE
447454
echo "$NOTES/release-notes.md"
448455
```
449456

450-
Run the Packages step from a checkout of `origin/main` (the verification
451-
worktree, once it is moved to the merged `main`, will do), since it reads the
452-
manifests on disk.
457+
Run the Packages step from a checkout of `$MERGE_SHA` (the verification
458+
worktree, moved there with `git switch --detach "$MERGE_SHA"`, will do), since
459+
it reads the manifests on disk.
453460

454461
Then add the ledger line and any known issue, and **read the result before
455462
handing it over**. The rules behind the recipe:
@@ -477,18 +484,20 @@ handing it over**. The rules behind the recipe:
477484

478485
**A maintainer does this**, after the merge PR has merged. Through the GitHub
479486
UI: *Releases → Draft a new release → Choose a tag → type the milestone's name
480-
(`vX.Y.Z`) → Create new tag on publish*, with **Target: `main`**, then paste
481-
the notes from 5a and publish.
487+
(`vX.Y.Z`) → Create new tag on publish*. For **Target**, pick the merge commit
488+
(`$MERGE_SHA` from 5a) under *Recent Commits*, not the branch `main`, then
489+
paste the notes from 5a and publish.
482490

483491
The same thing from the CLI, with the notes file from 5a:
484492

485493
```sh
486494
gh release create "$MILESTONE" --repo modelcontextprotocol/servers \
487-
--target main --title "$MILESTONE" --notes-file "$NOTES/release-notes.md" --latest
495+
--target "$MERGE_SHA" --title "$MILESTONE" --notes-file "$NOTES/release-notes.md" --latest
488496
```
489497

490-
`--target main` gives the right commit by construction: the tag is created on
491-
`main`'s head at that moment, which is the merge commit.
498+
The target is the SHA, so the tag lands on the commit the ledger verified,
499+
whatever has reached `main` since. `release.yml` only checks that the tagged
500+
commit is on `main`; it cannot know which commit was verified.
492501

493502
- **The tag is a label, not a version.** Seven packages publish at seven
494503
versions; none is compared with the tag. Naming it for the milestone is what

‎.github/workflows/release.yml‎

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -57,15 +57,21 @@ on:
5757
release:
5858
types: [published]
5959

60-
# One release at a time, and never cancelled. Each publish leg reads the
60+
# One release at a time, and none dropped. Each publish leg reads the
6161
# registry's `latest`, chooses a dist-tag from it and publishes; two runs doing
6262
# that at once could each see the old `latest` and then publish out of order,
63-
# leaving the lower version tagged `latest`. Queuing the second run behind the
64-
# first makes its read see what the first published. Never cancelled, because
65-
# a run stopped between packages leaves a release half published.
63+
# leaving the lower version tagged `latest`. Queuing a run behind the one in
64+
# progress makes its read see what that one published.
65+
#
66+
# `queue: max` keeps every waiting run (up to 100). The default keeps only
67+
# ONE pending run per group and cancels it when another arrives, which would
68+
# silently drop a release whose packages then never publish at its versions.
69+
# `cancel-in-progress` is left at its default, false: a run stopped between
70+
# packages leaves a release half published, and GitHub rejects `queue: max`
71+
# together with `cancel-in-progress: true`.
6672
concurrency:
6773
group: release
68-
cancel-in-progress: false
74+
queue: max
6975

7076
# Nothing in this workflow needs more than read access by default; the two
7177
# publish jobs add `id-token: write` for themselves.

‎RELEASING.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ A release ships one **milestone**. The step-by-step procedure, with its commands
8383
A milestone that touches both languages and needs an audit fix has all three. They are merged before the next step starts.
8484
3. **The merge PR** takes `v2/main` into `main`. It is a pure merge: its branch is `origin/v2/main` with no commits of its own, and the merged tree equals `origin/v2/main`'s. Its body starts with `Part of #<release issue>`, not `Closes`, because `main` is the default branch and a closing keyword there would close the issue before anything is published. It is merged with a merge commit, never squashed.
8585
4. **The release ledger** is linked from the merge PR. It records, for the merge branch's tree: `npm run local:gate`; `npm run pack:verify` for each package; each server-facing issue in the milestone exercised through a client; and a targeted probe for each issue with no client surface. The maintainers approve the merge on it. A finding is fixed on `v2/main` and merged in again, never committed to the merge branch.
86-
5. **A maintainer publishes a GitHub Release** targeting `main`: Releases → Draft a new release → create a tag named for the milestone (`vX.Y.Z`) → Generate release notes → Publish. The tag is a label, not a version.
86+
5. **A maintainer publishes a GitHub Release** targeting the merge commit on `main` (the commit the ledger verified, chosen by SHA rather than by the branch name, which may have moved): Releases → Draft a new release → create a tag named for the milestone (`vX.Y.Z`) → paste the drafted notes → Publish. The tag is a label, not a version.
8787
6. **The build jobs run, then the maintainer approves the `release` environment deployments.** Each package publishes if its version is not on the registry yet; the rest skip cleanly.
8888
7. **The release issue is closed by hand**, and its card moves to Done.
8989

‎scripts/verify-action-pins.mjs‎

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,9 @@
3737
// as one in the publish job would. (The build was split out of the
3838
// publish job to keep the OIDC token away from dependency installs; this
3939
// keeps a moving tag out of what gets published.); or
40-
// 4. has outputs that a credentialed job reads (`needs.<job>.outputs.…`).
40+
// 4. has outputs that a credentialed job reads: `needs.<job>.outputs.…`, or
41+
// the `needs` context handed over whole (`toJSON(needs)`). Reading only
42+
// a job's `.result` does not count.
4143
// The reader acts on them next to its credential. Here that is
4244
// `release.yml`'s `detect-packages`: the publish jobs take from it the
4345
// name and version an artifact must match before it is published, so a
@@ -204,17 +206,23 @@ export function credentialedJobs(yaml, file) {
204206
}
205207
return seen;
206208
};
207-
// The jobs whose outputs a job reads: every `needs.<job>.outputs` anywhere
208-
// in it. `needs.*.outputs` and a dynamic index name no job, so they count
209-
// every job it needs.
209+
// The jobs whose outputs a job reads. Any use of the `needs` context counts
210+
// except a job's `.result`, which carries nothing the producer chose:
211+
// `needs.<job>.outputs.x`, but also `toJSON(needs.<job>)` and
212+
// `toJSON(needs)`, which hand the outputs over whole for a step to parse. A
213+
// reference that names no job (bare `needs`, `needs.*`, a dynamic index)
214+
// counts every job the reader needs.
215+
const NEEDS_USE =
216+
/\bneeds\b\s*(\.\s*([\w-]+|\*)|\[\s*(?:'([^']*)'|"([^"]*)"|[^\]]*)\s*\])?\s*(?:\.\s*(\w+)|\[\s*['"](\w+)['"]\s*\])?/g;
210217
const outputsReadBy = (job) => {
211218
const read = new Set();
212219
for (const text of stringsIn(job)) {
213-
if (!text.includes(EXPRESSION_OPEN)) continue;
214-
for (const m of text.matchAll(
215-
/\bneeds\s*(?:\.\s*([\w-]+|\*)|\[\s*(?:'([^']*)'|"([^"]*)"|[^\]]*)\s*\])\s*(?:\.\s*outputs\b|\[\s*['"]outputs['"]\s*\])/g,
216-
)) {
217-
const named = m[1] ?? m[2] ?? m[3];
220+
const open = text.indexOf(EXPRESSION_OPEN);
221+
if (open === -1) continue;
222+
for (const m of text.slice(open).matchAll(NEEDS_USE)) {
223+
const named = m[2] ?? m[3] ?? m[4];
224+
const property = m[5] ?? m[6];
225+
if (m[1] !== undefined && property === "result") continue;
218226
if (named === undefined || named === "*")
219227
for (const n of needsOf(job)) read.add(n);
220228
else read.add(named);

‎scripts/verify-action-pins.test.mjs‎

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -350,6 +350,57 @@ test("needs.*.outputs counts every job the reader needs", () => {
350350
assert.deepEqual([...credentialedJobs(yaml)].sort(), ["a", "b", "publish"]);
351351
});
352352

353+
test("the needs context serialized whole counts as reading its outputs", () => {
354+
const all = wf(
355+
"jobs:",
356+
" a:",
357+
" runs-on: x",
358+
" b:",
359+
" runs-on: x",
360+
" publish:",
361+
" needs: [a, b]",
362+
" permissions:",
363+
" id-token: write",
364+
" steps:",
365+
" - env:",
366+
" NEEDS: ${{ toJSON(needs) }}",
367+
" run: publish",
368+
);
369+
assert.deepEqual([...credentialedJobs(all)].sort(), ["a", "b", "publish"]);
370+
const one = wf(
371+
"jobs:",
372+
" a:",
373+
" runs-on: x",
374+
" b:",
375+
" runs-on: x",
376+
" publish:",
377+
" needs: [a, b]",
378+
" permissions:",
379+
" id-token: write",
380+
" steps:",
381+
" - env:",
382+
" A: ${{ toJSON(needs.a) }}",
383+
" run: publish",
384+
);
385+
assert.deepEqual([...credentialedJobs(one)].sort(), ["a", "publish"]);
386+
});
387+
388+
test("reading only a needed job's result does not make it credentialed", () => {
389+
const yaml = wf(
390+
"jobs:",
391+
" detect:",
392+
" runs-on: x",
393+
" build:",
394+
" runs-on: x",
395+
" publish:",
396+
" needs: [detect, build]",
397+
" if: ${{ !cancelled() && needs.detect.result == 'success' && needs['build'].result != 'failure' }}",
398+
" permissions:",
399+
" id-token: write",
400+
);
401+
assert.deepEqual([...credentialedJobs(yaml)], ["publish"]);
402+
});
403+
353404
test("an upload is not credentialed when the consumer downloads nothing", () => {
354405
const yaml = wf(
355406
"jobs:",

0 commit comments

Comments
 (0)