-
Notifications
You must be signed in to change notification settings - Fork 11
329 lines (287 loc) · 10.8 KB
/
ci.yml
File metadata and controls
329 lines (287 loc) · 10.8 KB
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
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
name: CI
on:
push:
branches:
- main
paths-ignore:
- '**/*.md'
- '.github/workflows/markdown.yml'
- '.github/markdownlint.json'
- '.github/markdownlint.jsonc'
- '.github/workflows/nightly.yml'
- '.github/ISSUE_TEMPLATE/**'
pull_request:
branches:
- main
paths-ignore:
- '**/*.md'
- '.github/workflows/markdown.yml'
- '.github/markdownlint.json'
- '.github/markdownlint.jsonc'
- '.github/workflows/nightly.yml'
- '.github/ISSUE_TEMPLATE/**'
workflow_dispatch:
merge_group:
release:
types: [published]
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
permissions:
contents: read
jobs:
build:
strategy:
matrix:
platform: [ubuntu-24.04, windows-2022, macos-14]
include:
- platform: ubuntu-24.04
target: linux
- platform: windows-2022
target: windows
- platform: macos-14
target: darwin
runs-on: ${{ matrix.platform }}
permissions:
packages: read
name: 'Build and test (${{ matrix.target }})'
steps:
- name: Harden the runner (Audit all outbound calls)
uses: step-security/harden-runner@fa2e9d605c4eeb9fcad4c99c224cee0c6c7f3594 # v2.16.0
with:
egress-policy: audit
- run: git config --global core.autocrlf false
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
fetch-depth: 0
submodules: true
- uses: actions/setup-node@53b83947a5a98c8d113130e565377fae1a50d02f # v6.3.0
env:
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
node-version-file: package.json
registry-url: https://npm.pkg.github.com
package-manager-cache: false
- name: Set version
if: runner.os == 'Linux' && github.repository_owner == 'Open-CMSIS-Pack'
run: |
DESCRIBE=$(git describe --tags --long --match 'v[0-9]*.[0-9]*.[0-9]*' 2>/dev/null || true)
echo "DESCRIBE: ${DESCRIBE}"
if [ -z "${DESCRIBE}" ]; then
echo "No semver tag matching vX.Y.Z found."
exit 1
fi
BASE_TAG=$(printf '%s\n' "${DESCRIBE}" | grep -Eo '^v[0-9]+\.[0-9]+\.[0-9]+')
PR_QUALIFIER=$(printf '%s\n' "${DESCRIBE}" | grep -Eo '\-g[0-9a-f]+$' || true)
BRANCH_QUALIFIER=$(printf '%s\n' "${DESCRIBE}" | grep -Eo '[0-9]+\-g[0-9a-f]+$' || true)
SAFE_REF_NAME="${{ github.ref_name }}"
SAFE_REF_NAME="${SAFE_REF_NAME//[^0-9A-Za-z-]/-}"
case ${{ github.event_name }} in
release)
TAG="${{ github.event.release.tag_name }}"
npm version --allow-same-version --no-git-tag-version --new-version "${TAG#v}"
;;
pull_request)
npm version -s --allow-same-version --no-git-tag-version --new-version "${BASE_TAG#v}"
PR_VERSION="${BASE_TAG#v}-pr${{ github.event.number }}${PR_QUALIFIER}"
npm version --no-git-tag-version --new-version "${PR_VERSION}" && echo "Prerelease version set succeeded" || echo "Prerelease version set FAILED with exit code $?"
;;
*)
npm version -s --allow-same-version --no-git-tag-version --new-version "${BASE_TAG#v}"
PR_VERSION="${BASE_TAG#v}-${SAFE_REF_NAME}${BRANCH_QUALIFIER}"
npm version --no-git-tag-version --new-version "${PR_VERSION}" && echo "Prerelease version set succeeded" || echo "Prerelease version set FAILED with exit code $?"
;;
esac
VERSION="$(jq -r ".version" < package.json)"
sed -i "s/## Unreleased/## ${VERSION}/" CHANGELOG.md
echo "Updated CHANGELOG with version ${VERSION}"
- name: Remove badges
if: runner.os == 'Linux'
run: |
sed -i "/https:\/\/qlty\.sh\/gh/d" README.md
sed -i "/https:\/\/securityscorecards\.dev\/viewer/d" README.md
sed -i "/https:\/\/img.shields.io\//d" README.md
- name: Install dependencies
env:
GITHUB_TOKEN: ${{ github.token }}
run: npm ci
- name: Build on Windows or macOS
if: runner.os != 'Linux'
run: npm run build:no-lint
- name: Build on Linux
if: runner.os == 'Linux'
run: npm run build
- name: Check copyright
run: npm run copyright:check
- name: Test
run: npm run test
- name: Upload dist
if: runner.os == 'Linux'
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: dist
path: |
./README.md
./CHANGELOG.md
./package.json
./dist
retention-days: 1
- name: Commit changelog
if: false && github.event_name == 'release' && runner.os == 'Linux'
run: |
sed -i '3i ## Unreleased\n' CHANGELOG.md
git checkout main
git config user.name github-actions
git config user.email git@github.com
git add CHANGELOG.md
git commit -m "Update CHANGELOG.md after release [skip ci]"
git push
- uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
if: runner.os == 'Linux'
with:
name: test-coverage
path: ./coverage
- uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: test-report-${{ matrix.target }}
path: ./test-report.html
- name: Publish coverage report to QLTY
if: github.repository_owner == 'Open-CMSIS-Pack' && runner.os == 'Linux'
uses: qltysh/qlty-action/coverage@a19242102d17e497f437d7466aa01b528537e899 # v2.2.0
with:
token: ${{ secrets.QLTY_COVERAGE_TOKEN }}
files: coverage/lcov.info
package:
name: Package
runs-on: [ubuntu-latest]
needs: build
strategy:
fail-fast: true
matrix:
target:
- win32-x64
- win32-arm64
- linux-x64
- linux-arm64
- darwin-arm64
permissions:
packages: read
steps:
- name: Harden the runner (Audit all outbound calls)
uses: step-security/harden-runner@fa2e9d605c4eeb9fcad4c99c224cee0c6c7f3594 # v2.16.0
with:
egress-policy: audit
- name: Configure git settings
run: git config --global core.autocrlf false
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- uses: actions/setup-node@53b83947a5a98c8d113130e565377fae1a50d02f # v6.3.0
env:
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
node-version-file: package.json
registry-url: https://npm.pkg.github.com
package-manager-cache: false
- name: Download dist
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
name: dist
path: .
- name: Download tools
run: |
npm ci
npm run download-tools -- --target ${{ matrix.target }} --no-cache
- name: Create vsix package
run: |
npm run package -- --target ${{ matrix.target }}
- name: Upload package
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: vscode-cmsis-debugger-${{ matrix.target }}
path: ./*.vsix
retention-days: 1
validate:
name: Validate package (${{ matrix.target }})
runs-on: ${{ matrix.platform }}
needs: package
strategy:
fail-fast: false
matrix:
include:
- target: win32-x64
platform: windows-2022
- target: win32-arm64
platform: windows-2022
- target: linux-x64
platform: ubuntu-24.04
- target: linux-arm64
platform: ubuntu-24.04
- target: darwin-arm64
platform: macos-14
permissions:
packages: read
steps:
- name: Harden the runner (Audit all outbound calls)
uses: step-security/harden-runner@fa2e9d605c4eeb9fcad4c99c224cee0c6c7f3594 # v2.16.0
with:
egress-policy: audit
- name: Configure git settings
run: git config --global core.autocrlf false
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- uses: actions/setup-node@53b83947a5a98c8d113130e565377fae1a50d02f # v6.3.0
env:
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
node-version-file: package.json
registry-url: https://npm.pkg.github.com
package-manager-cache: false
- name: Install dependencies
run: npm ci
- name: Download vsix package
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
pattern: vscode-cmsis-debugger-${{ matrix.target }}
- name: Validate VSIX contents
shell: bash
run: |
VSIX_FILE=$(ls *.vsix)
echo "Validating VSIX: $VSIX_FILE"
npm run validate-tools -- --target ${{ matrix.target }} --vsix "$VSIX_FILE"
publish:
name: Publish release
runs-on: [ubuntu-latest]
if: github.event_name == 'release'
needs: [ package, validate ]
permissions:
contents: write # for softprops/action-gh-release to create a GitHub release
steps:
- name: Harden the runner (Audit all outbound calls)
uses: step-security/harden-runner@fa2e9d605c4eeb9fcad4c99c224cee0c6c7f3594 # v2.16.0
with:
egress-policy: audit
- name: Download packages
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
pattern: vscode-cmsis-debugger-*
- name: Download coverage report
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
pattern: test-coverage
path: test-coverage # Required for single-match patterns by actions/download-artifact >= v5
- name: Download test report
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
pattern: test-report-linux
path: test-report-linux # Required for single-match patterns by actions/download-artifact >= v5
- name: Zip test report
run: zip -r test-report.zip *
working-directory: test-report-linux
- name: Zip test coverage
run: zip -r test-coverage.zip *
working-directory: test-coverage
- name: Attach packages
uses: softprops/action-gh-release@153bb8e04406b158c6c84fc1615b65b24149a1fe # v2.6.1
with:
files: |
**/*.vsix
test-coverage/test-coverage.zip
test-report-linux/test-report.zip