fix(release): pack the tarball after the CLI is rebuilt - #91
Merged
Merged
Conversation
`lingo-tracker --version` printed 0.16.0 on the published 0.17.0 package. The version is not hardcoded: apps/cli/src/main.ts uses `.version(__CLI_VERSION__)`, which esbuild replaces at build time from the root package.json. The bundle therefore freezes whatever version was current when the CLI was built. semantic-release runs its prepare steps in plugin order, and @semantic-release/npm both bumps package.json and packs the tarball in the same step. So the tarball was packed from the CLI built by the workflow's earlier `pnpm run build` — before the bump — and the @semantic-release/exec rebuild that followed came too late to reach it. `npm publish ./dist/*.tgz` then shipped the pre-bump bundle. Drop `tarballDir` from the npm plugin and pack from the exec step instead, after the rebuild. This is the ordering the `republish` job already uses: checkout the tag, build, then pack. Also verify the packed CLI reports the released version before publishing, so a regression fails the release instead of reaching npm. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01RifJr7xyhZkaTWn4ssV1b4
|
🎉 This PR is included in version 0.18.0 🎉 The release is available on GitHub release Your semantic-release bot 📦🚀 |
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.
Fixes the aside reported on #86:
lingo-tracker --versionprinted0.16.0on the published0.17.0package. Confirmed against the published tarball —package.jsonsays0.17.0,dist/apps/cli/main.cjssaysversion("0.16.0").Cause
The version is not hardcoded.
apps/cli/src/main.tsuses.version(__CLI_VERSION__), andapps/cli/esbuild.config.jsreplaces that token at build time from the rootpackage.json.The bundle therefore freezes whatever version was current when the CLI was built.
The workflow's
Buildstep runs beforepnpm run release, so the first CLI bundle carriesthe previous version. semantic-release then runs its
preparesteps in plugin order:@semantic-release/changelogCHANGELOG.md@semantic-release/npmpackage.json, then packs the tarball intodist/@semantic-release/execpnpm nx build cli --skip-nx-cache— rebuilds with the right version@semantic-release/gitStep 3 fixes the bundle, but step 2 already packed the tarball, so
npm publish ./dist/*.tgzships the pre-bump build.The
republishjob does not have the bug: it checks out the tag (already bumped), builds,then packs.
Fix
Drop
tarballDirfrom the npm plugin so it only bumps the version, and pack from the execstep after the rebuild — the ordering
republishalready proves works.Also adds a step that unpacks the tarball and fails the release if the packed CLI does not
report the version in
package.json, so a regression here stops before npm rather thanafter. Same spirit as the existing "Verify tag matches package version" step in
republish.Verified
Ran
nx build cli --skip-nx-cache && npm pack --pack-destination distlocally and unpackedthe result:
The tarball lands as
dist/simoncodes-ca-lingo-tracker-0.17.0.tgz, so the existingdist/*.tgzglob andhashFilesguard still match. The verify step's shell was exercisedboth ways: it passes on a matching tarball and its failure branch fires on a mismatched one.
One caveat: the fix can only fully prove itself on a real release run, since locally
package.jsonwas already at the released version. The verify step exists to catch it ifthe ordering is still wrong.
🤖 Generated with Claude Code
https://claude.ai/code/session_01RifJr7xyhZkaTWn4ssV1b4