Skip to content

Commit 21b2d6d

Browse files
committed
Specify a tag for npm publish
1 parent ee6e83d commit 21b2d6d

1 file changed

Lines changed: 13 additions & 1 deletion

File tree

.github/workflows/publish-npm.yml

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,5 +42,17 @@ jobs:
4242
- name: Update npm
4343
run: npm install -g npm@latest
4444

45-
- run: npm publish
45+
- name: Determine npm tag
46+
id: npm-tag
47+
run: |
48+
PACKAGE_VERSION=$(node -p "require('./javascript/package.json').version")
49+
LATEST_VERSION=$(npm view @ruby/prism version 2>/dev/null || echo "0.0.0")
50+
if npx semver "$PACKAGE_VERSION" -r ">$LATEST_VERSION"; then
51+
echo "tag=latest" >> "$GITHUB_OUTPUT"
52+
else
53+
MINOR=$(echo "$PACKAGE_VERSION" | cut -d. -f1,2)
54+
echo "tag=v$MINOR" >> "$GITHUB_OUTPUT"
55+
fi
56+
57+
- run: npm publish --tag ${{ steps.npm-tag.outputs.tag }}
4658
working-directory: javascript

0 commit comments

Comments
 (0)