Skip to content

Commit e1c4b1b

Browse files
committed
update
added an npm publish job
1 parent 5e3ed18 commit e1c4b1b

File tree

1 file changed

+30
-15
lines changed

1 file changed

+30
-15
lines changed

.github/workflows/node.js.yml

Lines changed: 30 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ jobs:
1414
strategy:
1515
matrix:
1616
node-version: [19.x, 20.x, 21.x]
17-
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/
1817

1918
steps:
2019
- uses: actions/checkout@v3
@@ -30,17 +29,33 @@ jobs:
3029
- run: xvfb-run --auto-servernum npm run test:chrome
3130
- run: xvfb-run --auto-servernum npm run test:firefox
3231

33-
- name: Publish to npm dry-run
34-
env:
35-
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
36-
run: |
37-
echo "//registry.npmjs.org/:_authToken=${NPM_TOKEN}" > ~/.npmrc
38-
npm publish --dry-run
39-
40-
- name: Publish to npm
41-
if: github.ref == 'refs/heads/master' && github.event_name == 'push'
42-
env:
43-
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
44-
run: |
45-
echo "//registry.npmjs.org/:_authToken=${NPM_TOKEN}" > ~/.npmrc
46-
npm publish
32+
# Separate job for publishing to npm
33+
publish:
34+
runs-on: ubuntu-latest
35+
needs: build # Wait for build to complete
36+
if: github.ref == 'refs/heads/master' && github.event_name == 'push'
37+
38+
steps:
39+
- uses: actions/checkout@v3
40+
- name: Use Node.js 20.x
41+
uses: actions/setup-node@v3
42+
with:
43+
node-version: "20.x"
44+
cache: "npm"
45+
- run: npm install
46+
- run: npm run build
47+
48+
- name: Publish to npm dry-run
49+
env:
50+
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
51+
run: |
52+
echo "//registry.npmjs.org/:_authToken=${NPM_TOKEN}" > ~/.npmrc
53+
npm publish --dry-run
54+
55+
- name: Publish to npm
56+
if: github.ref == 'refs/heads/master' && github.event_name == 'push'
57+
env:
58+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
59+
run: |
60+
echo "//registry.npmjs.org/:_authToken=${NPM_TOKEN}" > ~/.npmrc
61+
npm publish

0 commit comments

Comments
 (0)