Skip to content

Commit b1d6111

Browse files
authored
chore(ci): make sure to only make new releases if tests pass (#764)
1 parent 01563ec commit b1d6111

File tree

3 files changed

+96
-65
lines changed

3 files changed

+96
-65
lines changed

.github/workflows/lint.yml

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -13,33 +13,6 @@ jobs:
1313
configFile: './package.json'
1414
env:
1515
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
16-
docs:
17-
runs-on: ubuntu-latest
18-
steps:
19-
- uses: actions/checkout@v2
20-
with:
21-
fetch-depth: 0
22-
- name: Get yarn cache
23-
id: yarn-cache
24-
run: echo "::set-output name=dir::$(yarn config get cacheFolder)"
25-
- uses: actions/cache@v2
26-
with:
27-
path: ${{ steps.yarn-cache.outputs.dir }}
28-
key: ubuntu-latest-node-14.x-yarn-${{ hashFiles('**/yarn.lock') }}
29-
restore-keys: |
30-
ubuntu-latest-node-14.x-yarn-
31-
- uses: actions/[email protected]
32-
with:
33-
node-version: 14.x
34-
- name: install
35-
run: yarn
36-
- name: regenerate docs
37-
run: yarn tools:regenerate-docs
38-
- name: report regenerated docs
39-
run: |
40-
git diff --name-only \
41-
| xargs -I '{}' bash -c \
42-
'echo "::error file={}::This needs to be regenerated by running \`tools:regenerate-docs\`" && false'
4316
danger:
4417
runs-on: ubuntu-latest
4518
steps:

.github/workflows/nodejs.yml

Lines changed: 96 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,52 @@
1-
name: Unit tests
1+
name: Unit tests & Release
22

33
on:
44
push:
55
branches:
66
- master
7+
- main
78
- next
89
pull_request:
910
branches:
1011
- master
12+
- main
1113
- next
1214

1315
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+
- uses: actions/[email protected]
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+
- uses: actions/[email protected]
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+
1445
test-node:
1546
name:
1647
# prettier-ignore
1748
Test on Node.js v${{ matrix.node-version }} and eslint v${{matrix.eslint-version }}
49+
needs: prepare-yarn-cache
1850
strategy:
1951
fail-fast: false
2052
matrix:
@@ -32,9 +64,9 @@ jobs:
3264
- uses: actions/cache@v2
3365
with:
3466
path: ${{ steps.yarn-cache.outputs.dir }}
35-
key: ubuntu-latest-node-12.x-yarn-${{ hashFiles('**/yarn.lock') }}
67+
key: yarn2-${{ hashFiles('yarn.lock') }}
3668
restore-keys: |
37-
ubuntu-latest-node-12.x-yarn-
69+
yarn2-
3870
- name: Use Node.js ${{ matrix.node-version }}
3971
uses: actions/[email protected]
4072
with:
@@ -56,6 +88,7 @@ jobs:
5688
if: ${{ matrix.eslint-version >= 6 }}
5789
test-os:
5890
name: Test on ${{ matrix.os }} using Node.js LTS
91+
needs: prepare-yarn-cache
5992
strategy:
6093
fail-fast: false
6194
matrix:
@@ -70,9 +103,9 @@ jobs:
70103
- uses: actions/cache@v2
71104
with:
72105
path: ${{ steps.yarn-cache.outputs.dir }}
73-
key: ${{ runner.os }}-node-14.x-yarn-${{ hashFiles('**/yarn.lock') }}
106+
key: yarn2-${{ hashFiles('yarn.lock') }}
74107
restore-keys: |
75-
${{ runner.os }}-node-14.x-yarn-
108+
yarn2-
76109
- uses: actions/[email protected]
77110
with:
78111
node-version: 14.x
@@ -86,3 +119,61 @@ jobs:
86119
run: yarn test --coverage
87120
env:
88121
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+
- uses: actions/[email protected]
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+
- uses: actions/[email protected]
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 }}

.github/workflows/release.yml

Lines changed: 0 additions & 33 deletions
This file was deleted.

0 commit comments

Comments
 (0)