-
Notifications
You must be signed in to change notification settings - Fork 4
1336 lines (1216 loc) · 52.4 KB
/
Copy pathpackage.yml
File metadata and controls
1336 lines (1216 loc) · 52.4 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
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
name: package
on:
workflow_dispatch:
inputs:
npm_version:
description: npm version to backfill after a full package build (must match CMakeLists.txt)
required: false
type: string
push:
tags:
- "v*"
permissions:
contents: write
concurrency:
group: package-${{ github.ref }}
cancel-in-progress: ${{ !startsWith(github.ref, 'refs/tags/v') }}
jobs:
build-web-ui:
name: web-dist
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Check bundled models.dev freshness for release
if: startsWith(github.ref, 'refs/tags/v')
shell: bash
run: |
python3 - <<'PY'
import datetime as dt
import json
from pathlib import Path
manifest_path = Path("assets/models_dev/MANIFEST.json")
try:
manifest = json.loads(manifest_path.read_text(encoding="utf-8"))
generated_at = dt.datetime.fromisoformat(
manifest["generated_at"].replace("Z", "+00:00")
)
except (OSError, KeyError, TypeError, ValueError, json.JSONDecodeError) as exc:
raise SystemExit(f"Invalid {manifest_path}: {exc}")
if generated_at.tzinfo is None:
raise SystemExit(f"{manifest_path}: generated_at must include a timezone")
now = dt.datetime.now(dt.timezone.utc)
age = now - generated_at.astimezone(dt.timezone.utc)
if age < -dt.timedelta(minutes=5):
raise SystemExit(f"{manifest_path}: generated_at is in the future")
if age > dt.timedelta(days=30):
raise SystemExit(
f"Bundled models.dev registry is {age.days} days old; "
"run scripts/sync_models_dev before creating a release tag"
)
print(f"Bundled models.dev registry age: {age.days} days")
PY
- name: Install pnpm
uses: pnpm/action-setup@v4
with:
version: '10.32.1'
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
cache: pnpm
cache-dependency-path: web/pnpm-lock.yaml
- name: Build web UI
shell: bash
run: |
cd web
pnpm install --frozen-lockfile
pnpm build
- name: Upload web UI
uses: actions/upload-artifact@v4
with:
name: web-dist
path: web/dist
if-no-files-found: error
build-and-package:
name: ${{ matrix.id }}
needs: build-web-ui
runs-on: ${{ matrix.os }}
env:
VCPKG_BINARY_SOURCES: clear;default,readwrite
strategy:
fail-fast: false
matrix:
include:
- id: linux-x64
os: ubuntu-22.04
triplet: x64-linux
executable: acecode
archive_extension: tar.gz
build_desktop: true
cmake_extra_args: -DACECODE_BUILD_DESKTOP=ON
- id: linux-arm64
os: ubuntu-22.04-arm
triplet: arm64-linux
executable: acecode
archive_extension: tar.gz
build_desktop: true
cmake_extra_args: -DACECODE_BUILD_DESKTOP=ON
- id: linux-armv7
os: ubuntu-22.04
triplet: arm-linux
executable: acecode
archive_extension: tar.gz
build_desktop: false
cmake_extra_args: >-
-DACECODE_BUILD_DESKTOP=OFF
-DVCPKG_CHAINLOAD_TOOLCHAIN_FILE="$VCPKG_ROOT/scripts/toolchains/linux.cmake"
-DVCPKG_TARGET_ARCHITECTURE=arm
- id: windows-x64
os: windows-2022
triplet: x64-windows-static
executable: acecode.exe
archive_extension: zip
msvc_arch: amd64
build_desktop: true
cmake_extra_args: -DACECODE_BUILD_DESKTOP=ON
- id: windows-arm64
os: windows-2022
triplet: arm64-windows-static
executable: acecode.exe
archive_extension: zip
msvc_arch: amd64_arm64
build_desktop: true
cmake_extra_args: -DACECODE_BUILD_DESKTOP=ON
- id: macos-x64
os: macos-15
triplet: x64-osx
executable: acecode
archive_extension: tar.gz
build_desktop: true
cmake_extra_args: -DCMAKE_OSX_ARCHITECTURES=x86_64 -DACECODE_BUILD_DESKTOP=ON
- id: macos-arm64
os: macos-15
triplet: arm64-osx
executable: acecode
archive_extension: tar.gz
build_desktop: true
cmake_extra_args: -DACECODE_BUILD_DESKTOP=ON
steps:
- name: Checkout
uses: actions/checkout@v4
with:
submodules: recursive
- name: Resolve package version
id: package-version
shell: bash
run: |
declared_version="$(awk '$1 == "project(acecode" && $2 == "VERSION" { print $3; exit }' CMakeLists.txt)"
if [ -z "$declared_version" ]; then
echo "::error::Unable to read the ACECode version from CMakeLists.txt"
exit 1
fi
if [[ "$GITHUB_REF" == refs/tags/v* && "${GITHUB_REF_NAME#v}" != "$declared_version" ]]; then
echo "::error::Tag $GITHUB_REF_NAME does not match CMake version $declared_version"
exit 1
fi
echo "version=$declared_version" >> "$GITHUB_OUTPUT"
- name: Check macOS release credentials
if: runner.os == 'macOS'
id: macos-release
shell: bash
env:
MACOS_CERTIFICATE_BASE64: ${{ secrets.MACOS_CERTIFICATE_BASE64 }}
MACOS_CERTIFICATE_PASSWORD: ${{ secrets.MACOS_CERTIFICATE_PASSWORD }}
MACOS_INSTALLER_CERTIFICATE_BASE64: ${{ secrets.MACOS_INSTALLER_CERTIFICATE_BASE64 }}
MACOS_INSTALLER_CERTIFICATE_PASSWORD: ${{ secrets.MACOS_INSTALLER_CERTIFICATE_PASSWORD }}
APPLE_ID: ${{ secrets.APPLE_ID }}
APPLE_TEAM_ID: ${{ secrets.APPLE_TEAM_ID }}
APPLE_APP_SPECIFIC_PASSWORD: ${{ secrets.APPLE_APP_SPECIFIC_PASSWORD }}
run: |
application_missing=()
for name in \
MACOS_CERTIFICATE_BASE64 \
MACOS_CERTIFICATE_PASSWORD \
APPLE_ID \
APPLE_TEAM_ID \
APPLE_APP_SPECIFIC_PASSWORD; do
if [ -z "${!name}" ]; then
application_missing+=("$name")
fi
done
if [ "${#application_missing[@]}" -ne 0 ]; then
if [[ "$GITHUB_REF" == refs/tags/v* ]]; then
echo "::error::Tagged macOS application releases require secrets: ${application_missing[*]}"
exit 1
fi
echo "::notice::macOS signing/notarization disabled; missing: ${application_missing[*]}"
echo "enabled=false" >> "$GITHUB_OUTPUT"
else
echo "enabled=true" >> "$GITHUB_OUTPUT"
fi
installer_certificate_set=false
installer_password_set=false
if [ -n "$MACOS_INSTALLER_CERTIFICATE_BASE64" ]; then
installer_certificate_set=true
fi
if [ -n "$MACOS_INSTALLER_CERTIFICATE_PASSWORD" ]; then
installer_password_set=true
fi
if [ "$installer_certificate_set" != "$installer_password_set" ]; then
echo "::error::macOS Installer credentials must configure both MACOS_INSTALLER_CERTIFICATE_BASE64 and MACOS_INSTALLER_CERTIFICATE_PASSWORD"
exit 1
fi
if [ "$installer_certificate_set" = "true" ]; then
if [ "${#application_missing[@]}" -eq 0 ]; then
echo "pkg_enabled=true" >> "$GITHUB_OUTPUT"
else
echo "::notice::macOS PKG creation disabled because application signing/notarization is disabled"
echo "pkg_enabled=false" >> "$GITHUB_OUTPUT"
fi
else
echo "::notice::macOS PKG creation disabled; Developer ID Installer credentials are not configured"
echo "pkg_enabled=false" >> "$GITHUB_OUTPUT"
fi
- name: Configure MSVC
if: runner.os == 'Windows'
uses: ilammy/msvc-dev-cmd@v1
with:
arch: ${{ matrix.msvc_arch }}
- name: Install Linux ARMv7 cross toolchain
if: matrix.id == 'linux-armv7'
shell: bash
run: |
sudo apt-get update
sudo apt-get install -y \
binutils-arm-linux-gnueabihf \
gcc-arm-linux-gnueabihf \
g++-arm-linux-gnueabihf \
qemu-user
- name: Run vcpkg
uses: lukka/run-vcpkg@v11
- name: Restore vcpkg binary cache
uses: actions/cache@v4
with:
path: ${{ env.VCPKG_DEFAULT_BINARY_CACHE }}
key: vcpkg-v2-${{ matrix.os }}-${{ matrix.triplet }}-${{ hashFiles('vcpkg.json', 'vcpkg-configuration.json', 'ports/**') }}
restore-keys: |
vcpkg-v2-${{ matrix.os }}-${{ matrix.triplet }}-
- name: Install Linux desktop dependencies
if: runner.os == 'Linux' && matrix.build_desktop
shell: bash
run: |
sudo apt-get update
sudo apt-get install -y libwebkit2gtk-4.1-dev
- name: Download web UI
uses: actions/download-artifact@v4
with:
name: web-dist
path: web/dist
- name: Configure
shell: bash
run: |
cmake -S . -B build -G Ninja \
-DCMAKE_BUILD_TYPE=MinSizeRel \
-DCMAKE_TOOLCHAIN_FILE="$VCPKG_ROOT/scripts/buildsystems/vcpkg.cmake" \
-DVCPKG_TARGET_TRIPLET="${{ matrix.triplet }}" \
-DBUILD_TESTING=OFF \
${{ matrix.cmake_extra_args }}
- name: Build
shell: bash
run: cmake --build build --config MinSizeRel --target acecode
- name: Build desktop
if: matrix.build_desktop
shell: bash
run: cmake --build build --config MinSizeRel --target acecode-desktop
- name: Verify Linux ARMv7 executable
if: matrix.id == 'linux-armv7'
shell: bash
run: |
export LC_ALL=C
elf_header="$(arm-linux-gnueabihf-readelf -h build/acecode)"
arm_attributes="$(arm-linux-gnueabihf-readelf -A build/acecode)"
program_headers="$(arm-linux-gnueabihf-readelf -l build/acecode)"
printf '%s\n' "$elf_header"
printf '%s\n' "$arm_attributes"
grep -Eq 'Class:[[:space:]]+ELF32' <<<"$elf_header"
grep -Eq 'Machine:[[:space:]]+ARM' <<<"$elf_header"
grep -Eq 'Tag_CPU_arch:[[:space:]]+v7' <<<"$arm_attributes"
grep -Eq 'Tag_ABI_VFP_args:[[:space:]]+VFP registers' <<<"$arm_attributes"
grep -Fq '/lib/ld-linux-armhf.so.3' <<<"$program_headers"
version_output="$(qemu-arm -L /usr/arm-linux-gnueabihf build/acecode --version)"
printf '%s\n' "$version_output"
grep -Eq '^acecode v[^[:space:]]+$' <<<"$version_output"
- name: Verify bundled resources in macOS app
if: runner.os == 'macOS' && matrix.build_desktop
shell: bash
run: |
registry_dir="build/ACECode.app/Contents/Resources/share/acecode/models_dev"
file_count="$(find "$registry_dir" -type f | wc -l | tr -d '[:space:]')"
if [ "$file_count" != "3" ]; then
echo "Expected exactly 3 models.dev resources in $registry_dir, found $file_count" >&2
exit 1
fi
for file in api.json MANIFEST.json LICENSE; do
if [ ! -f "$registry_dir/$file" ] ||
! cmp -s "assets/models_dev/$file" "$registry_dir/$file"; then
echo "Missing or mismatched macOS app models.dev resource: $file" >&2
exit 1
fi
done
python3 scripts/verify_seed_bundle.py \
--source assets/seed \
--packaged build/ACECode.app/Contents/Resources/share/acecode/seed
- name: Extract debug symbols (Linux)
if: runner.os == 'Linux'
shell: bash
run: |
binutils_prefix=""
if [ "${{ matrix.id }}" = "linux-armv7" ]; then
binutils_prefix="arm-linux-gnueabihf-"
fi
"${binutils_prefix}objcopy" --only-keep-debug \
"build/${{ matrix.executable }}" \
"build/${{ matrix.executable }}.debug"
"${binutils_prefix}strip" --strip-unneeded "build/${{ matrix.executable }}"
"${binutils_prefix}objcopy" \
--add-gnu-debuglink="build/${{ matrix.executable }}.debug" \
"build/${{ matrix.executable }}"
- name: Extract desktop debug symbols (Linux)
if: runner.os == 'Linux' && matrix.build_desktop
shell: bash
run: |
objcopy --only-keep-debug "build/acecode-desktop" "build/acecode-desktop.debug"
strip --strip-unneeded "build/acecode-desktop"
objcopy --add-gnu-debuglink="build/acecode-desktop.debug" "build/acecode-desktop"
- name: Extract debug symbols (macOS)
if: runner.os == 'macOS'
shell: bash
run: |
dsymutil "build/${{ matrix.executable }}" -o "build/${{ matrix.executable }}.dSYM"
strip "build/${{ matrix.executable }}"
- name: Extract desktop debug symbols (macOS)
if: runner.os == 'macOS' && matrix.build_desktop
shell: bash
run: |
app_exec="build/ACECode.app/Contents/MacOS/ACECode"
app_daemon="build/ACECode.app/Contents/MacOS/acecode-daemon"
if [ ! -f "$app_exec" ]; then
echo "Missing desktop app executable: $app_exec" >&2
exit 1
fi
if [ ! -f "$app_daemon" ]; then
echo "Missing desktop app daemon: $app_daemon" >&2
exit 1
fi
dsymutil "$app_exec" -o "build/ACECode.app.dSYM"
strip "$app_exec"
dsymutil "$app_daemon" -o "build/acecode-daemon.dSYM"
strip "$app_daemon"
- name: Import Developer ID identities (macOS)
if: runner.os == 'macOS' && steps.macos-release.outputs.enabled == 'true'
id: macos-keychain
shell: bash
env:
MACOS_CERTIFICATE_BASE64: ${{ secrets.MACOS_CERTIFICATE_BASE64 }}
MACOS_CERTIFICATE_PASSWORD: ${{ secrets.MACOS_CERTIFICATE_PASSWORD }}
MACOS_INSTALLER_CERTIFICATE_BASE64: ${{ secrets.MACOS_INSTALLER_CERTIFICATE_BASE64 }}
MACOS_INSTALLER_CERTIFICATE_PASSWORD: ${{ secrets.MACOS_INSTALLER_CERTIFICATE_PASSWORD }}
APPLE_TEAM_ID: ${{ secrets.APPLE_TEAM_ID }}
MACOS_CODESIGN_IDENTITY: ${{ vars.MACOS_CODESIGN_IDENTITY }}
MACOS_INSTALLER_SIGNING_IDENTITY: ${{ vars.MACOS_INSTALLER_SIGNING_IDENTITY }}
run: |
set +x
certificate_path="$RUNNER_TEMP/acecode-developer-id.p12"
installer_certificate_path="$RUNNER_TEMP/acecode-developer-id-installer.p12"
keychain_path="$RUNNER_TEMP/acecode-signing.keychain-db"
keychain_password="$(openssl rand -hex 32)"
printf '%s' "$MACOS_CERTIFICATE_BASE64" | /usr/bin/base64 -D > "$certificate_path"
chmod 600 "$certificate_path"
if [ "${{ steps.macos-release.outputs.pkg_enabled }}" = "true" ]; then
printf '%s' "$MACOS_INSTALLER_CERTIFICATE_BASE64" | /usr/bin/base64 -D > "$installer_certificate_path"
chmod 600 "$installer_certificate_path"
fi
security create-keychain -p "$keychain_password" "$keychain_path"
security set-keychain-settings -lut 21600 "$keychain_path"
security unlock-keychain -p "$keychain_password" "$keychain_path"
existing_user_keychains=()
while IFS= read -r existing_keychain; do
if [ -n "$existing_keychain" ]; then
existing_user_keychains+=("$existing_keychain")
fi
done < <(
security list-keychains -d user |
sed -E 's/^[[:space:]]*"//; s/"[[:space:]]*$//'
)
security list-keychains -d user -s \
"$keychain_path" \
"${existing_user_keychains[@]}"
security import "$certificate_path" \
-k "$keychain_path" \
-P "$MACOS_CERTIFICATE_PASSWORD" \
-f pkcs12 \
-T /usr/bin/codesign \
-T /usr/bin/security
if [ "${{ steps.macos-release.outputs.pkg_enabled }}" = "true" ]; then
security import "$installer_certificate_path" \
-k "$keychain_path" \
-P "$MACOS_INSTALLER_CERTIFICATE_PASSWORD" \
-f pkcs12 \
-T /usr/bin/pkgbuild \
-T /usr/bin/productbuild \
-T /usr/bin/security
fi
security set-key-partition-list \
-S apple-tool:,apple: \
-s \
-k "$keychain_password" \
"$keychain_path"
identity_record="$(security find-identity -v -p codesigning "$keychain_path" |
awk '/Developer ID Application:/ { print; exit }')"
identity_fingerprint="$(printf '%s\n' "$identity_record" | awk '{ print $2 }')"
identity_name="$(printf '%s\n' "$identity_record" | awk -F '"' '{ print $2 }')"
if [[ ! "$identity_fingerprint" =~ ^[[:xdigit:]]{40}$ ]] || [ -z "$identity_name" ]; then
echo "::error::No Developer ID Application identity found in the imported certificate"
exit 1
fi
if [ -n "$MACOS_CODESIGN_IDENTITY" ] && [ "$identity_name" != "$MACOS_CODESIGN_IDENTITY" ]; then
echo "::error::Imported signing identity does not match MACOS_CODESIGN_IDENTITY"
exit 1
fi
if [ -n "$APPLE_TEAM_ID" ] && [[ "$identity_name" != *"($APPLE_TEAM_ID)" ]]; then
echo "::error::Developer ID Application identity does not match APPLE_TEAM_ID"
exit 1
fi
if [ "${{ steps.macos-release.outputs.pkg_enabled }}" = "true" ]; then
installer_identity_record="$(security find-identity -v -p basic "$keychain_path" |
awk '/Developer ID Installer:/ { print; exit }')"
installer_identity_fingerprint="$(printf '%s\n' "$installer_identity_record" | awk '{ print $2 }')"
installer_identity_name="$(printf '%s\n' "$installer_identity_record" | awk -F '"' '{ print $2 }')"
if [[ ! "$installer_identity_fingerprint" =~ ^[[:xdigit:]]{40}$ ]] || [ -z "$installer_identity_name" ]; then
echo "::error::No Developer ID Installer identity found in the imported certificate"
exit 1
fi
if [ -n "$MACOS_INSTALLER_SIGNING_IDENTITY" ] && [ "$installer_identity_name" != "$MACOS_INSTALLER_SIGNING_IDENTITY" ]; then
echo "::error::Imported Installer identity does not match MACOS_INSTALLER_SIGNING_IDENTITY"
exit 1
fi
if [ -n "$APPLE_TEAM_ID" ] && [[ "$installer_identity_name" != *"($APPLE_TEAM_ID)" ]]; then
echo "::error::Developer ID Installer identity does not match APPLE_TEAM_ID"
exit 1
fi
echo "installer_identity=$installer_identity_name" >> "$GITHUB_OUTPUT"
fi
echo "keychain=$keychain_path" >> "$GITHUB_OUTPUT"
# Sign by the certificate fingerprint. codesign can fail to resolve a
# human-readable identity name inside an isolated temporary keychain.
echo "identity=$identity_fingerprint" >> "$GITHUB_OUTPUT"
- name: Sign macOS release payloads
if: runner.os == 'macOS' && steps.macos-release.outputs.enabled == 'true'
shell: bash
run: |
scripts/macos_codesign.sh \
--identity "${{ steps.macos-keychain.outputs.identity }}" \
--keychain "${{ steps.macos-keychain.outputs.keychain }}" \
--binary "build/${{ matrix.executable }}" \
--app "build/ACECode.app"
- name: Notarize and staple macOS app
if: runner.os == 'macOS' && steps.macos-release.outputs.enabled == 'true'
shell: bash
env:
APPLE_ID: ${{ secrets.APPLE_ID }}
APPLE_TEAM_ID: ${{ secrets.APPLE_TEAM_ID }}
APPLE_APP_SPECIFIC_PASSWORD: ${{ secrets.APPLE_APP_SPECIFIC_PASSWORD }}
run: scripts/macos_notarize_app.sh --app "build/ACECode.app"
- name: Create macOS self-update archive
if: runner.os == 'macOS'
id: macos-update
shell: bash
run: |
unsigned_suffix=""
trust_args=()
if [ "${{ steps.macos-release.outputs.enabled }}" = "true" ]; then
trust_args+=(--require-trusted)
else
unsigned_suffix="-unsigned"
fi
update_path="ACECode-${{ steps.package-version.outputs.version }}-${{ matrix.id }}-update${unsigned_suffix}.zip"
scripts/macos_create_update_zip.sh \
--app "build/ACECode.app" \
--output "$update_path" \
"${trust_args[@]}"
echo "path=$update_path" >> "$GITHUB_OUTPUT"
- name: Package (Unix)
if: runner.os != 'Windows'
shell: bash
run: |
package_dir="dist/acecode-${{ matrix.id }}"
mkdir -p "$package_dir"
validate_models_dev_registry() {
registry_dir="$1"
file_count="$(find "$registry_dir" -type f | wc -l | tr -d '[:space:]')"
if [ "$file_count" != "3" ]; then
echo "Expected exactly 3 models.dev files in $registry_dir, found $file_count" >&2
exit 1
fi
for file in api.json MANIFEST.json LICENSE; do
if [ ! -f "$registry_dir/$file" ] ||
! cmp -s "assets/models_dev/$file" "$registry_dir/$file"; then
echo "Missing or mismatched models.dev package file: $registry_dir/$file" >&2
exit 1
fi
done
}
if [ ! -f "build/${{ matrix.executable }}" ]; then
echo "Missing terminal executable: build/${{ matrix.executable }}" >&2
exit 1
fi
cp "build/${{ matrix.executable }}" "$package_dir/"
cp README.md README_CN.md "$package_dir/"
cmake --install build \
--config MinSizeRel \
--prefix "$PWD/$package_dir" \
--component models_dev_registry
cmake --install build \
--config MinSizeRel \
--prefix "$PWD/$package_dir" \
--component default_seed_bundle
validate_models_dev_registry "$package_dir/share/acecode/models_dev"
python3 scripts/verify_seed_bundle.py \
--source assets/seed \
--packaged "$package_dir/share/acecode/seed"
if [ "${{ matrix.build_desktop }}" = "true" ]; then
if [ "$RUNNER_OS" = "macOS" ]; then
if [ ! -d "build/ACECode.app" ]; then
echo "Missing desktop app bundle: build/ACECode.app" >&2
exit 1
fi
cp -r "build/ACECode.app" "$package_dir/"
else
if [ ! -f "build/acecode-desktop" ]; then
echo "Missing desktop executable: build/acecode-desktop" >&2
exit 1
fi
cp "build/acecode-desktop" "$package_dir/"
cp "web/dist/acecode-logo.png" "$package_dir/"
fi
fi
legacy="$(find "$package_dir" -maxdepth 1 -iname 'ace-browser-*' -print -quit)"
if [ -n "$legacy" ]; then
echo "Legacy browser artifact must not be packaged: $legacy" >&2
exit 1
fi
tar -C dist -czf "acecode-${{ matrix.id }}.tar.gz" "acecode-${{ matrix.id }}"
verify_root="$(mktemp -d)"
tar -xzf "acecode-${{ matrix.id }}.tar.gz" -C "$verify_root"
extracted_package="$verify_root/acecode-${{ matrix.id }}"
validate_models_dev_registry "$extracted_package/share/acecode/models_dev"
python3 scripts/verify_seed_bundle.py \
--source assets/seed \
--packaged "$extracted_package/share/acecode/seed"
if [ "$RUNNER_OS" = "macOS" ]; then
validate_models_dev_registry \
"$extracted_package/ACECode.app/Contents/Resources/share/acecode/models_dev"
python3 scripts/verify_seed_bundle.py \
--source assets/seed \
--packaged "$extracted_package/ACECode.app/Contents/Resources/share/acecode/seed"
fi
rm -rf -- "$verify_root"
- name: Create Linux self-update archive
if: matrix.id == 'linux-x64' || matrix.id == 'linux-arm64'
id: linux-update
shell: bash
run: |
update_path="acecode-${{ steps.package-version.outputs.version }}-${{ matrix.id }}-update.zip"
bash scripts/linux_create_update_zip.sh \
--package-dir "dist/acecode-${{ matrix.id }}" \
--output "$update_path" \
--expected-version "${{ steps.package-version.outputs.version }}"
echo "path=$update_path" >> "$GITHUB_OUTPUT"
- name: Create current-user macOS PKG
if: runner.os == 'macOS' && steps.macos-release.outputs.pkg_enabled == 'true'
id: macos-pkg
shell: bash
run: |
pkg_path="ACECode-${{ steps.package-version.outputs.version }}-${{ matrix.id }}.pkg"
scripts/macos_create_pkg.sh \
--app "build/ACECode.app" \
--output "$pkg_path" \
--installer-identity "${{ steps.macos-keychain.outputs.installer_identity }}" \
--keychain "${{ steps.macos-keychain.outputs.keychain }}"
echo "path=$pkg_path" >> "$GITHUB_OUTPUT"
- name: Notarize and validate macOS PKG
if: runner.os == 'macOS' && steps.macos-release.outputs.pkg_enabled == 'true'
shell: bash
env:
APPLE_ID: ${{ secrets.APPLE_ID }}
APPLE_TEAM_ID: ${{ secrets.APPLE_TEAM_ID }}
APPLE_APP_SPECIFIC_PASSWORD: ${{ secrets.APPLE_APP_SPECIFIC_PASSWORD }}
run: scripts/macos_notarize_pkg.sh --pkg "${{ steps.macos-pkg.outputs.path }}"
- name: Clean up macOS signing material
if: always() && runner.os == 'macOS'
shell: bash
run: |
set +e
security delete-keychain "$RUNNER_TEMP/acecode-signing.keychain-db" 2>/dev/null
rm -f -- \
"$RUNNER_TEMP/acecode-developer-id.p12" \
"$RUNNER_TEMP/acecode-developer-id-installer.p12"
- name: Package (Windows)
if: runner.os == 'Windows'
shell: pwsh
run: |
$packageDir = "dist/acecode-${{ matrix.id }}"
New-Item -ItemType Directory -Force -Path $packageDir | Out-Null
function Assert-ModelsDevRegistry([string] $RegistryDir) {
if (-not (Test-Path -LiteralPath $RegistryDir -PathType Container)) {
throw "Missing models.dev directory: $RegistryDir"
}
$actualFiles = @(Get-ChildItem -LiteralPath $RegistryDir -File -Recurse)
if ($actualFiles.Count -ne 3) {
throw "Expected exactly 3 models.dev files in ${RegistryDir}, found $($actualFiles.Count)"
}
foreach ($name in @("api.json", "MANIFEST.json", "LICENSE")) {
$source = Join-Path "assets/models_dev" $name
$packaged = Join-Path $RegistryDir $name
if (-not (Test-Path -LiteralPath $packaged -PathType Leaf)) {
throw "Missing models.dev package file: $packaged"
}
$sourceHash = (Get-FileHash -LiteralPath $source -Algorithm SHA256).Hash
$packagedHash = (Get-FileHash -LiteralPath $packaged -Algorithm SHA256).Hash
if ($sourceHash -ne $packagedHash) {
throw "Mismatched models.dev package file: $packaged"
}
}
}
$terminalExe = "build/${{ matrix.executable }}"
if (-not (Test-Path -LiteralPath $terminalExe)) {
throw "Missing terminal executable: $terminalExe"
}
Copy-Item -LiteralPath $terminalExe -Destination "$packageDir/"
Copy-Item "README.md","README_CN.md" "$packageDir/"
$packageRoot = (Resolve-Path -LiteralPath $packageDir).Path
& cmake --install build --config MinSizeRel --prefix $packageRoot --component models_dev_registry
if ($LASTEXITCODE -ne 0) {
throw "Failed to install the bundled models.dev registry"
}
& cmake --install build --config MinSizeRel --prefix $packageRoot --component default_seed_bundle
if ($LASTEXITCODE -ne 0) {
throw "Failed to install the default seed bundle"
}
Assert-ModelsDevRegistry (Join-Path $packageDir "share/acecode/models_dev")
& python scripts/verify_seed_bundle.py `
--source assets/seed `
--packaged (Join-Path $packageDir "share/acecode/seed")
if ($LASTEXITCODE -ne 0) {
throw "Failed to verify the packaged default seed bundle"
}
if ("${{ matrix.build_desktop }}" -eq "true") {
$desktopCandidates = @(
"build/acecode-desktop.exe",
"build/Release/acecode-desktop.exe",
"build/Debug/acecode-desktop.exe",
"build/RelWithDebInfo/acecode-desktop.exe",
"build/MinSizeRel/acecode-desktop.exe"
)
$desktopExe = $desktopCandidates | Where-Object { Test-Path -LiteralPath $_ } | Select-Object -First 1
if (-not $desktopExe) {
$desktopExe = Get-ChildItem -Path "build" -Recurse -Filter "acecode-desktop.exe" -File |
Select-Object -ExpandProperty FullName -First 1
}
if (-not $desktopExe) {
throw "Missing desktop executable: acecode-desktop.exe"
}
Copy-Item -LiteralPath $desktopExe -Destination "$packageDir/"
}
$legacyBrowserArtifact = Get-ChildItem -LiteralPath $packageDir -Filter "ace-browser-*" -Force |
Select-Object -First 1
if ($legacyBrowserArtifact) {
throw "Legacy browser artifact must not be packaged: $($legacyBrowserArtifact.FullName)"
}
Compress-Archive -Path "$packageDir/*" -DestinationPath "acecode-${{ matrix.id }}.zip" -Force
$verifyRoot = Join-Path $env:RUNNER_TEMP ("acecode-package-verify-" + [Guid]::NewGuid().ToString("N"))
New-Item -ItemType Directory -Path $verifyRoot | Out-Null
Expand-Archive -LiteralPath "acecode-${{ matrix.id }}.zip" -DestinationPath $verifyRoot
Assert-ModelsDevRegistry (Join-Path $verifyRoot "share/acecode/models_dev")
& python scripts/verify_seed_bundle.py `
--source assets/seed `
--packaged (Join-Path $verifyRoot "share/acecode/seed")
if ($LASTEXITCODE -ne 0) {
throw "Failed to verify the archived default seed bundle"
}
- name: Verify Windows ARM64 package
if: matrix.id == 'windows-arm64'
shell: pwsh
run: |
$packageDir = "dist/acecode-${{ matrix.id }}"
$expectedExecutables = @(
"acecode.exe",
"acecode-desktop.exe"
)
foreach ($name in $expectedExecutables) {
$path = Join-Path $packageDir $name
if (-not (Test-Path -LiteralPath $path)) {
throw "Missing ARM64 package executable: $path"
}
$headers = (& dumpbin /headers $path | Out-String)
if ($LASTEXITCODE -ne 0 -or $headers -notmatch '(?im)\bAA64 machine\b') {
throw "$name is not an ARM64 PE executable"
}
Write-Host "${name}: ARM64"
}
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: acecode-${{ matrix.id }}
path: acecode-${{ matrix.id }}.${{ matrix.archive_extension }}
if-no-files-found: error
- name: Upload Linux self-update archive
if: matrix.id == 'linux-x64' || matrix.id == 'linux-arm64'
uses: actions/upload-artifact@v4
with:
name: acecode-${{ matrix.id }}-update
path: ${{ steps.linux-update.outputs.path }}
if-no-files-found: error
- name: Upload macOS PKG
if: runner.os == 'macOS' && steps.macos-release.outputs.pkg_enabled == 'true'
uses: actions/upload-artifact@v4
with:
name: acecode-${{ matrix.id }}-pkg
path: ${{ steps.macos-pkg.outputs.path }}
if-no-files-found: error
- name: Upload macOS self-update archive
if: runner.os == 'macOS'
uses: actions/upload-artifact@v4
with:
name: acecode-${{ matrix.id }}-update
path: ${{ steps.macos-update.outputs.path }}
if-no-files-found: error
- name: Upload PDB
if: runner.os == 'Windows'
uses: actions/upload-artifact@v4
with:
name: acecode-${{ matrix.id }}-pdb
path: build/**/acecode.pdb
if-no-files-found: warn
- name: Upload desktop PDB
if: runner.os == 'Windows' && matrix.build_desktop
uses: actions/upload-artifact@v4
with:
name: acecode-${{ matrix.id }}-desktop-pdb
path: build/**/acecode-desktop.pdb
if-no-files-found: warn
- name: Upload debug symbols (Linux)
if: runner.os == 'Linux'
uses: actions/upload-artifact@v4
with:
name: acecode-${{ matrix.id }}-debug
path: build/${{ matrix.executable }}.debug
if-no-files-found: warn
- name: Upload desktop debug symbols (Linux)
if: runner.os == 'Linux' && matrix.build_desktop
uses: actions/upload-artifact@v4
with:
name: acecode-${{ matrix.id }}-desktop-debug
path: build/acecode-desktop.debug
if-no-files-found: warn
- name: Upload dSYM (macOS)
if: runner.os == 'macOS'
uses: actions/upload-artifact@v4
with:
name: acecode-${{ matrix.id }}-dsym
path: build/${{ matrix.executable }}.dSYM
if-no-files-found: warn
- name: Upload desktop dSYM (macOS)
if: runner.os == 'macOS' && matrix.build_desktop
uses: actions/upload-artifact@v4
with:
name: acecode-${{ matrix.id }}-desktop-dsym
path: |
build/ACECode.app.dSYM
build/acecode-daemon.dSYM
if-no-files-found: warn
build-linux-old-package:
name: ${{ matrix.id }}
needs: build-web-ui
runs-on: ${{ matrix.os }}
container:
image: buildpack-deps:buster
env:
DEBIAN_FRONTEND: noninteractive
VCPKG_BINARY_SOURCES: clear;default,readwrite
VCPKG_FORCE_SYSTEM_BINARIES: 1
strategy:
fail-fast: false
matrix:
include:
- id: linux-old-x64
os: ubuntu-22.04
triplet: x64-linux
executable: acecode
archive_extension: tar.gz
build_desktop: true
cmake_extra_args: >-
-DACECODE_BUILD_DESKTOP=ON
-DWEBVIEW_WEBKITGTK_API=4.0
- id: linux-old-arm64
os: ubuntu-22.04-arm
triplet: arm64-linux
executable: acecode
archive_extension: tar.gz
build_desktop: true
cmake_extra_args: >-
-DACECODE_BUILD_DESKTOP=ON
-DWEBVIEW_WEBKITGTK_API=4.0
- id: linux-old-armv7
os: ubuntu-22.04
triplet: arm-linux
executable: acecode
archive_extension: tar.gz
build_desktop: false
cmake_extra_args: >-
-DACECODE_BUILD_DESKTOP=OFF
-DVCPKG_CHAINLOAD_TOOLCHAIN_FILE="$VCPKG_ROOT/scripts/toolchains/linux.cmake"
-DVCPKG_TARGET_ARCHITECTURE=arm
-DCMAKE_C_COMPILER=clang-11
-DCMAKE_CXX_COMPILER=clang++-11
-DCMAKE_C_COMPILER_TARGET=arm-linux-gnueabihf
-DCMAKE_CXX_COMPILER_TARGET=arm-linux-gnueabihf
-DCMAKE_C_STANDARD_INCLUDE_DIRECTORIES=/usr/arm-linux-gnueabihf/include
-DCMAKE_CXX_STANDARD_INCLUDE_DIRECTORIES="/usr/arm-linux-gnueabihf/include/c++/8;/usr/arm-linux-gnueabihf/include/c++/8/arm-linux-gnueabihf;/usr/arm-linux-gnueabihf/include"
steps:
- name: Checkout
uses: actions/checkout@v4
with:
submodules: recursive
- name: Install old Linux dependencies
shell: bash
run: |
sed -i \
-e 's|http://deb.debian.org/debian|http://archive.debian.org/debian|g' \
-e 's|http://security.debian.org/debian-security|http://archive.debian.org/debian-security|g' \
-e 's|http://deb.debian.org/debian-security|http://archive.debian.org/debian-security|g' \
/etc/apt/sources.list
printf 'Acquire::Check-Valid-Until "false";\n' > /etc/apt/apt.conf.d/99no-check-valid-until
apt-get update
packages=(
binutils \
build-essential \
ca-certificates \
curl \
file \
git \
ninja-build \
perl \
pkg-config \
python3 \
python3-pip \
tar \
unzip \
zip
)
if [ "${{ matrix.build_desktop }}" = "true" ]; then
packages+=(libgtk-3-dev libwebkit2gtk-4.0-dev)
fi
if [ "${{ matrix.id }}" = "linux-old-armv7" ]; then
packages+=(
binutils-arm-linux-gnueabihf
clang-11
gcc-arm-linux-gnueabihf
g++-arm-linux-gnueabihf
qemu-user
)
fi
apt-get install -y --no-install-recommends "${packages[@]}"
rm -rf /var/lib/apt/lists/*
- name: Set up CMake
uses: jwlawson/actions-setup-cmake@v2
with:
cmake-version: '3.29.x'
- name: Run vcpkg
uses: lukka/run-vcpkg@v11
- name: Restore vcpkg binary cache
uses: actions/cache@v4
with:
path: ${{ env.VCPKG_DEFAULT_BINARY_CACHE }}
key: vcpkg-v2-buster-${{ matrix.os }}-${{ matrix.triplet }}-${{ hashFiles('vcpkg.json', 'vcpkg-configuration.json', 'ports/**') }}
restore-keys: |
vcpkg-v2-buster-${{ matrix.os }}-${{ matrix.triplet }}-
- name: Download web UI
uses: actions/download-artifact@v4
with:
name: web-dist
path: web/dist
- name: Configure
shell: bash
run: |
cmake -S . -B build -G Ninja \
-DCMAKE_BUILD_TYPE=MinSizeRel \
-DCMAKE_TOOLCHAIN_FILE="$VCPKG_ROOT/scripts/buildsystems/vcpkg.cmake" \
-DVCPKG_TARGET_TRIPLET="${{ matrix.triplet }}" \
-DBUILD_TESTING=OFF \
${{ matrix.cmake_extra_args }}
- name: Build
shell: bash
run: cmake --build build --config MinSizeRel --target acecode
- name: Build desktop
if: matrix.build_desktop
shell: bash
run: cmake --build build --config MinSizeRel --target acecode-desktop
- name: Verify old Linux ABI
shell: bash
run: |
abi_binaries=(build/acecode)
if [ "${{ matrix.build_desktop }}" = "true" ]; then
abi_binaries+=(build/acecode-desktop)
fi
max_glibc="$(
strings "${abi_binaries[@]}" |
grep -Eo 'GLIBC_[0-9]+\.[0-9]+' |
sed 's/GLIBC_//' |
sort -Vu |
tail -n1
)"
if [ -z "$max_glibc" ]; then
echo "No GLIBC symbol versions found" >&2
exit 1
fi
echo "Max GLIBC symbol: GLIBC_$max_glibc"