Skip to content

Commit 852581d

Browse files
Adding workflow to publish to NPM on a github release
1 parent bc28861 commit 852581d

File tree

1 file changed

+40
-0
lines changed

1 file changed

+40
-0
lines changed

.github/workflows/npm-publish.yml

+40
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
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: Publish to NPM
5+
6+
on:
7+
release:
8+
types: [published]
9+
10+
jobs:
11+
build-and-test:
12+
runs-on: ubuntu-latest
13+
steps:
14+
- uses: actions/checkout@v3
15+
- uses: actions/setup-node@v3
16+
with:
17+
node-version: 16
18+
- run: npm ci
19+
- run: npm test
20+
21+
main-branch-check:
22+
needs: build-and-test
23+
if: ${{ github.repository == 'auth0/node-jsonwebtoken' }} && ${{ github.ref == 'refs/heads/master' }}
24+
runs-on: ubuntu-latest
25+
steps:
26+
- run: echo "Publishing package to NPM"
27+
28+
publish-npm:
29+
needs: main-branch-check
30+
runs-on: ubuntu-latest
31+
steps:
32+
- uses: actions/checkout@v3
33+
- uses: actions/setup-node@v3
34+
with:
35+
node-version: 16
36+
registry-url: https://registry.npmjs.org/
37+
- run: npm ci
38+
- run: npm publish
39+
env:
40+
NODE_AUTH_TOKEN: ${{secrets.npm_token}}

0 commit comments

Comments
 (0)