Skip to content

Commit 99bbaf5

Browse files
committed
ci: extract tag logic in publish workflow
1 parent 035477f commit 99bbaf5

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

.github/workflows/publish.yml

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,19 @@ jobs:
2828
- name: Build
2929
run: npm run build
3030

31+
- name: Determine npm tag
32+
id: npm-tag
33+
run: |
34+
VERSION=$(node -p "require('./package.json').version")
35+
if [[ "$VERSION" == *"-"* ]]; then
36+
# Prerelease version - extract tag (e.g., "alpha" from "0.0.1-alpha.0")
37+
TAG=$(echo "$VERSION" | sed 's/.*-\([a-zA-Z]*\).*/\1/')
38+
echo "tag=$TAG" >> $GITHUB_OUTPUT
39+
else
40+
echo "tag=latest" >> $GITHUB_OUTPUT
41+
fi
42+
3143
- name: Publish
32-
run: npm publish --provenance --access public
44+
run: npm publish --provenance --access public --tag ${{ steps.npm-tag.outputs.tag }}
3345
env:
3446
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

0 commit comments

Comments
 (0)