1
- name : CI
1
+ name : CI & Release
2
+
3
+ # Workflow name based on selected inputs. Fallback to default Github naming when expression evaluates to empty string
4
+ run-name : >-
5
+ ${{
6
+ inputs.release && 'Publish to NPM' ||
7
+ ''
8
+ }}
2
9
3
10
on :
4
11
push :
5
12
branches :
6
13
- main
7
14
pull_request :
8
- branches :
9
- - main
15
+ workflow_dispatch :
16
+ inputs :
17
+ release :
18
+ description : ' Publish new release'
19
+ required : true
20
+ default : false
21
+ type : boolean
22
+
23
+ concurrency :
24
+ group : ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
25
+ cancel-in-progress : true
10
26
11
27
jobs :
12
28
build :
13
29
name : Lint and build
14
30
runs-on : ubuntu-latest
15
31
steps :
16
- - uses : actions/checkout@master
17
- - uses : actions/setup-node@master
18
- - name : Install dependencies
19
- run : npm ci
32
+ - uses : actions/checkout@755da8c3cf115ac066823e79a1e1788f8940201b # v3
33
+ - uses : actions/setup-node@8c91899e586c5b171469028077307d293428b516 # v3
34
+ with :
35
+ cache : npm
36
+ node-version : lts/*
37
+ - run : npm ci
38
+ - run : npx ls-engines
39
+ - run : npm run prepublishOnly
20
40
- name : lint, prettier --check
21
41
run : npm run lint
42
+ - name : build:lib, test:integration
43
+ run : |
44
+ npm run build:lib
45
+ npm run test:integration
46
+
22
47
test :
23
- name : Test on node ${{ matrix.node_version }} and ${{ matrix.os }}
24
- runs-on : ${{ matrix.os }}
25
48
needs : [build]
49
+ runs-on : ${{ matrix.os }}
26
50
strategy :
51
+ fail-fast : false
27
52
matrix :
28
- node_version : [12, 14, 16, 17]
29
- # @TODO figure out why windows-latest is hanging so mcuh
30
- # os: [ubuntu-latest, windows-latest, macOS-latest]
31
- os : [ubuntu-latest, macOS-latest]
32
-
53
+ # Run the testing suite on each major OS with the latest LTS release of Node.js
54
+ os : [macos-latest, ubuntu-latest, windows-latest]
55
+ node : [lts/*]
56
+ # It makes sense to also test the oldest, and latest, versions of Node.js, on ubuntu-only since it's the fastest CI runner
57
+ include :
58
+ - os : ubuntu-latest
59
+ # Test the oldest LTS release of Node that's still receiving bugfixes and security patches, versions older than that have reached End-of-Life
60
+ node : lts/-2
61
+ - os : ubuntu-latest
62
+ # Also test the previous LTS release
63
+ node : lts/-1
64
+ - os : ubuntu-latest
65
+ # Test the actively developed version that will become the latest LTS release next October
66
+ node : current
67
+ # The `build` job already runs the testing suite in ubuntu and lts/*
68
+ exclude :
69
+ - os : ubuntu-latest
70
+ # Test the oldest LTS release of Node that's still receiving bugfixes and security patches, versions older than that have reached End-of-Life
71
+ node : lts/*
33
72
steps :
34
- - uses : actions/checkout@master
35
- - name : Use Node.js ${{ matrix.node_version }}
36
- uses : actions/setup-node@master
73
+ - uses : actions/checkout@755da8c3cf115ac066823e79a1e1788f8940201b # v3
74
+ - uses : actions/setup-node@8c91899e586c5b171469028077307d293428b516 # v3
37
75
with :
38
- node-version : ${{ matrix.node_version }}
39
- - name : Install dependencies
40
- run : npm ci
76
+ cache : npm
77
+ node-version : ${{ matrix.node }}
78
+ - run : npm install
79
+ - run : npx ls-engines
41
80
- name : build:lib, test:integration
42
81
run : |
43
82
npm run build:lib
@@ -48,10 +87,12 @@ jobs:
48
87
runs-on : ubuntu-latest
49
88
needs : [build]
50
89
steps :
51
- - uses : actions/checkout@master
52
- - uses : actions/setup-node@master
53
- - name : Install dependencies
54
- run : npm ci
90
+ - uses : actions/checkout@755da8c3cf115ac066823e79a1e1788f8940201b # v3
91
+ - uses : actions/setup-node@8c91899e586c5b171469028077307d293428b516 # v3
92
+ with :
93
+ cache : npm
94
+ node-version : lts/*
95
+ - run : npm ci
55
96
- name : build:browser.js, test:browser.js
56
97
run : |
57
98
npm run build:browser.js
@@ -72,9 +113,43 @@ jobs:
72
113
ports :
73
114
- 6379:6379
74
115
steps :
75
- - uses : actions/checkout@master
76
- - uses : actions/setup-node@master
77
- - name : Install dependencies
78
- run : npm ci
116
+ - uses : actions/checkout@755da8c3cf115ac066823e79a1e1788f8940201b # v3
117
+ - uses : actions/setup-node@8c91899e586c5b171469028077307d293428b516 # v3
118
+ with :
119
+ cache : npm
120
+ node-version : lts/*
121
+ - run : npm ci
79
122
- name : test:e2e
80
123
run : npm run test:e2e -- --detectOpenHandles
124
+
125
+ release :
126
+ needs : [build, test, browser, e2e]
127
+ # only run if opt-in during workflow_dispatch
128
+ if : github.event.inputs.release == 'true'
129
+ runs-on : ubuntu-latest
130
+ steps :
131
+ - uses : actions/checkout@755da8c3cf115ac066823e79a1e1788f8940201b # v3
132
+ with :
133
+ # Need to fetch entire commit history to
134
+ # analyze every commit since last release
135
+ fetch-depth : 0
136
+ - uses : actions/setup-node@8c91899e586c5b171469028077307d293428b516 # v3
137
+ with :
138
+ node-version : lts/*
139
+ cache : npm
140
+ - run : npm ci --ignore-scripts
141
+ # Branches that will release new versions are defined in .releaserc.json
142
+ - run : npx semantic-release
143
+ # Don't allow interrupting the release step if the job is cancelled, as it can lead to an inconsistent state
144
+ # e.g. git tags were pushed but it exited before `npm publish`
145
+ if : always()
146
+ env :
147
+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
148
+ NPM_TOKEN : ${{ secrets.NPM_TOKEN }}
149
+ # Re-run semantic release with rich logs if it failed to publish for easier debugging
150
+ - run : npx semantic-release --dry-run --debug
151
+ if : failure()
152
+ env :
153
+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
154
+ NPM_TOKEN : ${{ secrets.NPM_TOKEN }}
155
+
0 commit comments