Skip to content

ci(release): fail when the tag and package.json version disagree - #180

Open
myselfsiddharth wants to merge 2 commits into
mainfrom
fix/release-version-guard
Open

ci(release): fail when the tag and package.json version disagree#180
myselfsiddharth wants to merge 2 commits into
mainfrom
fix/release-version-guard

Conversation

@myselfsiddharth

Copy link
Copy Markdown
Contributor

Summary

Pre-flighting the first npm release turned up a gap in .github/workflows/release.yml (added in #174, never yet run): nothing checks that the pushed tag matches the version in package.json.

The tag decides when to publish; package.json decides what gets published. Tagging v0.2.0 on a tree that still says 0.1.0 would publish 0.1.0 under a tag claiming 0.2.0 — or fail at the registry as "already published", after the token had already been used. This adds a step that fails before the registry call, while it is still free to fix.

Why this comes up now

There is already a stale v0.1.0 tag on main from 2026-08-09 (commit 90f66c6, far behind current HEAD). It predates release.yml, so it never triggered a run. Whoever cuts the first real release therefore has to either retag or bump — exactly the case this guard protects.

Test plan

  • Guard passes when tag matches: v0.1.0 + package.json 0.1.0publishing 0.1.0 from tag v0.1.0
  • Guard refuses on mismatch: v0.2.0 + package.json 0.1.0 → exits 1 with both versions named
  • Verified the existing forbidden-path guard has no false positives — \.env is an unanchored regex, but no file in the 179-file tarball contains env at all
  • npm pack --dry-run ships dist/src/, contracts/, README.md, LICENSE; dist/src/cli.js has its #!/usr/bin/env node shebang
  • Repo is public, so --provenance will work; id-token: write is already set

The tag decides when to publish; package.json decides what version is
published. Nothing tied the two together, so `git tag v0.2.0` on a tree
still saying 0.1.0 would publish 0.1.0 under a tag claiming otherwise —
or fail at the registry as "already published", after the token had
already been used.

Found while pre-flighting the first release: a stale `v0.1.0` tag from
2026-08-09 already exists on main (commit 90f66c6, well behind current
HEAD), and it predates release.yml, so it never fired. Whoever cuts the
real release has to pick a new version, which is exactly the situation
this guard covers.

Verified both branches locally against the real package.json: v0.1.0
passes, v0.2.0 refuses.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@myselfsiddharth
myselfsiddharth requested a review from a team as a code owner August 23, 2026 06:47
@github-actions github-actions Bot added the size/S <= 50 changed lines label Aug 23, 2026
@github-actions github-actions Bot added the area: ci Touches ci label Aug 23, 2026
@github-actions
github-actions Bot requested a review from OM152002 August 23, 2026 06:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: ci Touches ci size/S <= 50 changed lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant