-
Notifications
You must be signed in to change notification settings - Fork 35
57 lines (54 loc) · 1.45 KB
/
npmpublish.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
name: Node.js Package
on:
release:
types: [published]
jobs:
setup:
runs-on: ubuntu-latest
outputs:
version: ${{ steps.trim.outputs.version }}
steps:
- id: trim
run: echo "::set-output name=version::${TAG:1}"
env:
TAG: ${{ github.event.release.tag_name }}
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
cache: npm
- name: Test
run: |
npm ci
xvfb-run --auto-servernum npm test
publish-npm:
needs: [test, setup]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
cache: npm
registry-url: https://registry.npmjs.org/
- name: Setup and build
run: |
npm ci
npm install -g json
json -I -f package.json -e "this.version=\"$VERSION\""
json -I -f package-lock.json -e "this.version=\"$VERSION\""
npm run build
npm pack
env:
VERSION: ${{ needs.setup.outputs.version }}
- name: Publish @next
run: npm publish --tag next
if: "github.event.release.prerelease"
env:
NODE_AUTH_TOKEN: ${{secrets.NPM_AUTH_TOKEN}}
- name: Publish @latest
run: npm publish --tag latest
if: "!github.event.release.prerelease"
env:
NODE_AUTH_TOKEN: ${{secrets.NPM_AUTH_TOKEN}}