Skip to content

Commit 95a1ed4

Browse files
committed
Address comments
1 parent 961c315 commit 95a1ed4

1 file changed

Lines changed: 18 additions & 10 deletions

File tree

.github/workflows/npm-publish.yml

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -72,21 +72,29 @@ jobs:
7272
- name: Determine dist-tag
7373
id: dist-tag
7474
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
75+
TAG=$(node -p "
76+
const v = require('./package.json').version;
77+
const pre = v.split('-')[1];
78+
if (!pre) { 'latest' }
79+
else { pre.split('.')[0].replace(/[0-9]+$/, '') || 'next' }
80+
")
81+
if [[ -z "$TAG" ]]; then
82+
echo "::error::Failed to determine dist-tag"
83+
exit 1
8284
fi
83-
echo "Version: $VERSION, Tag: $(cat $GITHUB_OUTPUT | grep tag | cut -d= -f2)"
85+
echo "tag=$TAG" >> "$GITHUB_OUTPUT"
86+
echo "Resolved dist-tag: $TAG"
8487
8588
- name: Publish
8689
run: |
90+
TAG="${{ steps.dist-tag.outputs.tag }}"
91+
if [[ -z "$TAG" ]]; then
92+
echo "::error::dist-tag is empty, aborting publish"
93+
exit 1
94+
fi
8795
if [[ "${{ inputs.dry_run }}" == "true" ]]; then
8896
echo "=== DRY RUN ==="
89-
npm publish --provenance --access public --tag ${{ steps.dist-tag.outputs.tag }} --dry-run ./dist/rclnodejs-*.tgz
97+
npm publish --provenance --access public --tag "$TAG" --dry-run ./dist/rclnodejs-*.tgz
9098
else
91-
npm publish --provenance --access public --tag ${{ steps.dist-tag.outputs.tag }} ./dist/rclnodejs-*.tgz
99+
npm publish --provenance --access public --tag "$TAG" ./dist/rclnodejs-*.tgz
92100
fi

0 commit comments

Comments
 (0)