-
Notifications
You must be signed in to change notification settings - Fork 4
327 lines (272 loc) · 10.2 KB
/
ci.yml
File metadata and controls
327 lines (272 loc) · 10.2 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
name: CI
on:
workflow_dispatch:
push:
branches: [ main ]
pull_request:
branches: [ main ]
paths-ignore:
- '**/*.md'
- '.github/workflows/markdown.yml'
- '.github/markdownlint.json'
- '.github/markdownlint.jsonc'
- '.github/workflows/nightly.yml'
- '.github/ISSUE_TEMPLATE/**'
release:
types: [published]
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
permissions:
contents: read
defaults:
run:
shell: bash
jobs:
build:
permissions:
contents: write
packages: read
actions: read
runs-on: [ubuntu-latest]
name: 'Build'
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
- name: Checkout repository
uses: actions/checkout@0c366fd6a839edf440554fa01a7085ccba70ac98 # v4.3.1
with:
submodules: true
fetch-depth: 0
- name: Setup Node
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
env:
GITHUB_TOKEN: ${{ github.token }}
NODE_OPTIONS: --max-old-space-size=8192
run: npm ci
- name: Check copyright
run: npm run copyright:check
- name: Check links for insecure http URLs (only changed files)
run: npm run check:links -- -m false
- name: Lint check
run: npm run lint
- name: Run build
run: npm run build
- name: Update current version
if: github.event_name != 'release'
run: |
# Increment patch version by 1 (e.g. 1.64.1 -> 1.64.2)
BASE_VERSION=$(node -p "require('./package.json').version.split('-')[0]")
IFS='.' read -r MAJOR MINOR PATCH <<< "$BASE_VERSION"
if [ -z "$MAJOR" ] || [ -z "$MINOR" ] || [ -z "$PATCH" ]; then
echo "Invalid semver: $BASE_VERSION"
exit 1
fi
if ! [[ "$MAJOR" =~ ^[0-9]+$ && "$MINOR" =~ ^[0-9]+$ && "$PATCH" =~ ^[0-9]+$ ]]; then
echo "Invalid semver components (non-numeric): $BASE_VERSION (MAJOR=$MAJOR, MINOR=$MINOR, PATCH=$PATCH)"
exit 1
fi
NEXT_PATCH_VERSION="${MAJOR}.${MINOR}.$((PATCH + 1))"
# Get commit count: since last tag if exists, otherwise total commits
LAST_TAG=$(git describe --tags --abbrev=0 2>/dev/null || echo "")
if [ -n "$LAST_TAG" ]; then
COMMIT_COUNT=$(git rev-list --count HEAD ^${LAST_TAG})
else
COMMIT_COUNT=$(git rev-list --count HEAD)
fi
# Get short commit SHA
SHORT_SHA=$(git rev-parse --short HEAD)
# Create PR version: 1.64.2-12-abc1234
PR_VERSION="${NEXT_PATCH_VERSION}-${COMMIT_COUNT}-${SHORT_SHA}"
echo "Setting version to ${PR_VERSION}"
# Update package.json
npm version "${PR_VERSION}" --no-git-tag-version
- name: Remove badges
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: Ensure download-tools.sh is executable
working-directory: .github/workflows
run: chmod +x ./download-tools.sh
- name: Download dependencies (win32-x64)
working-directory: .github/workflows
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: ./download-tools.sh win32-x64
- name: Package win32-x64
run: npm run package -- --target win32-x64
- name: Download dependencies (win32-arm64)
working-directory: .github/workflows
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: ./download-tools.sh win32-arm64
- name: Package win32-arm64
run: npm run package -- --target win32-arm64
- name: Download dependencies (linux-x64)
working-directory: .github/workflows
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: ./download-tools.sh linux-x64
- name: Package linux-x64
run: npm run package -- --target linux-x64
- name: Download dependencies (linux-arm64)
working-directory: .github/workflows
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: ./download-tools.sh linux-arm64
- name: Package linux-arm64
run: npm run package -- --target linux-arm64
- name: Download dependencies (darwin-x64)
working-directory: .github/workflows
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: ./download-tools.sh darwin-x64
- name: Package darwin-x64
run: npm run package -- --target darwin-x64
- name: Download dependencies (darwin-arm64)
working-directory: .github/workflows
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: ./download-tools.sh darwin-arm64
- name: Package darwin-arm64
run: npm run package -- --target darwin-arm64
- name: Upload win32-x64 VSIX package
uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7.0.0
with:
name: vscode-cmsis-solution-win32-x64
path: ./*win32-x64*.vsix
retention-days: 1
- name: Upload win32-arm64 VSIX package
uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7.0.0
with:
name: vscode-cmsis-solution-win32-arm64
path: ./*win32-arm64*.vsix
retention-days: 1
- name: Upload linux-x64 VSIX package
uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7.0.0
with:
name: vscode-cmsis-solution-linux-x64
path: ./*linux-x64*.vsix
retention-days: 1
- name: Upload linux-arm64 VSIX package
uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7.0.0
with:
name: vscode-cmsis-solution-linux-arm64
path: ./*linux-arm64*.vsix
retention-days: 1
- name: Upload darwin-x64 VSIX package
uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7.0.0
with:
name: vscode-cmsis-solution-darwin-x64
path: ./*darwin-x64*.vsix
retention-days: 1
- name: Upload darwin-arm64 VSIX package
uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7.0.0
with:
name: vscode-cmsis-solution-darwin-arm64
path: ./*darwin-arm64*.vsix
retention-days: 1
- name: Create version bump patch
run: git diff > new-version.patch
- name: Store version bump patch
uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7.0.0
with:
name: new-version-patch
path: ./new-version.patch
if-no-files-found: error
test:
name: 'Test (${{ matrix.target }})'
runs-on: ${{ matrix.platform }}
needs: [ build ]
permissions:
contents: write
packages: read
actions: read
strategy:
fail-fast: false
matrix:
include:
- target: win32-x64
platform: windows-2022
- target: linux-x64
platform: ubuntu-24.04
- target: darwin-arm64
platform: macos-14
- target: darwin-x64
platform: macos-15-intel
steps:
- name: Harden the runner (Audit all outbound calls)
uses: step-security/harden-runner@fa2e9d605c4eeb9fcad4c99c224cee0c6c7f3594 # v2.16.0
with:
egress-policy: audit
- name: Checkout repository
uses: actions/checkout@c2d88d3ecc89a9ef08eebf45d9637801dcee7eb5 # v4.3.1
with:
submodules: true
fetch-depth: 0
- name: Setup Node
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
env:
GITHUB_TOKEN: ${{ github.token }}
NODE_OPTIONS: --max-old-space-size=8192
run: npm ci
- name: Run Test
run: npm run test
- uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7.0.0
if: ${{ matrix.target == 'linux-x64' }}
with:
name: unit-test-coverage
path: ./coverage
- name: Publish coverage report to QLTY
if: github.repository_owner == 'Open-CMSIS-Pack' && matrix.target == 'linux-x64'
uses: qltysh/qlty-action/coverage@a19242102d17e497f437d7466aa01b528537e899 # v2.2.0
with:
token: ${{ secrets.QLTY_COVERAGE_TOKEN }}
files: coverage/lcov.info
publish:
name: Publish release
runs-on: [ubuntu-latest]
if: github.event_name == 'release'
needs: [ build, test ]
permissions:
contents: write
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-solution-*
- name: Download coverage report
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
pattern: unit-test-coverage
path: 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