diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 852cf206..06acde1d 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -121,6 +121,10 @@ jobs: registry-url: https://registry.npmjs.org scope: "@reflag" package-manager-cache: false + - name: Use npm with OIDC dist-tag support + run: | + npm install --global npm@12.2.0 + test "$(npm --version)" = "12.2.0" - run: node --test scripts/v1-release.test.mjs - name: Require the current protected v1 commit shell: bash diff --git a/scripts/v1-release.test.mjs b/scripts/v1-release.test.mjs index fa9d3786..0ec7f8a0 100644 --- a/scripts/v1-release.test.mjs +++ b/scripts/v1-release.test.mjs @@ -196,3 +196,17 @@ test("the maintenance publisher never selects latest", () => { ); assert.match(seedJob, /run: node scripts\/v1-release\.mjs tag-legacy/); }); + +test("legacy tag migration pins an OIDC-capable npm before changing tags", () => { + const workflow = readFileSync( + new URL("../.github/workflows/publish.yml", import.meta.url), + "utf8", + ); + const seedJob = workflow.split(" legacy-tags:\n")[1]; + const install = seedJob.indexOf("npm install --global npm@12.2.0"); + const verify = seedJob.indexOf('test "$(npm --version)" = "12.2.0"'); + const tag = seedJob.indexOf("node scripts/v1-release.mjs tag-legacy"); + assert.ok(install >= 0, "Install npm with OIDC dist-tag support explicitly"); + assert.ok(verify > install, "Verify the installed npm version"); + assert.ok(tag > verify, "Require the pinned npm before changing tags"); +});