ci: publish the tagged tree, not the branch tip - #563
Merged
Conversation
`npm version from-git` runs `git describe --tags`, which needs history back to the release tag. Two things break that: - `fetch-depth` defaults to 1, so the tag ref is fetched but disconnected from HEAD. This only worked so far because the tag happened to sit on the branch tip; once anything merges after the release, a re-run fails with `fatal: No tags can describe '<sha>'`. - Even when it resolves, the job packs the checked-out tree, so master content would be published under the tag's version number. Fetch the full history and check the tag out explicitly, so the tarball matches the release the version number claims. Co-Authored-By: Claude Opus 5 (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.
Follow-up to #561, needed before
v0.57.0can actually be published (#557).The bug
Merging #561 and #562 moved
masterpastv0.57.0, and that alone breaks the publish job. Reproduced by replaying exactly whatactions/checkout@v6does with the current settings (fetch-depthdefaulting to 1,fetch-tags: true) against today'smaster:fetch-tagsbrings the tag ref down, but a depth-1 clone has no commits connectingHEADto it, sogit describecannot walk back. This never surfaced before only because every previous release ran while the tag still sat on the branch tip.There is a second, quieter problem: even when
describedoes resolve, the job packs whatever tree is checked out. On aworkflow_runtrigger that is the default branch, not the tag — so master content could go out labelled with the tag's version.The fix
fetch-depth: 0so the tag is reachableVerified against a full clone of current
master: the tag resolves tov0.57.0,npm version from-gityields0.57.0, andgit diff v0.57.0 HEAD -- bdist/jsis empty, so the tree published is the released one.fetch-tagsis dropped asfetch-depth: 0already fetches tags.The workflow filename is unchanged, so the trusted publisher registration on npmjs.com still matches.
🤖 Generated with Claude Code