Skip to content

ci(publish): skip publish when the version is already on the registry - #54

Merged
murffious merged 1 commit into
mainfrom
ci/skip-already-published
Sep 20, 2026
Merged

murffious merged 1 commit into
mainfrom
ci/skip-already-published

Conversation

@murffious

Copy link
Copy Markdown
Contributor

0.4.0 is on npm, published by Trusted Publishing from a workflow_dispatch run (#44 is closed with the root cause). The GitHub releases page still shows v0.3.0 as latest, so the repo needs a v0.4.0 tag — but creating one fires this workflow through on: release: [created], against a version already on the registry. npm answers:

E403 — You cannot publish over the previously published versions

which looks like the auth failures this workflow has spent six runs eliminating, and isn't one.

Change

One step before Publish, reading the registry for the version in package.json:

  • already there → set skip=true, emit a ::notice::, and Publish is skipped by if:
  • not there → publish exactly as before

Publishing behaviour is unchanged on the path that matters: a genuinely new version still goes out, still over OIDC, still with provenance. Only the redundant replay is skipped.

Why not just drop the release trigger

Tagging a release is the natural way to cut one, and dispatch is the escape hatch that got 0.4.0 out. Keeping both and making the job idempotent means the tag can be created at any time, before or after the publish, without the order mattering.

Verification

CHANGELOG.md is untouched: it records package behaviour per release, and this changes none. The guard is exercised by the v0.4.0 release created right after this merges — the run should go green with Publish skipped.

🤖 Generated with Claude Code

A release-triggered run and a workflow_dispatch run can land on the same
version. 0.4.0 was published by dispatch and tagged afterwards, so the
release event replayed the job against a version already on the registry.
npm answers E403 there, which reads like an auth failure and is not one.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@murffious
murffious merged commit 937604a into main Sep 20, 2026
1 check passed
@murffious
murffious deleted the ci/skip-already-published branch September 20, 2026 06:26
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