1
- name : Unit tests
1
+ name : Unit tests & Release
2
2
3
3
on :
4
4
push :
5
5
branches :
6
6
- master
7
+ - main
7
8
- next
8
9
pull_request :
9
10
branches :
10
11
- master
12
+ - main
11
13
- next
12
14
13
15
jobs :
16
+ prepare-yarn-cache :
17
+ name : Prepare yarn cache
18
+ runs-on : ubuntu-latest
19
+
20
+ steps :
21
+ - uses : actions/checkout@v2
22
+
23
+
24
+ with :
25
+ node-version : 14.x
26
+
27
+ - name : Get yarn cache
28
+ id : yarn-cache
29
+ run : echo "::set-output name=dir::$(yarn config get cacheFolder)"
30
+
31
+
32
+ with :
33
+ path : ${{ steps.yarn-cache.outputs.dir }}
34
+ key : yarn2-${{ hashFiles('yarn.lock') }}
35
+ restore-keys : |
36
+ yarn2-
37
+ - name : Validate cache
38
+ env :
39
+ # Use PnP and disable postinstall scripts as this just needs to
40
+ # populate the cache for the other jobs
41
+ YARN_NODE_LINKER : pnp
42
+ YARN_ENABLE_SCRIPTS : false
43
+ run : yarn --immutable
44
+
14
45
test-node :
15
46
name :
16
47
# prettier-ignore
17
48
Test on Node.js v${{ matrix.node-version }} and eslint v${{matrix.eslint-version }}
49
+ needs : prepare-yarn-cache
18
50
strategy :
19
51
fail-fast : false
20
52
matrix :
32
64
- uses : actions/cache@v2
33
65
with :
34
66
path : ${{ steps.yarn-cache.outputs.dir }}
35
- key : ubuntu-latest-node-12.x-yarn- ${{ hashFiles('**/ yarn.lock') }}
67
+ key : yarn2- ${{ hashFiles('yarn.lock') }}
36
68
restore-keys : |
37
- ubuntu-latest-node-12.x-yarn -
69
+ yarn2 -
38
70
- name : Use Node.js ${{ matrix.node-version }}
39
71
40
72
with :
56
88
if : ${{ matrix.eslint-version >= 6 }}
57
89
test-os :
58
90
name : Test on ${{ matrix.os }} using Node.js LTS
91
+ needs : prepare-yarn-cache
59
92
strategy :
60
93
fail-fast : false
61
94
matrix :
70
103
- uses : actions/cache@v2
71
104
with :
72
105
path : ${{ steps.yarn-cache.outputs.dir }}
73
- key : ${{ runner.os }}-node-14.x-yarn- ${{ hashFiles('**/ yarn.lock') }}
106
+ key : yarn2- ${{ hashFiles('yarn.lock') }}
74
107
restore-keys : |
75
- ${{ runner.os }}-node-14.x-yarn -
108
+ yarn2 -
76
109
77
110
with :
78
111
node-version : 14.x
@@ -86,3 +119,61 @@ jobs:
86
119
run : yarn test --coverage
87
120
env :
88
121
CI : true
122
+
123
+ docs :
124
+ if : ${{ github.event_name == 'pull_request' }}
125
+ needs : prepare-yarn-cache
126
+ runs-on : ubuntu-latest
127
+ steps :
128
+ - uses : actions/checkout@v2
129
+ with :
130
+ fetch-depth : 0
131
+ - name : Get yarn cache
132
+ id : yarn-cache
133
+ run : echo "::set-output name=dir::$(yarn config get cacheFolder)"
134
+ - uses : actions/cache@v2
135
+ with :
136
+ path : ${{ steps.yarn-cache.outputs.dir }}
137
+ key : yarn2-${{ hashFiles('yarn.lock') }}
138
+ restore-keys : |
139
+ yarn2-
140
+
141
+ with :
142
+ node-version : 14.x
143
+ - name : install
144
+ run : yarn
145
+ - name : regenerate docs
146
+ run : yarn tools:regenerate-docs
147
+ - name : report regenerated docs
148
+ run : |
149
+ git diff --name-only \
150
+ | xargs -I '{}' bash -c \
151
+ 'echo "::error file={}::This needs to be regenerated by running \`tools:regenerate-docs\`" && false'
152
+
153
+ release :
154
+ if :
155
+ # prettier-ignore
156
+ ${{ github.event_name == 'push' && github.event.ref == 'refs/heads/master' }}
157
+ name : Release new version
158
+ needs : [test-node, test-os]
159
+ runs-on : ubuntu-latest
160
+ steps :
161
+ - uses : actions/checkout@v2
162
+ - name : Get yarn cache
163
+ id : yarn-cache
164
+ run : echo "::set-output name=dir::$(yarn config get cacheFolder)"
165
+ - uses : actions/cache@v2
166
+ with :
167
+ path : ${{ steps.yarn-cache.outputs.dir }}
168
+ key : yarn2-${{ hashFiles('yarn.lock') }}
169
+ restore-keys : |
170
+ yarn2-
171
+
172
+ with :
173
+ node-version : 14.x
174
+ - name : install
175
+ run : yarn
176
+ - run : yarn semantic-release
177
+ env :
178
+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
179
+ NPM_TOKEN : ${{ secrets.NPM_TOKEN }}
0 commit comments