Skip to content

ci: publish the tagged tree, not the branch tip - #563

Merged
yoheimuta merged 1 commit into
masterfrom
ci/publish-npm-from-tag
Aug 14, 2026
Merged

ci: publish the tagged tree, not the branch tip#563
yoheimuta merged 1 commit into
masterfrom
ci/publish-npm-from-tag

Conversation

@yoheimuta

Copy link
Copy Markdown
Owner

Follow-up to #561, needed before v0.57.0 can actually be published (#557).

The bug

Merging #561 and #562 moved master past v0.57.0, and that alone breaks the publish job. Reproduced by replaying exactly what actions/checkout@v6 does with the current settings (fetch-depth defaulting to 1, fetch-tags: true) against today's master:

HEAD: 630f68e Merge pull request #561 from yoheimuta/ci/npm-trusted-publishing
tags present: 122  (v0.57.0? v0.57.0)
git describe --tags --abbrev=0 => fatal: No tags can describe '630f68e...'

npm error command git --no-replace-objects describe --tags --abbrev=0 --match=*.*.*
npm error fatal: No tags can describe '630f68e...'

fetch-tags brings the tag ref down, but a depth-1 clone has no commits connecting HEAD to it, so git describe cannot 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 describe does resolve, the job packs whatever tree is checked out. On a workflow_run trigger that is the default branch, not the tag — so master content could go out labelled with the tag's version.

The fix

  • fetch-depth: 0 so the tag is reachable
  • check the tag out explicitly before packing, so the tarball is the tagged tree

Verified against a full clone of current master: the tag resolves to v0.57.0, npm version from-git yields 0.57.0, and git diff v0.57.0 HEAD -- bdist/js is empty, so the tree published is the released one.

fetch-tags is dropped as fetch-depth: 0 already fetches tags.

The workflow filename is unchanged, so the trusted publisher registration on npmjs.com still matches.

🤖 Generated with Claude Code

`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>
@yoheimuta
yoheimuta merged commit 2d47b5a into master Aug 14, 2026
6 checks passed
@yoheimuta
yoheimuta deleted the ci/publish-npm-from-tag branch August 14, 2026 11:33
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