1- # This workflow will run tests using node and then publish a package to GitHub Packages when a release is created
2- # For more information see: https://docs.github.com/en/actions/publishing-packages/publishing-nodejs-packages
3-
4- name : Release Git Package & Publish on NPM
1+ name : Release & Publish
52
63on :
74 push :
118jobs :
129 release :
1310 runs-on : ubuntu-latest
11+ outputs :
12+ version : ${{ steps.version.outputs.new_version }}
1413
1514 steps :
1615 # Checkout repo
@@ -21,26 +20,31 @@ jobs:
2120 - name : Setup Node.js
2221 uses : actions/setup-node@v4
2322 with :
24- node-version : ' 20'
25- registry-url : ' https://registry.npmjs.org/'
23+ node-version : ' 24'
24+
25+ # Git identity (required for npm version)
26+ - name : Setup Git identity
27+ run : |
28+ git config user.name "github-actions[bot]"
29+ git config user.email "github-actions[bot]@users.noreply.github.com"
2630
2731 # Install deps
2832 - name : Install dependencies
2933 run : npm install
3034
31- # Bump version dynamically & push tag
35+ # Bump version dynamically
3236 - name : Bump version
3337 id : version
3438 run : |
35- # Author identity
39+
40+ # gitbot
3641 git config user.name "github-actions[bot]"
37- git config user.email "github-actions[bot]@users.noreply.github.com"
38-
39- # Bump patch version (you can change to minor/major if needed)
42+ git config user.email "github-actions[bot]@users.noreply.github.com"
43+
4044 NEW_VERSION=$(npm version patch -m "chore(release) : v%s [skip ci]")
4145 echo "new_version=$NEW_VERSION" >> $GITHUB_OUTPUT
4246
43- # Push updated package.json and tag to main
47+ # Push changes (commit + tag)
4448 - name : Push changes
4549 uses : ad-m/github-push-action@v0.8.0
4650 with :
5761 env :
5862 GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
5963
60- # Publish to NPM
64+ publish-npm :
65+ needs : release # ⬅ Runs only after release is successful
66+ runs-on : ubuntu-latest
67+ steps :
68+ - name : Checkout code
69+ uses : actions/checkout@v4
70+
71+ - name : Setup Node.js
72+ uses : actions/setup-node@v4
73+ with :
74+ node-version : ' 24'
75+ registry-url : ' https://registry.npmjs.org/'
76+
77+ - name : Install dependencies
78+ run : npm install
79+
80+ - name : Build package
81+ run : npm run build
82+
6183 - name : Publish to NPM
62- run : npm publish
84+ run : npm publish --access public
6385 env :
6486 NODE_AUTH_TOKEN : ${{ secrets.NPM_TOKEN }}
0 commit comments