Skip to content

Commit d37e8f2

Browse files
committed
chore(ci): update npm publish workflow to support prereleases
- Detects prerelease tags (vX.Y.Z-rc.N, vX.Y.Z-beta.N, etc.) - Publishes prereleases with their corresponding dist-tag (rc, beta, next, alpha) - Stable tags (vX.Y.Z) continue to publish as latest
1 parent b7edf1c commit d37e8f2

1 file changed

Lines changed: 16 additions & 2 deletions

File tree

.github/workflows/npm-publish.yml

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@ name: 📦 Auto Publish to npm
55
on:
66
push:
77
tags:
8-
- 'v*.*.*'
8+
- 'v*.*.*' # stable tags like v1.2.3
9+
- 'v*.*.*-*' # prerelease tags like v1.2.3-rc.1, v1.2.3-beta.0
910
workflow_dispatch:
1011

1112
jobs:
@@ -38,6 +39,19 @@ jobs:
3839
run: npm run compile
3940

4041
- name: 🚀 Publish to npm
41-
run: npm publish --access public
4242
env:
4343
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
44+
run: |
45+
VERSION=${GITHUB_REF_NAME#v} # strip "v" prefix
46+
echo "Publishing version $VERSION"
47+
48+
if [[ "$VERSION" == *-* ]]; then
49+
# It's a prerelease (contains "-rc", "-beta", etc.)
50+
TAG=$(echo $VERSION | sed 's/^[0-9.]*-//' | cut -d. -f1)
51+
echo "Detected prerelease, using dist-tag=$TAG"
52+
npm publish --access public --tag "$TAG"
53+
else
54+
# Stable release
55+
echo "Detected stable release, using dist-tag=latest"
56+
npm publish --access public --tag latest
57+
fi

0 commit comments

Comments
 (0)