fix(release): sync version.ts when changeset bumps package.json#944
Merged
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
src/lib/version.tshas been persistently out of sync withpackage.jsonafter every release —package.jsonbumps to the new version,version.tsstays at the previous one. Trace:package.jsonand updatesCHANGELOG.mdsrc/lib/version.ts—changeset versiononly knows aboutpackage.jsonnpm run build:libwhich runssync-versionand rewritesversion.tson the CI runner onlyLIBRARY_VERSION✅mainstill has the staleversion.ts❌The drift was harmless to consumers (npm got the right value) but visible on every fresh checkout —
npm run build:libwould silently rewriteversion.tsand developers would have a "modified" file they couldn't usefully commit.Fix
Chain
sync-versionafterchangeset versionin theversionnpm script. Now the Release PR includes the syncedversion.ts, and merging keeps both files in lockstep.Also includes a one-time catch-up:
version.tsbumped from5.16.0to5.17.0to 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.tsmodified afternpm run build:lib. Each PR had to either include the catch-up bump (mixing it with unrelated changes) orgit checkout --it before commit (just deferring the problem).Test plan
npx tsx scripts/sync-version.tsrewritesversion.tsto matchpackage.json's5.17.0LIBRARY_VERSIONwas always correct via build-time syncversion.tsupdates alongsidepackage.json/CHANGELOG.mdTradeoffs
Ties Release-PR creation to
sync-version's correctness.sync-versionalready runs on everybuild:libtoday, so its blast radius is unchanged. The new failure mode: a malformedADCP_VERSIONfile would break Release PR creation instead of silently shipping drift — which is what we want.🤖 Generated with Claude Code