Skip to content

Commit 961c315

Browse files
committed
Support pre-release publishing in npm-publish workflow
1 parent 44594cf commit 961c315

1 file changed

Lines changed: 15 additions & 2 deletions

File tree

.github/workflows/npm-publish.yml

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,11 +69,24 @@ jobs:
6969
- name: Pack
7070
run: ./scripts/npm-pack.sh
7171

72+
- name: Determine dist-tag
73+
id: dist-tag
74+
run: |
75+
VERSION=$(node -p "require('./package.json').version")
76+
if [[ "$VERSION" == *-* ]]; then
77+
# Pre-release version (e.g. 1.9.0-alpha.0) — extract pre-release label
78+
TAG=$(echo "$VERSION" | sed 's/.*-\([a-zA-Z]*\).*/\1/')
79+
echo "tag=$TAG" >> $GITHUB_OUTPUT
80+
else
81+
echo "tag=latest" >> $GITHUB_OUTPUT
82+
fi
83+
echo "Version: $VERSION, Tag: $(cat $GITHUB_OUTPUT | grep tag | cut -d= -f2)"
84+
7285
- name: Publish
7386
run: |
7487
if [[ "${{ inputs.dry_run }}" == "true" ]]; then
7588
echo "=== DRY RUN ==="
76-
npm publish --provenance --access public --dry-run ./dist/rclnodejs-*.tgz
89+
npm publish --provenance --access public --tag ${{ steps.dist-tag.outputs.tag }} --dry-run ./dist/rclnodejs-*.tgz
7790
else
78-
npm publish --provenance --access public ./dist/rclnodejs-*.tgz
91+
npm publish --provenance --access public --tag ${{ steps.dist-tag.outputs.tag }} ./dist/rclnodejs-*.tgz
7992
fi

0 commit comments

Comments
 (0)