Skip to content

fix(release): sync version.ts when changeset bumps package.json#944

Merged
bokelley merged 1 commit into
mainfrom
bokelley/version-ts-sync-fix
Apr 25, 2026
Merged

fix(release): sync version.ts when changeset bumps package.json#944
bokelley merged 1 commit into
mainfrom
bokelley/version-ts-sync-fix

Conversation

@bokelley

Copy link
Copy Markdown
Contributor

Summary

src/lib/version.ts has been persistently out of sync with package.json after every release — package.json bumps to the new version, version.ts stays at the previous one. Trace:

  1. Developer merges a PR with a changeset
  2. Changesets bot creates a Release PR that bumps package.json and updates CHANGELOG.md
  3. Release PR doesn't touch src/lib/version.tschangeset version only knows about package.json
  4. Release PR merges to main; release workflow runs npm run build:lib which runs sync-version and rewrites version.ts on the CI runner only
  5. npm tarball ships with correct LIBRARY_VERSION
  6. Git tree on main still has the stale version.ts

The drift was harmless to consumers (npm got the right value) but visible on every fresh checkout — npm run build:lib would silently rewrite version.ts and developers would have a "modified" file they couldn't usefully commit.

Fix

Chain sync-version after changeset version in the version npm script. Now the Release PR includes the synced version.ts, and merging keeps both files in lockstep.

- "version": "changeset version",
+ "version": "changeset version && npm run sync-version",

Also includes a one-time catch-up: version.ts bumped from 5.16.0 to 5.17.0 to match the published package and clear the existing drift on main.

Why now

The drift surfaced repeatedly during PRs #931, #934, #938 — every fresh checkout had version.ts modified after npm run build:lib. Each PR had to either include the catch-up bump (mixing it with unrelated changes) or git checkout -- it before commit (just deferring the problem).

Test plan

  • Local dry-run: npx tsx scripts/sync-version.ts rewrites version.ts to match package.json's 5.17.0
  • No behavior change at runtime — published npm package's LIBRARY_VERSION was always correct via build-time sync
  • Verified on next release: when the next changeset Release PR opens, it will include version.ts updates alongside package.json/CHANGELOG.md

Tradeoffs

Ties Release-PR creation to sync-version's correctness. sync-version already runs on every build:lib today, so its blast radius is unchanged. The new failure mode: a malformed ADCP_VERSION file would break Release PR creation instead of silently shipping drift — which is what we want.

🤖 Generated with Claude Code

Changesets bumps `package.json` for the Release PR but doesn't know
about `src/lib/version.ts` (`scripts/sync-version.ts` is what writes
the latter from the former). Result: every release left git-tree
`version.ts` stale, even though the npm tarball was always correct
because `build:lib` runs `sync-version` on the CI runner. The drift
was visible — `package.json` at 5.17.0 while `version.ts` at 5.16.0
on main — but the published artifact was fine, so the gap silently
re-opened on every release.

Fix: chain `npm run sync-version` after `changeset version` so the
Release PR includes the synced `version.ts`. When merged, both files
stay in lockstep.

Also includes a one-time catch-up: `version.ts` bumped from 5.16.0 to
5.17.0 to match the published package and clear the existing drift.

No runtime behavior change.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@bokelley bokelley merged commit ce4d1ce into main Apr 25, 2026
9 checks passed
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