-
Notifications
You must be signed in to change notification settings - Fork 5
172 lines (138 loc) · 5.05 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
name: build
on:
push:
branches:
- main
- 'renovate/**'
pull_request:
concurrency:
group: ${{ github.workflow }}-${{ github.event.number || github.ref }}
cancel-in-progress: true
env:
GIT_EMAIL: bot+ruby-semver@renovateapp.com
NODE_VERSION: 18 # needs to be in sync with other v18 below
DEFAULT_BRANCH: ${{ github.event.repository.default_branch }}
DRY_RUN: true
jobs:
test:
name: ${{ matrix.node-version == 18 && format('test ({0})', matrix.os) || format('test ({0}, node-{1})', matrix.os, matrix.node-version) }}
runs-on: ${{ matrix.os }}
# tests shouldn't need more time
timeout-minutes: 30
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
node-version: [18, 20]
env:
coverage: ${{ matrix.os == 'ubuntu-latest' && matrix.node-version == 18 }}
NODE_VERSION: ${{ matrix.node-version }}
permissions:
actions: write
contents: read
steps:
- uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab # v3.5.2
with:
fetch-depth: 2
- name: Set up Node.js ${{ env.NODE_VERSION }}
uses: actions/setup-node@64ed1c7eab4cce3362f8c340dee64e5eaeef8f7c # v3.6.0
with:
node-version: ${{ env.NODE_VERSION }}
cache: yarn
- name: Init platform
shell: bash
run: |
git config --global core.autocrlf false
git config --global core.symlinks true
git config --global user.email ${GIT_EMAIL}
git config --global user.name 'Renovate Bot'
echo "Node $(node --version)"
echo "Yarn $(yarn --version)"
- name: Installing dependencies
run: yarn install --frozen-lockfile --ignore-engines # semantic release will fail to install otherwise
- name: Build
run: yarn build
- name: Unit tests
run: yarn jest --maxWorkers=2 --ci --coverage ${{ env.coverage }} --logHeapUsage
- name: Upload coverage
uses: actions/upload-artifact@0b7f8abb1508181956e8e162db84b466c27e18ce # v3.1.2
if: always() && env.coverage == 'true'
with:
name: coverage
path: coverage
- name: Codecov
uses: codecov/codecov-action@894ff025c7b54547a9a2a1e9f228beae737ad3c2 # v3.1.3
if: env.coverage == 'true'
lint:
runs-on: ubuntu-latest
# lint shouldn't need more than 10 min
timeout-minutes: 15
permissions:
contents: read
steps:
- uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab # v3.5.2
with:
fetch-depth: 2
- name: Set up Node.js ${{ env.NODE_VERSION }}
uses: actions/setup-node@64ed1c7eab4cce3362f8c340dee64e5eaeef8f7c # v3.6.0
with:
node-version: ${{ env.NODE_VERSION }}
cache: yarn
- name: Init platform
run: |
git config --global core.autocrlf false
git config --global core.symlinks true
git config --global user.email ${GIT_EMAIL}
git config --global user.name 'Renovate Bot'
echo "Node $(node --version)"
echo "Yarn $(yarn --version)"
- name: Installing dependencies
run: yarn install --frozen-lockfile
- name: Lint
run: |
yarn eslint -f gha
yarn markdown-lint
yarn prettier
- name: Type check
run: yarn type-check
release:
needs: [lint, test]
runs-on: ubuntu-latest
# release shouldn't need more than 5 min
timeout-minutes: 15
permissions:
contents: write
id-token: write
steps:
# full checkout for semantic-release
- uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab # v3.5.2
with:
fetch-depth: 0
- name: Set up Node.js ${{ env.NODE_VERSION }}
uses: actions/setup-node@64ed1c7eab4cce3362f8c340dee64e5eaeef8f7c # v3.6.0
with:
node-version: ${{ env.NODE_VERSION }}
cache: yarn
- name: Init platform
run: |
git config --global core.autocrlf false
git config --global core.symlinks true
git config --global user.email ${GIT_EMAIL}
git config --global user.name 'Renovate Bot'
yarn config set version-git-tag false
- name: Check dry run
run: |
if [[ "${{github.event_name}}" == "workflow_dispatch" && "${{ github.event.inputs.dryRun }}" != "true" ]]; then
echo "DRY_RUN=false" >> $GITHUB_ENV
elif [[ "${{github.ref}}" == "refs/heads/${{env.DEFAULT_BRANCH}}" ]]; then
echo "DRY_RUN=false" >> $GITHUB_ENV
elif [[ "${{github.ref}}" =~ ^refs/heads/v[0-9]+(\.[0-9]+)?$ ]]; then
echo "DRY_RUN=false" >> $GITHUB_ENV
fi
- name: Installing dependencies
run: yarn install --frozen-lockfile
- name: semantic-release
run: |
yarn semantic-release --dry-run ${{github.ref != 'refs/heads/main'}} --ci ${{github.ref == 'refs/heads/main'}}
env:
GITHUB_TOKEN: ${{ github.token }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}