fix: finish releases after npm accepts uploads

- Remove registry propagation polling from release completion.
- Resume accepted uploads from receipts without pre-publication registry requests.
This commit is contained in:
Chris Tate
2026-09-30 17:44:51 -05:00
parent 2cb4c65896
commit 0ffa1dd05c
+7 -47
View File
@@ -37,7 +37,7 @@ jobs:
node-version: "24"
registry-url: "https://registry.npmjs.org"
- name: Check npm version and GitHub release
- name: Check GitHub release completion
id: check
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
@@ -45,8 +45,8 @@ jobs:
LOCAL_VERSION=$(node -p "require('./packages/cli/package.json').version")
echo "Local version: $LOCAL_VERSION"
RELEASE_DRAFT=$(gh release view "v$LOCAL_VERSION" --json isDraft --jq .isDraft 2>/dev/null || echo missing)
if npm view "scriptc@$LOCAL_VERSION" version >/dev/null 2>&1 && [ "$RELEASE_DRAFT" = false ]; then
echo "npm and GitHub release are complete"
if [ "$RELEASE_DRAFT" = false ]; then
echo "Release is complete"
echo "should_release=false" >> "$GITHUB_OUTPUT"
else
echo "Release needs publishing or completion"
@@ -411,13 +411,8 @@ jobs:
dir="$1"
packed="${2:-}"
name=$(node -p "require('./$dir/package.json').name")
if npm view "$name@$VERSION" version >/dev/null 2>&1; then
echo "$name@$VERSION already published, skipping"
echo "$name@$VERSION" >> "$RUNNER_TEMP/npm-accepted.txt"
return 0
fi
if grep -Fxq "$name@$VERSION" "$RUNNER_TEMP/npm-accepted.txt"; then
echo "$name@$VERSION upload already accepted; skipping upload while npm processes it"
echo "$name@$VERSION upload already accepted, skipping"
return 0
fi
if [ -z "$packed" ]; then
@@ -453,43 +448,9 @@ jobs:
return "$publish_status"
}
# Check exact public versions concurrently. A staged upload is never
# sufficient to publish a dependent package or finish the release.
require_public_versions() {
node --input-type=module - "$@" <<'NODE'
import { readFileSync } from 'node:fs';
const version = process.env.VERSION;
let pending = process.argv.slice(2)
.map((dir) => JSON.parse(readFileSync(`${dir}/package.json`, 'utf8')))
.filter((pkg) => pkg.private !== true).map((pkg) => pkg.name);
for (let attempt = 0; attempt < 12; attempt++) {
pending = (await Promise.all(pending.map(async (name) => {
try {
const response = await fetch(`https://registry.npmjs.org/${encodeURIComponent(name)}`, {
headers: { accept: 'application/vnd.npm.install-v1+json' },
signal: AbortSignal.timeout(10000),
});
if (response.ok) {
const metadata = (await response.json()).versions?.[version];
if (metadata?.name === name && metadata.version === version && metadata.dist?.tarball) {
const tarball = await fetch(metadata.dist.tarball, { method: 'HEAD', signal: AbortSignal.timeout(10000) });
if (tarball.ok) return null;
}
}
} catch {}
return name;
}))).filter(Boolean);
if (pending.length === 0) process.exit(0);
console.log(`Awaiting public availability: ${pending.map((name) => `${name}@${version}`).join(', ')}`);
if (attempt < 11) await new Promise((resolve) => setTimeout(resolve, 10000));
}
console.error('::error::npm has not made every accepted upload public. Receipts are saved; rerun failed jobs to resume without re-uploading.');
process.exit(1);
NODE
}
# pnpm pack resolves workspace dependencies; npm handles OIDC.
# Upload all independent platform packages before waiting for npm.
# Publish dependencies first. Registry propagation after an accepted
# upload must not block the remaining packages or the GitHub release.
publish_dir packages/runtime
publish_dir packages/runtime-darwin-arm64
publish_dir packages/llvm-darwin-arm64
@@ -510,10 +471,9 @@ jobs:
publish_dir packages/runtime-win32-x64-msvc
publish_dir packages/llvm-win32-x64-msvc
for pkg in packages/cli-*; do publish_dir "$pkg"; done
require_public_versions packages/runtime packages/runtime-* packages/llvm-* packages/cli-*
publish_dir packages/compiler
publish_dir packages/cli
require_public_versions packages/compiler packages/cli
echo "All package uploads accepted; npm registry propagation may continue after this job." >> "$GITHUB_STEP_SUMMARY"
- name: Save accepted upload receipts
if: always()