From 961c3150be817bd5841d2bd38a8115afba24746b Mon Sep 17 00:00:00 2001 From: Minggang Wang Date: Wed, 1 Apr 2026 15:04:34 +0800 Subject: [PATCH 1/3] Support pre-release publishing in npm-publish workflow --- .github/workflows/npm-publish.yml | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/.github/workflows/npm-publish.yml b/.github/workflows/npm-publish.yml index fb1f8b70..42a30008 100644 --- a/.github/workflows/npm-publish.yml +++ b/.github/workflows/npm-publish.yml @@ -69,11 +69,24 @@ jobs: - name: Pack run: ./scripts/npm-pack.sh + - name: Determine dist-tag + id: dist-tag + run: | + VERSION=$(node -p "require('./package.json').version") + if [[ "$VERSION" == *-* ]]; then + # Pre-release version (e.g. 1.9.0-alpha.0) — extract pre-release label + TAG=$(echo "$VERSION" | sed 's/.*-\([a-zA-Z]*\).*/\1/') + echo "tag=$TAG" >> $GITHUB_OUTPUT + else + echo "tag=latest" >> $GITHUB_OUTPUT + fi + echo "Version: $VERSION, Tag: $(cat $GITHUB_OUTPUT | grep tag | cut -d= -f2)" + - name: Publish run: | if [[ "${{ inputs.dry_run }}" == "true" ]]; then echo "=== DRY RUN ===" - npm publish --provenance --access public --dry-run ./dist/rclnodejs-*.tgz + npm publish --provenance --access public --tag ${{ steps.dist-tag.outputs.tag }} --dry-run ./dist/rclnodejs-*.tgz else - npm publish --provenance --access public ./dist/rclnodejs-*.tgz + npm publish --provenance --access public --tag ${{ steps.dist-tag.outputs.tag }} ./dist/rclnodejs-*.tgz fi From 95a1ed42ff63205ba3e6742bb549b680b16f64d7 Mon Sep 17 00:00:00 2001 From: Minggang Wang Date: Wed, 1 Apr 2026 15:22:04 +0800 Subject: [PATCH 2/3] Address comments --- .github/workflows/npm-publish.yml | 28 ++++++++++++++++++---------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/.github/workflows/npm-publish.yml b/.github/workflows/npm-publish.yml index 42a30008..b9a84704 100644 --- a/.github/workflows/npm-publish.yml +++ b/.github/workflows/npm-publish.yml @@ -72,21 +72,29 @@ jobs: - name: Determine dist-tag id: dist-tag run: | - VERSION=$(node -p "require('./package.json').version") - if [[ "$VERSION" == *-* ]]; then - # Pre-release version (e.g. 1.9.0-alpha.0) — extract pre-release label - TAG=$(echo "$VERSION" | sed 's/.*-\([a-zA-Z]*\).*/\1/') - echo "tag=$TAG" >> $GITHUB_OUTPUT - else - echo "tag=latest" >> $GITHUB_OUTPUT + TAG=$(node -p " + const v = require('./package.json').version; + const pre = v.split('-')[1]; + if (!pre) { 'latest' } + else { pre.split('.')[0].replace(/[0-9]+$/, '') || 'next' } + ") + if [[ -z "$TAG" ]]; then + echo "::error::Failed to determine dist-tag" + exit 1 fi - echo "Version: $VERSION, Tag: $(cat $GITHUB_OUTPUT | grep tag | cut -d= -f2)" + echo "tag=$TAG" >> "$GITHUB_OUTPUT" + echo "Resolved dist-tag: $TAG" - name: Publish run: | + TAG="${{ steps.dist-tag.outputs.tag }}" + if [[ -z "$TAG" ]]; then + echo "::error::dist-tag is empty, aborting publish" + exit 1 + fi if [[ "${{ inputs.dry_run }}" == "true" ]]; then echo "=== DRY RUN ===" - npm publish --provenance --access public --tag ${{ steps.dist-tag.outputs.tag }} --dry-run ./dist/rclnodejs-*.tgz + npm publish --provenance --access public --tag "$TAG" --dry-run ./dist/rclnodejs-*.tgz else - npm publish --provenance --access public --tag ${{ steps.dist-tag.outputs.tag }} ./dist/rclnodejs-*.tgz + npm publish --provenance --access public --tag "$TAG" ./dist/rclnodejs-*.tgz fi From 71f8e3a4bd13a9e344abc40a9b9edfe50b0d3e91 Mon Sep 17 00:00:00 2001 From: Minggang Wang Date: Wed, 1 Apr 2026 15:30:58 +0800 Subject: [PATCH 3/3] Address comments --- .github/workflows/npm-publish.yml | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/.github/workflows/npm-publish.yml b/.github/workflows/npm-publish.yml index b9a84704..3846ad1c 100644 --- a/.github/workflows/npm-publish.yml +++ b/.github/workflows/npm-publish.yml @@ -70,13 +70,12 @@ jobs: run: ./scripts/npm-pack.sh - name: Determine dist-tag - id: dist-tag + id: dist_tag run: | TAG=$(node -p " const v = require('./package.json').version; const pre = v.split('-')[1]; - if (!pre) { 'latest' } - else { pre.split('.')[0].replace(/[0-9]+$/, '') || 'next' } + !pre ? 'latest' : (pre.split('.')[0].replace(/[0-9]+$/, '') || 'next') ") if [[ -z "$TAG" ]]; then echo "::error::Failed to determine dist-tag" @@ -87,7 +86,7 @@ jobs: - name: Publish run: | - TAG="${{ steps.dist-tag.outputs.tag }}" + TAG="${{ steps.dist_tag.outputs.tag }}" if [[ -z "$TAG" ]]; then echo "::error::dist-tag is empty, aborting publish" exit 1