diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 459763b..7342c2b 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -18,9 +18,6 @@ jobs: runs-on: ubuntu-24.04 timeout-minutes: 10 steps: - - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 - with: - persist-credentials: false - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 with: fetch-depth: 0 @@ -47,6 +44,9 @@ jobs: contents: read id-token: write steps: + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + with: + persist-credentials: false - uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2 with: name: package diff --git a/scripts/release-files.mjs b/scripts/release-files.mjs index f00f4ef..b64b754 100644 --- a/scripts/release-files.mjs +++ b/scripts/release-files.mjs @@ -32,7 +32,28 @@ async function published() { } if (mode === "select") { - console.log((await published()) ? "present" : "missing"); + if (await published()) { + console.log("present"); + } else { + const response = await fetch(`https://registry.npmjs.org/${encodeURIComponent(name)}/latest`, { + signal: AbortSignal.timeout(30000), + }); + if (response.ok) { + const latest = await response.json(); + if (latest.name !== name || !/^\d+\.\d+\.\d+$/.test(latest.version)) { + throw new Error("Unexpected npm latest release"); + } + const wanted = version.split(".").map(Number); + const current = latest.version.split(".").map(Number); + const index = current.findIndex((value, i) => value !== wanted[i]); + if (index === -1 || current[index] > wanted[index]) { + throw new Error("Refusing to move the npm latest tag back to an older release"); + } + } else if (response.status !== 404) { + throw new Error(`npm latest lookup returned HTTP ${response.status}`); + } + console.log("missing"); + } } else { for (let attempt = 0; !(await published()); attempt++) { if (attempt === 5) throw new Error("Published npm tarball is missing");