Skip to content

Commit b116fd3

Browse files
committed
Update action
1 parent a46c547 commit b116fd3

File tree

1 file changed

+18
-7
lines changed

1 file changed

+18
-7
lines changed

.github/workflows/publish.yml

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,24 +3,31 @@ name: Build and Publish to npm
33
on:
44
push:
55
tags:
6-
- '[0-9]+.[0-9]+.[0-9]+'
7-
- '[0-9]+.[0-9]+.[0-9]+-*'
6+
- 'v[0-9]+.[0-9]+.[0-9]+'
7+
- 'v[0-9]+.[0-9]+.[0-9]+-*'
88

99
jobs:
1010
build-and-publish:
1111
runs-on: ubuntu-latest
1212

1313
permissions:
14-
contents: read
1514
id-token: write
15+
contents: read
1616

1717
steps:
1818
- name: Checkout repository
1919
uses: actions/checkout@v4
2020

2121
- name: Get version from tag
2222
id: version
23-
run: echo "VERSION=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT
23+
run: |
24+
VERSION=${GITHUB_REF#refs/tags/}
25+
echo "VERSION=$VERSION" >> $GITHUB_OUTPUT
26+
if [[ "$VERSION" == *-* ]]; then
27+
echo "DRY_RUN=true" >> $GITHUB_OUTPUT
28+
else
29+
echo "DRY_RUN=false" >> $GITHUB_OUTPUT
30+
fi
2431
2532
- name: Setup Node.js
2633
uses: actions/setup-node@v4
@@ -39,10 +46,14 @@ jobs:
3946

4047
- name: Verify build output
4148
run: |
42-
echo "📦 Publishing version ${{ steps.version.outputs.VERSION }}"
49+
echo "📦 Version: ${{ steps.version.outputs.VERSION }}"
50+
echo "🧪 Dry run: ${{ steps.version.outputs.DRY_RUN }}"
4351
ls -la dist/
4452
53+
- name: Publish to npm (Dry Run)
54+
if: steps.version.outputs.DRY_RUN == 'true'
55+
run: npm publish --dry-run
56+
4557
- name: Publish to npm
58+
if: steps.version.outputs.DRY_RUN == 'false'
4659
run: npm publish --provenance --access public
47-
env:
48-
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

0 commit comments

Comments
 (0)