11name : Publish to npm and create GitHub Release
22
33on :
4- push :
5- branches : master
6-
4+ push :
5+ branches : master
6+
77jobs :
8- publish :
9- runs-on : ubuntu-latest
10- steps :
11- - uses : actions/checkout@v4
12- - uses : actions/setup-node@v3
13- with :
14- node-version : " 20"
15- - run : npm ci
16- - uses : JS-DevTools/npm-publish@v3
17- with :
18- token : ${{ secrets.NPM_TOKEN }}
8+ publish :
9+ runs-on : ubuntu-latest
10+
11+ steps :
12+ - name : Checkout code
13+ uses : actions/checkout@v4
14+
15+ - name : Setup Node.js
16+ uses : actions/setup-node@v3
17+ with :
18+ node-version : " 20"
19+ registry-url : ' https://registry.npmjs.org'
20+
21+ - name : Install dependencies
22+ run : npm ci
23+
24+ - name : Publish to npm
25+ uses : JS-DevTools/npm-publish@v3
26+ with :
27+ token : ${{ secrets.NPM_TOKEN }}
28+
29+ - name : Configure .npmrc for GitHub Packages
30+ run : |
31+ echo "//npm.pkg.github.com/:_authToken=\${{ secrets.GITHUB_TOKEN }}" > ~/.npmrc
32+ echo "@${{ secrets.GITHUB_USERNAME }}:registry=https://npm.pkg.github.com" >> ~/.npmrc
33+
34+ - name : Publish to GitHub Packages
35+ run : npm publish
36+ env :
37+ NODE_AUTH_TOKEN : ${{ secrets.GITHUB_TOKEN }}
38+
39+ - name : Create GitHub Release
40+ id : create_release
41+ uses : actions/create-release@v1
42+ env :
43+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
44+ with :
45+ tag_name : v${{ github.event.head_commit.timestamp }}
46+ release_name : Release v${{ github.event.head_commit.timestamp }}
47+ draft : false
48+ prerelease : false
49+
50+ - name : Upload Release Asset
51+ uses : actions/upload-release-asset@v1
52+ env :
53+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
54+ with :
55+ upload_url : ${{ steps.create_release.outputs.upload_url }}
56+ asset_path : ./path-to-your-asset.zip
57+ asset_name : your-asset.zip
58+ asset_content_type : application/zip
0 commit comments