Skip to content

Commit 31d7a34

Browse files
DavertMikclaude
andcommitted
ci: derive npm dist-tag from prerelease label
`npm publish` fails on a prerelease version unless `--tag` is given, otherwise it would silently land on `latest`. Parse the prerelease label out of the release tag (4.0.0-beta.1 -> beta, 4.0.0-rc.1 -> rc) and pass it through; stable releases keep the default `latest`. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent cb6ce7c commit 31d7a34

1 file changed

Lines changed: 9 additions & 1 deletion

File tree

.github/workflows/publish.yml

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,4 +44,12 @@ jobs:
4444
run: npm version "${{ github.event.release.tag_name }}" --no-git-tag-version
4545

4646
- name: Publish to npm
47-
run: npm publish --provenance --access public
47+
run: |
48+
VERSION="${{ github.event.release.tag_name }}"
49+
if [[ "$VERSION" == *-* ]]; then
50+
# prerelease (e.g. 4.0.0-beta.1, 4.0.0-rc.2) — derive dist-tag from label
51+
TAG=$(echo "$VERSION" | sed -E 's/^[^-]+-([a-zA-Z]+).*/\1/')
52+
npm publish --provenance --access public --tag "$TAG"
53+
else
54+
npm publish --provenance --access public
55+
fi

0 commit comments

Comments
 (0)