Skip to content

ci(release): make the npm publish re-runnable - #18

Merged
edspencer merged 2 commits into
mainfrom
release-publish-idempotent
Nov 5, 2026
Merged

edspencer merged 2 commits into
mainfrom
release-publish-idempotent

Conversation

@edspencer

@edspencer edspencer commented Nov 5, 2026 •

Copy link
Copy Markdown
Owner

An npm version can never be published twice, so re-running publish-npm after a later step failed dies with:

npm error You cannot publish over the previously published versions: <version>.

The Verify provenance landed comment worked around that by telling you to "never re-run this job" — which leaves a release that published fine and then tripped over a later step with no recovery path at all.

Paddock hit exactly this on 0.81.0: its provenance poll timed out, the re-run died on the republish, and run 41960228079 is permanently red even though npm has 0.81.0 with SLSA provenance. Fixed there in edspencer/paddock#988; this is the other half of it.

What changes

Publish skips a version that is already on the registry, so "Re-run failed jobs" finishes the release. Localidraw, Hallway, Local Review, cli-contract, BragDoc and now Paddock all do this — Managers was the last one without it.

It asks the registry directly, with caching off, the way Verify provenance landed already does, rather than through npm view:

code="$(curl -sS -o /dev/null -w '%{http_code}' -H 'Cache-Control: no-cache' \
  "https://registry.npmjs.org/@edspencer%2fmanagers/${VERSION}" || true)"
if [ "${code}" = "200" ]; then
  echo "@edspencer/managers@${VERSION} is already on the registry; not publishing it again"
else
  echo "registry answered ${code} for ${VERSION} — publishing"
  npm publish
fi

The five sibling repos use npm view … version, but this repo deliberately avoids it in the verify step because a cached packument can predate the publish — and a false "not on npm" here is the very failure being guarded against, so consistency with the neighbouring step wins over consistency with the other repos. Only a 200 skips: a 404, or a registry having a bad day, publishes — exactly what this step did unconditionally before, so the guard is never more cautious than today's behaviour.

The Verify provenance landed step is unchanged. Its 30-minute poll already covers the registry lag that broke Paddock's two releases (and the ~9-minute metadata delay on 0.2.0 that its own comment records). Only its comment changes: it no longer bans a re-run, and points at the Publish step's log instead.

How I verified it

No UI, so no screenshots. I extracted the run: block straight out of the committed workflow and drove it against the real public registry, with a stub npm on PATH recording whether npm publish was reached. @edspencer/managers has 0.0.1, 0.2.0, 0.3.0, 0.3.1 published.

Case Registry Expected Result
VERSION=0.2.0 — really is published 200 skip ✅ already on the registry; not publishing it again, 0 npm publish calls
VERSION=99.99.99 — is not 404 publish ✅ registry answered 404 … — publishing, 1 npm publish call
registry unreachable 000 publish (fail safe) ✅ PUBLISH

The third case is the one worth having: a network failure must not silently skip a publish that never happened. curl's own error output goes nowhere near the log — -w '%{http_code}' reports the status instead, so a 404 reads as a status line rather than a scary curl: (22) The requested URL returned error: 404.

What CI here does and does not prove

release.yml is not triggered by a pull request, so this PR's CI never executes the changed workflow. Green here means nothing else broke; the changed step is covered by the real-registry runs above. The first live exercise is the next release — and since the change only ever skips a publish that would have failed anyway, a wrong call cannot lose a version.

Notes

  • No changeset and no version bump. CI-only, per CONTRIBUTING: "No changeset is needed for pure-internal changes (tests, CI, …)".
  • Managers is wave F in the CLI-contract rollout and deliberately comes last, but this is a release-workflow fix rather than F1 alignment work, and it touches nothing F1 will.
  • I did not run a release, and the version PR is untouched.

🤖 Generated with Claude Code

An npm version can never be published twice, so re-running this job after
a LATER step failed dies with "You cannot publish over the previously
published versions". The Verify provenance landed comment worked around
that by telling you to "never re-run this job" -- which leaves a release
that published fine and then tripped over a later step with no recovery
path at all.

Paddock hit exactly this on 0.81.0: its provenance poll timed out, the
re-run died on the republish, and the run is permanently red even though
npm has the version with provenance (edspencer/paddock#988).

Skip a version already on the registry, so "Re-run failed jobs" finishes
the release. Localidraw, Hallway, Local Review, cli-contract, BragDoc and
now Paddock all do this; Managers was the last one without it.

Asks the registry directly with caching off, as Verify provenance landed
does, rather than through `npm view`: a cached packument predating the
publish would give a false "not on npm", which is the failure this
guards against. Only a 200 skips -- a 404, or a registry having a bad
day, publishes, exactly as this step did unconditionally before.

Managers' 30-minute poll already covers the registry lag that broke
Paddock's releases, so the verify step is unchanged apart from its
comment no longer banning a re-run.

CI-only, so no changeset and no version bump (CONTRIBUTING).

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@edspencer

Copy link
Copy Markdown
Owner Author

npm audit (high/critical) is red for a reason unrelated to this PR, and I am not merging over it.

This PR touches one file, .github/workflows/release.yml, and nothing in the dependency tree. The audit job fails on four advisories in existing dependencies that have no documented exception:

npm audit: 23 vulnerable packages (critical 4, high 6, moderate 11, low 2); 39 advisories, 12 documented exceptions.

4 high/critical advisory(ies) with no documented exception:
note: exception GHSA-vfj7-8cjw-p6xm (braces) no longer matches any advisory; remove it and its doc row.
  high     GHSA-27r3-jxmh-p828  body-parser: DoS via trailing bytes after a compressed request body
  critical GHSA-2f48-3555-fpx6  nodejs-whisper: OS command injection through crafted audio file paths
  high     GHSA-587h-7wmj-h5pm  vite: launch-editor `fs.existsSync()` bypass on Windows
  high     GHSA-mrhx-c7xc-m3w5  zod: memory exhaustion validating oversized constrained collections

Evidence that it is pre-existing and time-dependent, not caused here: this branch is cut from origin/main at f0aba1c, and the CI run for that same commit (39146938763, 2026-10-18) concluded success. The advisories have been published in the ~2.5 weeks since. The stale braces exception points the same way.

It will not go green on a re-run. Fixing it means bumping or triaging each of the four into docs/security/npm-audit-exceptions.json and docs/security/npm-audit.md with a reachability argument — a security judgement that deserves its own pass rather than being bundled into a release-workflow fix, and one that will unblock every other PR in this repo too.

So I am leaving this open rather than merging red. The companion fix in Paddock (edspencer/paddock#988) is independent and lands on its own.

🤖 Generated with Claude Code

@edspencer
edspencer merged commit 61dfbd5 into main Nov 5, 2026
4 checks passed
@edspencer
edspencer deleted the release-publish-idempotent branch November 5, 2026 08:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant