Skip to content

Commit d1ce78b

Browse files
committed
Add GH Action to publish NPM package based on tag
1 parent 4f17ec3 commit d1ce78b

File tree

3 files changed

+53
-0
lines changed

3 files changed

+53
-0
lines changed

.github/workflows/ci.yml

+7
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,7 @@ jobs:
168168
- name: Upload demo-dist folder
169169
uses: actions/upload-pages-artifact@v1
170170
with:
171+
name: demoDist
171172
path: ./demo-dist
172173

173174
buildRelease:
@@ -192,3 +193,9 @@ jobs:
192193

193194
- name: Build release
194195
run: npm run build:release
196+
197+
- name: Upload npm folder
198+
uses: actions/upload-pages-artifact@v1
199+
with:
200+
name: npmDist
201+
path: ./

.github/workflows/publish.yml

+44
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
name: Publish to NPM
2+
on:
3+
push:
4+
tags:
5+
- 'v[0-9]+.[0-9]+.[0-9]+*'
6+
permissions: {}
7+
jobs:
8+
ci:
9+
permissions:
10+
contents: read # for actions/checkout
11+
security-events: write # for codeql-action
12+
uses: ./.github/workflows/ci.yml
13+
14+
npm-publish:
15+
environment:
16+
name: npm-publish
17+
url: https://www.npmjs.com/package/graphql-voyager/v/${GITHUB_REF/refs\/tags\//}
18+
needs: ci
19+
permissions:
20+
contents: read # for actions/checkout
21+
runs-on: ubuntu-latest
22+
steps:
23+
- name: Checkout repo
24+
uses: actions/checkout@v3
25+
with:
26+
persist-credentials: false
27+
28+
- name: Setup Node.js
29+
uses: actions/setup-node@v3
30+
with:
31+
cache: npm
32+
node-version-file: '.node-version'
33+
# 'registry-url' is required for 'npm publish'
34+
registry-url: 'https://registry.npmjs.org'
35+
36+
- uses: actions/download-artifact@v3
37+
with:
38+
name: npmDist
39+
path: npmDist
40+
41+
- name: Publish package on NPM
42+
run: npm publish ./npmDist
43+
env:
44+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

.github/workflows/push.yml

+2
Original file line numberDiff line numberDiff line change
@@ -23,3 +23,5 @@ jobs:
2323
- name: Deploy to GitHub Pages
2424
id: deployment
2525
uses: actions/deploy-pages@v2
26+
with:
27+
artifact_name: demoDist

0 commit comments

Comments
 (0)