-
Notifications
You must be signed in to change notification settings - Fork 66
84 lines (70 loc) · 1.99 KB
/
test_and_release.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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
name: Test
on:
workflow_dispatch:
release:
types:
- published
pull_request:
branches:
- master
- v[0-9]+.[0-9]+-dev
jobs:
test:
name: Run Dashd RPC tests
runs-on: ubuntu-20.04
timeout-minutes: 10
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
with:
node-version: '16'
- name: Enable NPM cache
uses: actions/cache@v2
with:
path: '~/.npm'
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-
- name: Install NPM dependencies
run: npm ci
- name: Run tests
run: npm run test
- name: Run coverage tests
run: npm run coverage
release:
name: Release NPM package
runs-on: ubuntu-20.04
needs: test
if: ${{ github.event_name == 'release' }}
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
with:
node-version: '16'
- name: Check package version matches tag
uses: geritol/match-tag-to-package-version@0.1.0
env:
TAG_PREFIX: refs/tags/v
- name: Enable NPM cache
uses: actions/cache@v2
with:
path: '~/.npm'
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-
- name: Install NPM dependencies
run: npm ci
- name: Set release tag
uses: actions/github-script@v3
id: tag
with:
result-encoding: string
script: |
const tag = context.payload.release.tag_name;
const [, major, minor] = tag.match(/^v([0-9]+)\.([0-9]+)/);
return (tag.includes('dev') ? `${major}.${minor}-dev` : 'latest');
- name: Publish NPM package
uses: JS-DevTools/npm-publish@v1
with:
token: ${{ secrets.NPM_TOKEN }}
tag: ${{ steps.tag.outputs.result }}