Skip to content

Commit e087376

Browse files
committed
ci(publish-npm): add pre-release tag when publishing pre-releases on npm
1 parent 5a53aeb commit e087376

1 file changed

Lines changed: 14 additions & 1 deletion

File tree

.github/workflows/ci.yml

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,20 @@ jobs:
5050
- name: Publish to npm
5151
env:
5252
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
53-
run: pnpm publish --access public
53+
run: |
54+
# Extract version from package.json
55+
VERSION=$(node -p "require('./package.json').version")
56+
57+
# Check if it's a prerelease version (contains a hyphen, e.g., 3.0.0-alpha.0)
58+
if [[ "$VERSION" == *-* ]]; then
59+
# Extract the prerelease tag (e.g., "alpha" from "3.0.0-alpha.0")
60+
PRERELEASE_TAG=$(echo "$VERSION" | sed 's/.*-\([a-zA-Z]*\).*/\1/')
61+
echo "Publishing prerelease version $VERSION with tag: $PRERELEASE_TAG"
62+
pnpm publish --access public --tag "$PRERELEASE_TAG"
63+
else
64+
echo "Publishing stable version $VERSION"
65+
pnpm publish --access public
66+
fi
5467
5568
deploy-docs:
5669
needs: build-and-test

0 commit comments

Comments
 (0)