-
-
Notifications
You must be signed in to change notification settings - Fork 18
99 lines (84 loc) · 2.31 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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
name: Run tests and publish
on:
push:
branches:
- master
- main
- beta
# - feature/*
paths-ignore:
- 'docs/**'
- 'examples/**'
- 'README.md'
pull_request:
paths-ignore:
- 'docs/**'
- 'README.md'
jobs:
test:
name: 'Build and test on node v${{ matrix.node }}'
runs-on: ubuntu-latest
strategy:
matrix:
node: [16, 18]
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node }}
- name: Install dependencies
run: npm ci
- name: Build library
run: npm run build
- name: Run code linting
run: npm run lint
- name: Run tests
if: ${{ always() }}
run: npm run test:jest
- name: Send data to Coveralls
if: always() && matrix.node == 16
uses: coverallsapp/github-action@master
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
npm-release:
name: 'Release to npm'
runs-on: ubuntu-latest
needs: [test]
if: github.event_name != 'pull_request'
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Use node 18
uses: actions/setup-node@v4
with:
node-version: 18
- name: Install dependencies
run: npm ci
- name: Build library
run: npm run build
- uses: svrooij/secret-gate-action@v1
id: mygate
with:
inputsToCheck: 'NPM_TOKEN'
env:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
- name: Semantic Release
uses: cycjimmy/semantic-release-action@v4
if: steps.mygate.outputs.inputsChecked == 'true'
id: semantic
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
- name: Setup node for Github Registry
if: steps.semantic.outputs.new_release_published == 'true'
uses: actions/setup-node@v4
with:
node-version: 18
registry-url: 'https://npm.pkg.github.com'
scope: 'svrooij'
- name: Publish To GitHub Package Registry
if: steps.semantic.outputs.new_release_published == 'true'
run: |
npm publish
env:
NODE_AUTH_TOKEN: ${{secrets.GITHUB_TOKEN}}