-
Notifications
You must be signed in to change notification settings - Fork 8
472 lines (398 loc) · 16.1 KB
/
release.yml
File metadata and controls
472 lines (398 loc) · 16.1 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
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
name: Build & Release
on:
push:
tags:
- 'v*'
workflow_dispatch:
inputs:
version:
description: 'Version to inject (e.g. 1.0.0). Leave empty for 0.1-dev.'
required: false
type: string
permissions:
contents: write
jobs:
# ---------------------------------------------------------------------------
# Compute the version string once, share it across jobs
# ---------------------------------------------------------------------------
prepare:
runs-on: ubuntu-latest
outputs:
version: ${{ steps.version.outputs.version }}
steps:
- name: Determine version
id: version
run: |
if [[ "${{ github.ref_type }}" == "tag" ]]; then
VERSION="${{ github.ref_name }}"
VERSION="${VERSION#v}"
elif [[ -n "${{ inputs.version }}" ]]; then
VERSION="${{ inputs.version }}"
else
VERSION="0.1-dev"
fi
echo "version=${VERSION}" >> "$GITHUB_OUTPUT"
echo "### Version: \`${VERSION}\`" >> "$GITHUB_STEP_SUMMARY"
# ---------------------------------------------------------------------------
# Linux x64
# ---------------------------------------------------------------------------
build-linux-x64:
needs: prepare
runs-on: ubuntu-22.04
env:
VERSION: ${{ needs.prepare.outputs.version }}
steps:
- uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '22'
cache: 'npm'
- name: Install dependencies
run: npm ci
- name: Inject version
run: npm version "$VERSION" --no-git-tag-version --allow-same-version
- name: Bundle
run: npm run build:bundle
- name: Build standalone binary
run: npx pkg dist/strucpp-bundle.cjs --no-bytecode --public-packages "*" --public --target node22-linux-x64 --output dist/bin/strucpp --compress GZip
- name: Smoke-test binary
env:
STRUCPP_EXPECTED_VERSION: ${{ needs.prepare.outputs.version }}
run: |
file dist/bin/strucpp
node scripts/smoke-test.mjs dist/bin/strucpp
- name: Package
run: |
mkdir -p staging/strucpp/runtime/include staging/strucpp/runtime/repl staging/strucpp/runtime/test staging/strucpp/libs
cp dist/bin/strucpp staging/strucpp/
cp src/runtime/include/*.hpp staging/strucpp/runtime/include/
cp src/runtime/repl/* staging/strucpp/runtime/repl/
cp src/runtime/test/* staging/strucpp/runtime/test/
cp libs/*.stlib staging/strucpp/libs/
cp LICENSE COPYING COPYING.RUNTIME staging/strucpp/ 2>/dev/null || true
tar -czf strucpp-linux-x64.tar.gz -C staging strucpp
- uses: actions/upload-artifact@v4
with:
name: strucpp-linux-x64
path: strucpp-linux-x64.tar.gz
# ---------------------------------------------------------------------------
# Linux ARM64
# ---------------------------------------------------------------------------
build-linux-arm64:
needs: prepare
runs-on: ubuntu-24.04-arm
env:
VERSION: ${{ needs.prepare.outputs.version }}
steps:
- uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '22'
cache: 'npm'
- name: Install dependencies
run: npm ci
- name: Inject version
run: npm version "$VERSION" --no-git-tag-version --allow-same-version
- name: Bundle
run: npm run build:bundle
- name: Build standalone binary
run: npx pkg dist/strucpp-bundle.cjs --no-bytecode --public-packages "*" --public --target node22-linux-arm64 --output dist/bin/strucpp --compress GZip
- name: Smoke-test binary
env:
STRUCPP_EXPECTED_VERSION: ${{ needs.prepare.outputs.version }}
run: |
file dist/bin/strucpp
node scripts/smoke-test.mjs dist/bin/strucpp
- name: Package
run: |
mkdir -p staging/strucpp/runtime/include staging/strucpp/runtime/repl staging/strucpp/runtime/test staging/strucpp/libs
cp dist/bin/strucpp staging/strucpp/
cp src/runtime/include/*.hpp staging/strucpp/runtime/include/
cp src/runtime/repl/* staging/strucpp/runtime/repl/
cp src/runtime/test/* staging/strucpp/runtime/test/
cp libs/*.stlib staging/strucpp/libs/
cp LICENSE COPYING COPYING.RUNTIME staging/strucpp/ 2>/dev/null || true
tar -czf strucpp-linux-arm64.tar.gz -C staging strucpp
- uses: actions/upload-artifact@v4
with:
name: strucpp-linux-arm64
path: strucpp-linux-arm64.tar.gz
# ---------------------------------------------------------------------------
# macOS x64 (Intel) — cross-compiled via pkg on ARM runner
# ---------------------------------------------------------------------------
build-darwin-x64:
needs: prepare
runs-on: macos-15
env:
VERSION: ${{ needs.prepare.outputs.version }}
steps:
- uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '22'
cache: 'npm'
- name: Install dependencies
run: npm ci
- name: Inject version
run: npm version "$VERSION" --no-git-tag-version --allow-same-version
- name: Bundle
run: npm run build:bundle
- name: Build standalone binary
run: npx pkg dist/strucpp-bundle.cjs --no-bytecode --public-packages "*" --public --target node22-macos-x64 --output dist/bin/strucpp --compress GZip
- name: Smoke-test binary
env:
STRUCPP_EXPECTED_VERSION: ${{ needs.prepare.outputs.version }}
run: |
file dist/bin/strucpp
node scripts/smoke-test.mjs dist/bin/strucpp arch -x86_64
- name: Package
run: |
mkdir -p staging/strucpp/runtime/include staging/strucpp/runtime/repl staging/strucpp/runtime/test staging/strucpp/libs
cp dist/bin/strucpp staging/strucpp/
cp src/runtime/include/*.hpp staging/strucpp/runtime/include/
cp src/runtime/repl/* staging/strucpp/runtime/repl/
cp src/runtime/test/* staging/strucpp/runtime/test/
cp libs/*.stlib staging/strucpp/libs/
cp LICENSE COPYING COPYING.RUNTIME staging/strucpp/ 2>/dev/null || true
cd staging && zip -r ../strucpp-darwin-x64.zip strucpp
- uses: actions/upload-artifact@v4
with:
name: strucpp-darwin-x64
path: strucpp-darwin-x64.zip
# ---------------------------------------------------------------------------
# macOS ARM64 (Apple Silicon)
# ---------------------------------------------------------------------------
build-darwin-arm64:
needs: prepare
runs-on: macos-15
env:
VERSION: ${{ needs.prepare.outputs.version }}
steps:
- uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '22'
cache: 'npm'
- name: Install dependencies
run: npm ci
- name: Inject version
run: npm version "$VERSION" --no-git-tag-version --allow-same-version
- name: Bundle
run: npm run build:bundle
- name: Build standalone binary
run: npx pkg dist/strucpp-bundle.cjs --no-bytecode --public-packages "*" --public --target node22-macos-arm64 --output dist/bin/strucpp --compress GZip
- name: Smoke-test binary
env:
STRUCPP_EXPECTED_VERSION: ${{ needs.prepare.outputs.version }}
run: |
file dist/bin/strucpp
node scripts/smoke-test.mjs dist/bin/strucpp
- name: Package
run: |
mkdir -p staging/strucpp/runtime/include staging/strucpp/runtime/repl staging/strucpp/runtime/test staging/strucpp/libs
cp dist/bin/strucpp staging/strucpp/
cp src/runtime/include/*.hpp staging/strucpp/runtime/include/
cp src/runtime/repl/* staging/strucpp/runtime/repl/
cp src/runtime/test/* staging/strucpp/runtime/test/
cp libs/*.stlib staging/strucpp/libs/
cp LICENSE COPYING COPYING.RUNTIME staging/strucpp/ 2>/dev/null || true
cd staging && zip -r ../strucpp-darwin-arm64.zip strucpp
- uses: actions/upload-artifact@v4
with:
name: strucpp-darwin-arm64
path: strucpp-darwin-arm64.zip
# ---------------------------------------------------------------------------
# Windows x64 (cross-compiled via pkg on Linux)
# ---------------------------------------------------------------------------
build-windows-x64:
needs: prepare
runs-on: ubuntu-22.04
env:
VERSION: ${{ needs.prepare.outputs.version }}
steps:
- uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '22'
cache: 'npm'
- name: Install dependencies
run: npm ci
- name: Inject version
run: npm version "$VERSION" --no-git-tag-version --allow-same-version
- name: Bundle
run: npm run build:bundle
- name: Build standalone binary
run: npx pkg dist/strucpp-bundle.cjs --no-bytecode --public-packages "*" --public --target node22-win-x64 --output dist/bin/strucpp.exe --compress GZip
- name: Verify binary
# Cross-built on Linux — cannot execute here. The produced .exe is
# smoke-tested natively in the `smoke-windows` job below.
run: file dist/bin/strucpp.exe
- name: Package
run: |
mkdir -p staging/strucpp/runtime/include staging/strucpp/runtime/repl staging/strucpp/runtime/test staging/strucpp/libs
cp dist/bin/strucpp.exe staging/strucpp/
cp src/runtime/include/*.hpp staging/strucpp/runtime/include/
cp src/runtime/repl/* staging/strucpp/runtime/repl/
cp src/runtime/test/* staging/strucpp/runtime/test/
cp libs/*.stlib staging/strucpp/libs/
cp LICENSE COPYING COPYING.RUNTIME staging/strucpp/ 2>/dev/null || true
cd staging && zip -r ../strucpp-win32-x64.zip strucpp
- uses: actions/upload-artifact@v4
with:
name: strucpp-win32-x64
path: strucpp-win32-x64.zip
# ---------------------------------------------------------------------------
# Windows smoke test — the .exe is cross-built on Linux and can't run there,
# so execute it natively on a Windows runner and fail the release if it can't
# start (guards against the issue #132 class of bug on Windows).
# ---------------------------------------------------------------------------
smoke-windows:
needs: [prepare, build-windows-x64]
runs-on: windows-latest
steps:
- uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '22'
- uses: actions/download-artifact@v4
with:
name: strucpp-win32-x64
- name: Unpack binary
shell: bash
run: unzip -o strucpp-win32-x64.zip -d unpacked
- name: Smoke-test binary
shell: bash
env:
# Job runs on a fresh runner with a clean source checkout — the
# `npm version` bump done by `build-windows-x64` only lived in
# that build job's filesystem. Pass the canonical version from
# `prepare.outputs.version` so the smoke-test asserts against
# what we ASKED the pipeline to build, not whatever happens to
# be committed in `package.json` at the tagged commit.
STRUCPP_EXPECTED_VERSION: ${{ needs.prepare.outputs.version }}
run: node scripts/smoke-test.mjs unpacked/strucpp/strucpp.exe
# ---------------------------------------------------------------------------
# npm tarball (platform-independent — used by OpenPLC Editor)
# ---------------------------------------------------------------------------
build-npm:
needs: prepare
runs-on: ubuntu-latest
env:
VERSION: ${{ needs.prepare.outputs.version }}
steps:
- uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '22'
cache: 'npm'
- name: Install dependencies
run: npm ci
- name: Install vscode-extension dependencies
# Required so the browser-server bundle can build during prepack.
run: npm ci
working-directory: vscode-extension
- name: Inject version
run: npm version "$VERSION" --no-git-tag-version --allow-same-version
- name: Build
run: npm run build
- name: Create npm tarball
# `npm pack` triggers `prepack`, which builds the browser-server
# bundle into `dist/browser-server.js` so it ships in the tarball
# alongside the Node compiler output.
run: npm pack
- uses: actions/upload-artifact@v4
with:
name: strucpp-npm
path: strucpp-*.tgz
# ---------------------------------------------------------------------------
# VSCode Extension (.vsix)
# ---------------------------------------------------------------------------
build-vsix:
needs: prepare
runs-on: ubuntu-latest
env:
VERSION: ${{ needs.prepare.outputs.version }}
steps:
- uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
cache: 'npm'
- name: Install compiler dependencies and build
run: npm ci && npm run build
- name: Install extension dependencies
run: cd vscode-extension && npm ci
- name: Inject version
run: cd vscode-extension && npm version "$VERSION" --no-git-tag-version --allow-same-version
- name: Package extension
run: cd vscode-extension && npx @vscode/vsce package --no-dependencies
- uses: actions/upload-artifact@v4
with:
name: strucpp-vsix
path: vscode-extension/*.vsix
# ---------------------------------------------------------------------------
# Create GitHub Release (only on tag push)
# ---------------------------------------------------------------------------
create-release:
if: startsWith(github.ref, 'refs/tags/')
needs:
- prepare
- build-linux-x64
- build-linux-arm64
- build-darwin-x64
- build-darwin-arm64
- build-windows-x64
- smoke-windows
- build-npm
- build-vsix
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/download-artifact@v4
with:
path: artifacts
- name: Prepare release assets
run: |
mkdir -p release
cp artifacts/strucpp-linux-x64/strucpp-linux-x64.tar.gz release/
cp artifacts/strucpp-linux-arm64/strucpp-linux-arm64.tar.gz release/
cp artifacts/strucpp-darwin-x64/strucpp-darwin-x64.zip release/
cp artifacts/strucpp-darwin-arm64/strucpp-darwin-arm64.zip release/
cp artifacts/strucpp-win32-x64/strucpp-win32-x64.zip release/
# Windows ARM64 runs x64 binaries via emulation
cp release/strucpp-win32-x64.zip release/strucpp-win32-arm64.zip
# npm tarball (platform-independent, used by OpenPLC Editor)
cp artifacts/strucpp-npm/strucpp-*.tgz release/
cp artifacts/strucpp-vsix/*.vsix release/
ls -lh release/
- name: Detect prerelease
id: prerelease
run: |
TAG="${{ github.ref_name }}"
if [[ "$TAG" =~ (alpha|beta|rc) ]]; then
echo "flag=--prerelease" >> "$GITHUB_OUTPUT"
else
echo "flag=" >> "$GITHUB_OUTPUT"
fi
- name: Create release
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
gh release create "${{ github.ref_name }}" \
--title "${{ github.ref_name }}" \
--generate-notes \
${{ steps.prerelease.outputs.flag }} \
release/*
- name: Publish extension to VSCode Marketplace
if: env.VSCE_PAT != ''
env:
VSCE_PAT: ${{ secrets.VSCE_PAT }}
run: npx @vscode/vsce publish --packagePath release/*.vsix --pat "$VSCE_PAT"