-
Notifications
You must be signed in to change notification settings - Fork 125
106 lines (99 loc) · 3.05 KB
/
ci.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
100
101
102
103
104
105
106
name: CI & Release
# Workflow name based on selected inputs. Fallback to default Github naming when expression evaluates to empty string
run-name: >-
${{
inputs.release && 'Publish to NPM' ||
''
}}
on:
push:
branches:
- 7.x
pull_request:
branches:
- 7.x
workflow_dispatch:
inputs:
release:
description: 'Publish new release'
required: true
default: false
type: boolean
permissions:
contents: read # for checkout
jobs:
build:
name: Lint and build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
- uses: actions/setup-node@master
- name: Install dependencies
run: npm ci
- name: lint, prettier --check
run: npm run lint
test:
name: Test on node ${{ matrix.node_version }} and ${{ matrix.os }}
runs-on: ${{ matrix.os }}
needs: [build]
strategy:
matrix:
node_version: [12, 14, 16, 17]
# @TODO figure out why windows-latest is hanging so mcuh
#os: [ubuntu-latest, windows-latest, macOS-latest]
os: [ubuntu-latest, macOS-latest]
steps:
- uses: actions/checkout@master
- name: Use Node.js ${{ matrix.node_version }}
uses: actions/setup-node@master
with:
node-version: ${{ matrix.node_version }}
- name: Install dependencies
run: npm ci
- name: build:lib, test:integration
run: |
npm run build:lib
npm run test:integration
browser:
name: Test browser.js
runs-on: ubuntu-latest
needs: [build]
steps:
- uses: actions/checkout@master
- uses: actions/setup-node@master
- name: Install dependencies
run: npm ci
- name: build:browser.js, test:browser.js
run: |
npm run build:browser.js
npm run test:browser.js
release:
permissions:
contents: write # to be able to publish a GitHub release
issues: write # to be able to comment on released issues
pull-requests: write # to be able to comment on released pull requests
id-token: write # to enable use of OIDC for npm provenance
needs: [build, test, browser]
# only run if opt-in during workflow_dispatch
if: github.event.inputs.release == 'true'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
# Need to fetch entire commit history to
# analyze every commit since last release
fetch-depth: 0
- uses: actions/setup-node@v3
with:
node-version: lts/*
cache: npm
- run: npm ci --ignore-scripts
- run: npm audit signatures
# Branches that will release new versions are defined in .releaserc.json
- run: npx semantic-release
# Don't allow interrupting the release step if the job is cancelled, as it can lead to an inconsistent state
# e.g. git tags were pushed but it exited before `npm publish`
if: always()
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}