generated from actions/typescript-action
-
Notifications
You must be signed in to change notification settings - Fork 1
179 lines (146 loc) · 5.68 KB
/
build.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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
name: build
on:
push:
branches:
- main
- 'renovate/**'
pull_request:
env:
VERSION: v0
NODE_VERSION: 16
YARN_CACHE_KEY: v0
YARN_CACHE_FOLDER: .cache/yarn
# https://github.com/chalk/supports-color/issues/106
FORCE_COLOR: true
jobs:
prepare:
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3.6.0
- name: Cache Yarn packages
id: yarn_cache_packages
uses: actions/cache@e12d46a63a90f2fae62d114769bbf2a179198b5c # v3.3.3
with:
path: ${{ env.YARN_CACHE_FOLDER }}
key: ${{ env.YARN_CACHE_KEY }}-${{ runner.os }}-yarn_cache-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ env.YARN_CACHE_KEY }}-${{ runner.os }}-yarn_cache-
- name: Cache node_modules
uses: actions/cache@e12d46a63a90f2fae62d114769bbf2a179198b5c # v3.3.3
with:
path: node_modules
key: ${{ runner.os }}-${{ matrix.node-version }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-${{ matrix.node-version }}-yarn-
# Clear caches on cache miss, otherwise they will grow indefinitely
- name: Clear yarn cache
if: steps.yarn_cache_packages.outputs.cache-hit != 'true' && github.ref == 'refs/heads/main'
run: yarn cache clean
- run: yarn install --frozen-lockfile
test:
needs: prepare
runs-on: ubuntu-latest
# tests shouldn't need more than 15 min
timeout-minutes: 15
steps:
- name: Set up Node.js ${{ env.NODE_VERSION }}
uses: actions/setup-node@1a4442cacd436585916779262731d5b162bc6ec7 # v3.8.2
with:
node-version: ${{ env.NODE_VERSION }}
- name: Init platform
id: init
shell: bash
run: |
git config --global core.autocrlf false
git config --global core.symlinks true
git config --global user.email 'jamie.magee@gmail.com'
git config --global user.name 'Jamie Magee'
echo "Node $(node --version)"
echo "Yarn $(yarn --version)"
- uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3.6.0
- name: Cache Yarn packages
id: yarn_cache_packages
uses: actions/cache@e12d46a63a90f2fae62d114769bbf2a179198b5c # v3.3.3
with:
path: ${{ env.YARN_CACHE_FOLDER }}
key: ${{ env.YARN_CACHE_KEY }}-${{ runner.os }}-yarn_cache-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ env.YARN_CACHE_KEY }}-${{ runner.os }}-yarn_cache-
- name: Cache node_modules
uses: actions/cache@e12d46a63a90f2fae62d114769bbf2a179198b5c # v3.3.3
with:
path: node_modules
key: ${{ runner.os }}-${{ env.NODE_VERSION }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-${{ env.NODE_VERSION }}-yarn-
- run: yarn install --frozen-lockfile
- run: yarn lint
- run: yarn compile
- run: yarn jest --maxWorkers=2 --ci --coverage
- name: Upload coverage
uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32 # v3.1.3
if: always()
with:
name: coverage
path: coverage
- name: Codecov
uses: codecov/codecov-action@4fe8c5f003fae66aa5ebb77cfd3e7bfbbda0b6b0 # v3.1.5
release:
needs: [test]
runs-on: ubuntu-latest
steps:
- name: Set up Node.js ${{ env.NODE_VERSION }}
uses: actions/setup-node@1a4442cacd436585916779262731d5b162bc6ec7 # v3.8.2
with:
node-version: ${{ env.NODE_VERSION }}
- name: Init platform
id: init
shell: bash
run: |
git config --global core.autocrlf false
git config --global core.symlinks true
git config --global user.email 'jamie.magee@gmail.com'
git config --global user.name 'Jamie Magee'
yarn config set version-git-tag false
- uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3.6.0
with:
fetch-depth: 0
ref: 'release'
- name: fetch pr
if: ${{github.event_name == 'pull_request'}}
run: |
git fetch origin ${{ github.ref }}
- name: Merge
id: merge
run: |
git merge --allow-unrelated-histories --no-ff -m 'skip: merge (${{ github.sha }}) [skip release]' ${{ github.sha }}
commit=$(git rev-parse HEAD)
echo "::set-output name=commit::${commit}"
- name: Cache Yarn packages
id: yarn_cache_packages
uses: actions/cache@e12d46a63a90f2fae62d114769bbf2a179198b5c # v3.3.3
with:
path: ${{ env.YARN_CACHE_FOLDER }}
key: ${{ env.YARN_CACHE_KEY }}-${{ runner.os }}-yarn_cache-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ env.YARN_CACHE_KEY }}-${{ runner.os }}-yarn_cache-
- name: Cache node_modules
uses: actions/cache@e12d46a63a90f2fae62d114769bbf2a179198b5c # v3.3.3
with:
path: node_modules
key: ${{ runner.os }}-${{ env.NODE_VERSION }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-${{ env.NODE_VERSION }}-yarn-
- run: yarn install --frozen-lockfile
- name: Push release branch
run: git push origin release:release
if: ${{github.ref == 'refs/heads/main'}}
- name: Release
run: |
# override for semantic-release
export GITHUB_REF=refs/heads/release GITHUB_SHA=${{ steps.merge.outputs.commit }}
yarn release
if: ${{github.ref == 'refs/heads/main'}}
env:
GITHUB_TOKEN: ${{ github.token }}