From 4c18dee9b77de80907112e1bed35d3b88ff7b2ee Mon Sep 17 00:00:00 2001 From: Victor Simonetti Date: Thu, 13 Aug 2026 20:48:27 +0000 Subject: [PATCH] release: let npm authenticate itself instead of a placeholder token MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit setup-node's registry-url writes an .npmrc with _authToken pointing at NODE_AUTH_TOKEN, and sets that variable to a placeholder when no token is given. npm then authenticates with the literal placeholder and the registry answers 404 on the upload — after the provenance statement has already been signed and logged. A token in that file also beats the OIDC exchange trusted publishing exists to perform, so the fix is to write no file at all. npm whoami now proves the credential before anything is uploaded. --- .github/workflows/release.yml | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index aa7da1d..bdb1bd2 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -281,13 +281,28 @@ jobs: steps: - uses: actions/checkout@v4 + # Deliberately no `registry-url`. It writes an .npmrc holding + # `_authToken=${NODE_AUTH_TOKEN}` and sets that variable to a placeholder + # when no token is supplied, so npm authenticates with the literal string + # `XXXXX-XXXXX-XXXXX-XXXXX` and the registry answers 404 on the upload — + # its way of saying "not authorized" without admitting the package exists. + # A token in the file also wins over the OIDC exchange, which is the whole + # point of trusted publishing. Without it, npm asks for its own credential + # and there is nothing to conflict with. registry.npmjs.org is the default + # registry, so nothing needs to name it. - uses: actions/setup-node@v4 with: node-version: 22 - registry-url: https://registry.npmjs.org - # Trusted publishing needs a newer npm than the runner image ships. - - run: npm install -g npm@latest && npm --version + # Trusted publishing needs a newer npm than the runner image ships, and + # `npm whoami` proves the credential exists before anything is uploaded: + # the failure mode this replaces was a publish that signed its provenance, + # pushed it to the transparency log, and only then discovered it could not + # authenticate. + - run: | + npm install -g npm@latest + npm --version + npm whoami # The published version is the tag, always. package.json carries 0.0.0 in # the repository so there is no second place to forget to bump.