1- name : Git Package Release & Publish oon NPM
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 : Node.js Package
25
36on :
4- push :
5- branches :
6- - main
7+ release :
8+ types : [created]
79
8- permissions :
9- contents : write # needed to push commits, tags, and create releases
10- packages : write # needed for publishing GitHub packages (optional)
11-
1210jobs :
13- release :
11+ build :
1412 runs-on : ubuntu-latest
15- outputs :
16- version : ${{ steps.version.outputs.new_version }}
17-
1813 steps :
19- # Checkout repo
20- - name : Checkout code
21- uses : actions/checkout@v4
22-
23- # Setup Node.js
24- - name : Setup Node.js
25- uses : actions/setup-node@v4
14+ - uses : actions/checkout@v4
15+ - uses : actions/setup-node@v4
2616 with :
27- node-version : ' 24'
17+ node-version : 24
18+ - run : npm run build
2819
29- # Git identity (required for npm version)
30- - name : Setup Git identity
31- run : |
32- git config user.name "github-actions[bot]"
33- git config user.email "github-actions[bot]@users.noreply.github.com"
34-
35- # Install dependencies
36- - name : Install dependencies
37- run : npm install
38-
39- # Bump version dynamically
40- - name : Bump version
41- id : version
42- run : |
43- NEW_VERSION=$(npm version patch -m "chore(release): v%s [skip ci]")
44- echo "new_version=$NEW_VERSION" >> $GITHUB_OUTPUT
45-
46- # Push changes (commit + tag)
47- - name : Push changes
48- uses : ad-m/github-push-action@v0.8.0
49- with :
50- github_token : ${{ secrets.GITHUB_TOKEN }}
51- branch : main
52- tags : true
53-
54- # Create GitHub Release
55- - name : Create GitHub Release
56- uses : softprops/action-gh-release@v2
57- with :
58- tag_name : ${{ steps.version.outputs.new_version }}
59- name : Release ${{ steps.version.outputs.new_version }}
60- env :
61- GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
20+ - name : Change directory to dist
21+ run : cd dist
6222
6323 publish-npm :
64- needs : release # ⬅ Runs only after release is successful
24+ needs : build
6525 runs-on : ubuntu-latest
66-
6726 steps :
68- - name : Checkout code
69- uses : actions/checkout@v4
70-
71- - name : Setup Node.js
72- uses : actions/setup-node@v4
27+ - uses : actions/checkout@v4
28+ - uses : actions/setup-node@v4
7329 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-
83- - name : Publish to NPM
30+ node-version : 24
31+ registry-url : https://registry.npmjs.org/
32+
33+ - name : Publish to npm
8434 run : npm publish --access public
8535 env :
86- NODE_AUTH_TOKEN : ${{ secrets.NPM_TOKEN }}
36+ NODE_AUTH_TOKEN : ${{secrets.NPM_AUTH_TOKEN }}
0 commit comments