File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ name : Publish to NPM
2+
3+ on :
4+ push :
5+ branches : [ master ]
6+ tags : [ 'v*' ]
7+ release :
8+ types : [ published ]
9+
10+ jobs :
11+ publish :
12+ runs-on : ubuntu-latest
13+ permissions :
14+ contents : write
15+
16+ steps :
17+ - name : Checkout code
18+ uses : actions/checkout@v4
19+ with :
20+ fetch-depth : 0
21+ token : ${{ secrets.GH_TOKEN }}
22+
23+ - name : Setup Node.js
24+ uses : actions/setup-node@v4
25+ with :
26+ node-version : ' 18'
27+ registry-url : ' https://registry.npmjs.org/'
28+
29+ - name : Install dependencies
30+ run : npm ci
31+
32+ - name : Run tests
33+ run : npm test -- --passWithNoTests
34+
35+ - name : Build package
36+ run : npm run build
37+
38+ - name : Conditional version bump and publish
39+ run : |
40+ if [[ ${{ github.ref }} == refs/tags/* ]]; then
41+ echo "Tag push - langsung publish tanpa bump version"
42+ npm publish --access public
43+ else
44+ echo "Regular push - bump version dan publish"
45+ npm version patch -m "ci: bump version to %s [skip ci]"
46+ npm publish --access public
47+ fi
48+ env :
49+ NODE_AUTH_TOKEN : ${{ secrets.NPM_TOKEN }}
50+
51+ - name : Push version changes
52+ if : startsWith(github.ref, 'refs/heads/')
53+ run : git push origin master --follow-tags
54+ env :
55+ GITHUB_TOKEN : ${{ secrets.GH_TOKEN }}
You can’t perform that action at this time.
0 commit comments