Skip to content

Commit 1a24e45

Browse files
cliffhallclaude
andcommitted
fix: a credentialed reusable-workflow call counts as an artifact downloader; rerun guidance matches artifact retention
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Signed-off-by: cliffhall <cliff@futurescale.com>
1 parent 1b33a84 commit 1a24e45

3 files changed

Lines changed: 29 additions & 3 deletions

File tree

‎RELEASING.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ gh run rerun <run-id> --failed --repo modelcontextprotocol/servers
100100
- A re-run is still a `release.yml` run in the `release` environment, so it satisfies the trusted-publisher binding.
101101
- It re-runs only the failed legs, at the original release tag. It publishes exactly the released code, and the registry-diff guard keeps already-published packages safe. If the failed leg was a build job, re-run it together with its publish job.
102102
- It needs a fresh `release` environment approval, and the run must be complete first (approve or reject any pending deployments).
103-
- GitHub's re-run window is about 30 days from the original run.
103+
- The build jobs' artifacts are kept for **7 days**. Within that time, re-running a failed publish leg alone works, because the artifact it downloads is still there. After that (GitHub allows re-runs for about 30 days), re-run the package's build leg together with its publish leg, or the whole run (`gh run rerun <run-id>`): the build recreates the artifact, and the registry-diff guard skips whatever already published.
104104

105105
**A defect in the released code or in the workflow: fix it and release again.** A release event runs the workflow as it is at the tag, so a re-run repeats the same broken step. Fix it on `v2/main` through an ordinary PR, merge `v2/main` into `main`, and publish a new Release. The guard publishes whatever never reached the registry and skips the rest: no stranded versions, and no version edits to force it.
106106

‎scripts/verify-action-pins.mjs‎

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,13 @@ const stepsUsing = (job, action) =>
133133
const mayUploadArtifact = (job) =>
134134
typeof job.uses === "string" || stepsUsing(job, "actions/upload-artifact@");
135135

136+
/**
137+
* Can this job download an artifact? The same reasoning, the other way round:
138+
* a called workflow's jobs can download anything uploaded earlier in the run.
139+
*/
140+
const mayDownloadArtifact = (job) =>
141+
typeof job.uses === "string" || stepsUsing(job, "actions/download-artifact@");
142+
136143
/**
137144
* @param {string} yaml raw contents of a workflow file
138145
* @param {string} [file] only for the parse-error message
@@ -184,8 +191,7 @@ export function credentialedJobs(yaml, file) {
184191
for (let grew = true; grew; ) {
185192
grew = false;
186193
for (const [name, job] of jobs) {
187-
if (!held.has(name) || !stepsUsing(job, "actions/download-artifact@"))
188-
continue;
194+
if (!held.has(name) || !mayDownloadArtifact(job)) continue;
189195
for (const producer of upstreamOf(name)) {
190196
if (!held.has(producer) && mayUploadArtifact(workflow.jobs[producer])) {
191197
held.add(producer);

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

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -261,6 +261,26 @@ test("an upstream reusable-workflow call counts as an artifact producer", () =>
261261
]);
262262
});
263263

264+
test("a credentialed reusable-workflow call counts as an artifact downloader", () => {
265+
const yaml = wf(
266+
"jobs:",
267+
" package:",
268+
" steps:",
269+
" - uses: actions/upload-artifact@v7",
270+
" publish:",
271+
" needs: package",
272+
" permissions:",
273+
" id-token: write",
274+
` uses: org/repo/.github/workflows/publish.yml@${SHA} # v1.2.3`,
275+
);
276+
// The called workflow can download what `package` uploaded, and is not read
277+
// here, so `package` is held to the pin although `publish` has no steps.
278+
assert.deepEqual([...credentialedJobs(yaml)].sort(), ["package", "publish"]);
279+
assert.deepEqual(unpinnedRefs(yaml), [
280+
{ job: "package", uses: "actions/upload-artifact@v7" },
281+
]);
282+
});
283+
264284
test("an upload is not credentialed when the consumer downloads nothing", () => {
265285
const yaml = wf(
266286
"jobs:",

0 commit comments

Comments
 (0)