diff --git a/.github/workflows/npmjs-release.yml b/.github/workflows/npmjs-release.yml index 4219ada..0d69d5e 100644 --- a/.github/workflows/npmjs-release.yml +++ b/.github/workflows/npmjs-release.yml @@ -31,4 +31,24 @@ jobs: - run: npm test - run: npm run build - run: npm run validate:package:dist - - run: cd dist && npm publish --access=public \ No newline at end of file + - name: Publish to npm + shell: bash + run: | + VERSION="$(node -p "require('./dist/package.json').version")" + + if [[ "$VERSION" == *-* ]]; then + PRERELEASE_TAG="${VERSION#*-}" + PRERELEASE_TAG="${PRERELEASE_TAG%%[0-9]*}" + + if [[ -z "$PRERELEASE_TAG" ]]; then + PRERELEASE_TAG="next" + fi + + echo "Publishing prerelease $VERSION with tag '$PRERELEASE_TAG'" + cd dist + npm publish --access public --tag "$PRERELEASE_TAG" + else + echo "Publishing stable release $VERSION with tag 'latest'" + cd dist + npm publish --access public + fi \ No newline at end of file