File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -3,7 +3,6 @@ name: Publish to npm
33on :
44 push :
55 branches : [main]
6- workflow_dispatch :
76
87concurrency :
98 group : publish
@@ -12,14 +11,8 @@ concurrency:
1211jobs :
1312 publish :
1413 runs-on : ubuntu-latest
15- permissions :
16- contents : write
17- pull-requests : write
18- id-token : write
1914 steps :
2015 - uses : actions/checkout@v4
21- with :
22- fetch-depth : 0
2316
2417 - uses : pnpm/action-setup@v4
2518 with :
@@ -31,13 +24,19 @@ jobs:
3124 registry-url : https://registry.npmjs.org
3225
3326 - run : pnpm install --no-frozen-lockfile
27+ - run : pnpm build
3428
35- - name : Create Release Pull Request or Publish
36- id : changesets
37- uses : changesets/action@v1
38- with :
39- publish : pnpm run release
29+ - name : Publish if version is new
30+ run : |
31+ PACKAGE_NAME=$(node -p "require('./package.json').name")
32+ LOCAL_VER=$(node -p "require('./package.json').version")
33+ NPM_VER=$(npm view "$PACKAGE_NAME" version 2>/dev/null || echo "0.0.0")
34+
35+ if [ "$LOCAL_VER" = "$NPM_VER" ]; then
36+ echo "v$LOCAL_VER already on npm — skipping"
37+ else
38+ npm publish --access public
39+ echo "Published $PACKAGE_NAME@$LOCAL_VER"
40+ fi
4041 env :
41- GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
42- NPM_TOKEN : ${{ secrets.NPM_TOKEN }}
4342 NODE_AUTH_TOKEN : ${{ secrets.NPM_TOKEN }}
You can’t perform that action at this time.
0 commit comments