Skip to content

Commit 0641bde

Browse files
authored
Fix release finalizer receipt lookup
Validated by the exact-head CI suite.
2 parents 854ba16 + 783b480 commit 0641bde

2 files changed

Lines changed: 26 additions & 9 deletions

File tree

.github/workflows/release-finalize.yml

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -91,15 +91,23 @@ jobs:
9191
run: |
9292
set -euo pipefail
9393
version="${TAG#v}"
94-
run="$(gh api "/repos/${GITHUB_REPOSITORY}/actions/workflows/npm-publish.yml/runs?head_sha=${SOURCE_SHA}&status=completed&per_page=30" \
95-
--jq '[.workflow_runs[] | select(.event == "workflow_dispatch")][0] // {}')"
96-
test "$(jq -r '.conclusion // "missing"' <<< "$run")" = success
97-
run_id="$(jq -r '.id // empty' <<< "$run")"
94+
package_receipt="packages-${version}-${SOURCE_SHA}"
95+
crates_receipt="crates-${version}-${SOURCE_SHA}"
96+
run_id=""
97+
while read -r candidate; do
98+
test -n "$candidate" || continue
99+
artifact_names="$(gh api "/repos/${GITHUB_REPOSITORY}/actions/runs/${candidate}/artifacts?per_page=100" --jq '.artifacts[].name')"
100+
if grep -Fqx "$package_receipt" <<< "$artifact_names" && grep -Fqx "$crates_receipt" <<< "$artifact_names"; then
101+
run_id="$candidate"
102+
break
103+
fi
104+
done < <(gh api "/repos/${GITHUB_REPOSITORY}/actions/workflows/npm-publish.yml/runs?status=completed&per_page=100" \
105+
--jq '.workflow_runs[] | select(.event == "workflow_dispatch" and .conclusion == "success") | .id')
98106
test -n "$run_id"
99107
gh run download "$run_id" --repo "$GITHUB_REPOSITORY" \
100-
--name "packages-${version}-${SOURCE_SHA}" --dir "$RUNNER_TEMP/release-unit"
108+
--name "$package_receipt" --dir "$RUNNER_TEMP/release-unit"
101109
gh run download "$run_id" --repo "$GITHUB_REPOSITORY" \
102-
--name "crates-${version}-${SOURCE_SHA}" --dir "$RUNNER_TEMP/crates-receipt"
110+
--name "$crates_receipt" --dir "$RUNNER_TEMP/crates-receipt"
103111
for package in \
104112
@operatorstack/yield \
105113
@operatorstack/create-yield \

scripts/check-release-control.mjs

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -253,8 +253,16 @@ export async function checkReleaseControl(root = resolve(import.meta.dirname, ".
253253
"automatic finalization must ignore canary publisher runs",
254254
)
255255
expect(
256-
raw["release-finalize.yml"].includes('select(.event == "workflow_dispatch")'),
257-
"finalization must select only stable publisher receipts",
256+
raw["release-finalize.yml"].includes(
257+
'select(.event == "workflow_dispatch" and .conclusion == "success")',
258+
),
259+
"finalization must select only successful stable publisher receipts",
260+
)
261+
expect(
262+
raw["release-finalize.yml"].includes("artifacts?per_page=100") &&
263+
raw["release-finalize.yml"].includes('grep -Fqx "$package_receipt"') &&
264+
raw["release-finalize.yml"].includes('grep -Fqx "$crates_receipt"'),
265+
"finalization must select the publisher receipt by its exact source-bound artifact names",
258266
)
259267
expect(
260268
raw["release-finalize.yml"].includes("--draft=false"),
@@ -290,7 +298,8 @@ export async function checkReleaseControl(root = resolve(import.meta.dirname, ".
290298
"Go finalization must bind the module to the release source",
291299
)
292300
expect(
293-
raw["release-finalize.yml"].includes('--name "crates-${version}-${SOURCE_SHA}"'),
301+
raw["release-finalize.yml"].includes('crates_receipt="crates-${version}-${SOURCE_SHA}"') &&
302+
raw["release-finalize.yml"].includes('--name "$crates_receipt"'),
294303
"finalization must consume the publisher-produced crates receipt",
295304
)
296305
expect(

0 commit comments

Comments
 (0)