diff --git a/.github/workflows/npm-publish.yml b/.github/workflows/npm-publish.yml index fb1f8b70..3846ad1c 100644 --- a/.github/workflows/npm-publish.yml +++ b/.github/workflows/npm-publish.yml @@ -69,11 +69,31 @@ jobs: - name: Pack run: ./scripts/npm-pack.sh + - name: Determine dist-tag + id: dist_tag + run: | + TAG=$(node -p " + const v = require('./package.json').version; + const pre = v.split('-')[1]; + !pre ? 'latest' : (pre.split('.')[0].replace(/[0-9]+$/, '') || 'next') + ") + if [[ -z "$TAG" ]]; then + echo "::error::Failed to determine dist-tag" + exit 1 + fi + 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 --dry-run ./dist/rclnodejs-*.tgz + npm publish --provenance --access public --tag "$TAG" --dry-run ./dist/rclnodejs-*.tgz else - npm publish --provenance --access public ./dist/rclnodejs-*.tgz + npm publish --provenance --access public --tag "$TAG" ./dist/rclnodejs-*.tgz fi