-
-
Notifications
You must be signed in to change notification settings - Fork 124
1994 lines (1796 loc) · 81.9 KB
/
Copy pathc-cpp.yml
File metadata and controls
1994 lines (1796 loc) · 81.9 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: C/C++ CI
on:
workflow_dispatch:
push:
branches: [master]
tags:
- 'v*'
- 'preview-v*'
paths-ignore:
- '**.md'
- 'wiki/**'
- '.github/ISSUE_TEMPLATE/**'
- '.github/FUNDING.yml'
- '.github/CODE_OF_CONDUCT.md'
- '.github/CONTRIBUTING.md'
pull_request:
paths-ignore:
- '**.md'
- 'wiki/**'
# Cancel older in-progress runs for the same branch/PR ref.
# This reduces wasted CI minutes when multiple pushes happen quickly.
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
# Set least-privilege defaults for all jobs
permissions:
contents: read
env:
QEMU_UAE_RELEASE_REPO: BlitterStudio/amiberry-qemu-uae
QEMU_UAE_RELEASE_TAG: v11.0.1-amiberry.7
GH_TOKEN: ${{ github.token }}
jobs:
build-macOS:
runs-on: ${{ matrix.runner }}
timeout-minutes: 45
permissions:
contents: read
actions: write
strategy:
fail-fast: false
matrix:
include:
- name: x86_64
runner: macos-15-intel
arch: intel
artifact_name: amiberry-macOS-x86_64-intermediate
- name: Apple-Silicon
runner: macos-15
arch: apple-silicon
artifact_name: amiberry-macOS-arm64-intermediate
steps:
- name: Check out repository code
uses: actions/checkout@v6
with:
submodules: recursive
- name: Cache Homebrew
if: matrix.arch == 'intel'
uses: actions/cache@v5
with:
path: /usr/local/Homebrew
key: ${{ runner.os }}-brew-${{ hashFiles('Brewfile') }}
restore-keys: |
${{ runner.os }}-brew-
- name: Fix homebrew in Github Runner
if: matrix.arch == 'intel'
run: |
for f in $(find /usr/local/bin -type l -print); do \
(readlink $f | grep -q -s "/Library") && echo Removing "$f" && rm -f "$f"; \
done || exit 0
- name: Ensure GLib is available for QEMU-UAE plugin bundling
if: matrix.arch == 'intel'
run: |
# Intel runners normally include GLib already. Avoid upgrading it via
# the old gobject-introspection workaround, since Homebrew postinstall
# failures there can fail CI even when the libraries are usable.
if ! brew --prefix glib >/dev/null 2>&1; then
brew install glib || true
fi
glib_prefix="$(brew --prefix glib)"
test -f "$glib_prefix/lib/libglib-2.0.0.dylib"
test -f "$glib_prefix/lib/libgmodule-2.0.0.dylib"
- name: Install dependencies (Homebrew)
run: |
brew update
# `brew bundle` installs formulae concurrently, so sdl3 (which depends on
# cmake) races the cmake entry for the cmake lock and intermittently fails
# ("a `brew install --formula sdl3` process has already locked .../cmake").
# Install the shared build dependency first, then retry the bundle once to
# ride out any remaining transient lock contention.
brew install cmake || true
brew bundle || { sleep 10; brew bundle; }
- name: Download QEMU-UAE plugin
run: .github/scripts/download-qemu-uae-plugin.sh qemu-uae-macos-universal.zip
- name: Build for macOS (${{ matrix.name }})
run: |
cmake -B build -DQEMU_UAE_PLUGIN="$QEMU_UAE_PLUGIN" && cmake --build build -j$(sysctl -n hw.ncpu)
- name: Archive intermediate app bundle
run: |
tar -C build -czf Amiberry.app.tar.gz Amiberry.app
- name: Upload intermediate app bundle
uses: actions/upload-artifact@v7
with:
name: ${{ matrix.artifact_name }}
path: Amiberry.app.tar.gz
retention-days: 1
merge-macOS-universal:
needs: [build-macOS]
runs-on: macos-15
timeout-minutes: 30
permissions:
contents: read
actions: write
steps:
- name: Check out repository code
uses: actions/checkout@v6
- name: Download x86_64 app bundle
uses: actions/download-artifact@v8
with:
name: amiberry-macOS-x86_64-intermediate
path: x86_64-app
- name: Download arm64 app bundle
uses: actions/download-artifact@v8
with:
name: amiberry-macOS-arm64-intermediate
path: arm64-app
- name: Extract downloaded app bundles
run: |
tar -xzf x86_64-app/Amiberry.app.tar.gz -C x86_64-app
tar -xzf arm64-app/Amiberry.app.tar.gz -C arm64-app
- name: Create Universal binary with lipo
run: |
# macOS ships bash 3.2 (GPLv2); install bash 5 for associative arrays
if [ "${BASH_VERSINFO[0]:-0}" -lt 4 ]; then
brew install bash
exec "$(brew --prefix)/bin/bash" --noprofile --norc -euo pipefail "$0" "$@"
fi
set -euo pipefail
mkdir -p universal-app/Amiberry.app
# Start with the arm64 app as the base (preserves bundle structure)
cp -R arm64-app/Amiberry.app/ universal-app/Amiberry.app/
# Merge the main executable
lipo -create \
x86_64-app/Amiberry.app/Contents/MacOS/Amiberry \
arm64-app/Amiberry.app/Contents/MacOS/Amiberry \
-output universal-app/Amiberry.app/Contents/MacOS/Amiberry
chmod +x universal-app/Amiberry.app/Contents/MacOS/Amiberry
# Helper: merge a single binary with lipo, skipping if already universal
merge_binary() {
local x86_file="$1" arm_file="$2" output="$3"
if [ ! -f "$x86_file" ] || [ ! -f "$arm_file" ]; then
return
fi
# If a file is already universal (e.g. capsimage builds fat), just copy it
local x86_archs arm_archs
x86_archs=$(lipo -info "$x86_file" 2>/dev/null | sed 's/.*: //')
arm_archs=$(lipo -info "$arm_file" 2>/dev/null | sed 's/.*: //')
if echo "$x86_archs" | grep -q "x86_64" && echo "$x86_archs" | grep -q "arm64"; then
echo " Already universal: $(basename "$output") — copying as-is"
cp "$x86_file" "$output"
elif [ "$x86_archs" = "$arm_archs" ]; then
echo " WARNING: same arch in both — copying x86 version: $(basename "$output")"
cp "$x86_file" "$output"
else
lipo -create "$x86_file" "$arm_file" -output "$output"
fi
}
# Helper: extract library stem from a versioned dylib filename
# For libs with -N in the name (e.g. libglib-2.0), strip only the last version component
# libglib-2.0.0.dylib → libglib-2.0
# libgobject-2.0.0.dylib → libgobject-2.0
# For all other libs, strip the entire trailing version
# libavif.16.4.0.dylib → libavif
# libSDL3.0.6.0.dylib → libSDL3
# libpng16.16.dylib → libpng16
lib_stem() {
local name="${1%.dylib}"
if [[ "$name" =~ -[0-9] ]] && [[ "$name" =~ \.[0-9]+([.][0-9]+)*$ ]]; then
echo "${name%.*}"
else
echo "$name" | sed -E 's/\.[0-9]+(\.[0-9]+)*$//'
fi
}
X86_FW="x86_64-app/Amiberry.app/Contents/Frameworks"
ARM_FW="arm64-app/Amiberry.app/Contents/Frameworks"
UNI_FW="universal-app/Amiberry.app/Contents/Frameworks"
# Build stem → filename maps for both architectures
declare -A x86_stems arm_stems
if [ -d "$X86_FW" ]; then
for f in "$X86_FW"/*.dylib; do
[ -f "$f" ] || continue
name=$(basename "$f")
stem=$(lib_stem "$name")
x86_stems["$stem"]="$name"
done
fi
if [ -d "$ARM_FW" ]; then
for f in "$ARM_FW"/*.dylib; do
[ -f "$f" ] || continue
name=$(basename "$f")
stem=$(lib_stem "$name")
arm_stems["$stem"]="$name"
done
fi
# Parity check: warn about mismatches between architectures
echo "=== Checking dylib parity between x86_64 and arm64 builds ==="
had_mismatch=0
for stem in "${!arm_stems[@]}"; do
arm_name="${arm_stems[$stem]}"
x86_name="${x86_stems[$stem]:-}"
if [ -z "$x86_name" ]; then
echo " WARNING: $arm_name exists only in arm64 build (no x86_64 equivalent)"
had_mismatch=1
elif [ "$arm_name" != "$x86_name" ]; then
echo " WARNING: version mismatch for $stem: x86_64=$x86_name vs arm64=$arm_name"
had_mismatch=1
fi
done
for stem in "${!x86_stems[@]}"; do
if [ -z "${arm_stems[$stem]:-}" ]; then
echo " WARNING: ${x86_stems[$stem]} exists only in x86_64 build (no arm64 equivalent)"
had_mismatch=1
fi
done
if [ "$had_mismatch" = "0" ]; then
echo " All dylibs match between architectures"
fi
# Merge Frameworks dylibs using stem-aware matching
echo "=== Merging Frameworks dylibs ==="
declare -A merged_stems
# Collect all unique stems from both architectures
all_stems=()
for stem in "${!arm_stems[@]}"; do all_stems+=("$stem"); done
for stem in "${!x86_stems[@]}"; do
if [ -z "${arm_stems[$stem]:-}" ]; then
all_stems+=("$stem")
fi
done
for stem in "${all_stems[@]}"; do
[ -n "${merged_stems[$stem]:-}" ] && continue
merged_stems["$stem"]=1
x86_name="${x86_stems[$stem]:-}"
arm_name="${arm_stems[$stem]:-}"
if [ -n "$x86_name" ] && [ -n "$arm_name" ]; then
if [ "$x86_name" = "$arm_name" ]; then
# Same filename — standard merge
echo " Merging: $arm_name"
merge_binary "$X86_FW/$x86_name" "$ARM_FW/$arm_name" "$UNI_FW/$arm_name"
else
# Version mismatch — merge by stem, provide both names
echo " Merging with version mismatch: x86_64=$x86_name + arm64=$arm_name"
merge_binary "$X86_FW/$x86_name" "$ARM_FW/$arm_name" "$UNI_FW/$arm_name"
ln -sf "$arm_name" "$UNI_FW/$x86_name"
echo " → Universal dylib: $arm_name, symlink: $x86_name → $arm_name"
fi
elif [ -n "$arm_name" ]; then
echo " Keeping arm64-only: $arm_name (no x86_64 equivalent)"
elif [ -n "$x86_name" ]; then
echo " Copying x86_64-only: $x86_name (not in arm64 base)"
cp "$X86_FW/$x86_name" "$UNI_FW/$x86_name"
fi
done
# Merge all dylibs in plugins (arm64 base + any x86-only plugins)
UNI_PLUGINS="universal-app/Amiberry.app/Contents/Resources/plugins"
X86_PLUGINS="x86_64-app/Amiberry.app/Contents/Resources/plugins"
ARM_PLUGINS="arm64-app/Amiberry.app/Contents/Resources/plugins"
if [ -d "$UNI_PLUGINS" ]; then
for dylib in "$UNI_PLUGINS"/*.dylib; do
[ -f "$dylib" ] || continue
bname=$(basename "$dylib")
merge_binary "$X86_PLUGINS/$bname" "$ARM_PLUGINS/$bname" "$dylib"
done
fi
if [ -d "$X86_PLUGINS" ]; then
for dylib in "$X86_PLUGINS"/*.dylib; do
[ -f "$dylib" ] || continue
bname=$(basename "$dylib")
if [ ! -f "$UNI_PLUGINS/$bname" ]; then
echo " Copying x86_64-only plugin: $bname"
mkdir -p "$UNI_PLUGINS"
cp "$dylib" "$UNI_PLUGINS/$bname"
fi
done
fi
QEMU_PLUGIN="$UNI_PLUGINS/qemu-uae.dylib"
if [ ! -f "$QEMU_PLUGIN" ]; then
echo "::error::Universal app bundle is missing qemu-uae.dylib"
exit 1
fi
lipo "$QEMU_PLUGIN" -verify_arch x86_64 arm64
# Verify the main binary is universal
echo "=== Universal binary info ==="
lipo -info universal-app/Amiberry.app/Contents/MacOS/Amiberry
file universal-app/Amiberry.app/Contents/MacOS/Amiberry
# Verify all Frameworks dylibs are universal
echo "=== Verifying Frameworks dylibs ==="
non_universal=0
for dylib in "$UNI_FW"/*.dylib; do
[ -f "$dylib" ] || continue
# Skip symlinks — they point to an already-checked universal dylib
[ -L "$dylib" ] && continue
archs=$(lipo -info "$dylib" 2>/dev/null | sed 's/.*: //')
name=$(basename "$dylib")
if echo "$archs" | grep -q "x86_64" && echo "$archs" | grep -q "arm64"; then
echo " OK: $name ($archs)"
else
echo " WARNING: $name is NOT universal ($archs)"
non_universal=1
fi
done
if [ "$non_universal" = "1" ]; then
echo "::warning::Some Frameworks dylibs are not universal — the app may crash on one architecture"
fi
echo "=== Verifying dylib dependencies resolve ==="
missing_deps=0
MAIN_BIN="universal-app/Amiberry.app/Contents/MacOS/Amiberry"
check_framework_refs() {
local binary="$1"
local label="$2"
for arch in x86_64 arm64; do
if ! lipo "$binary" -verify_arch "$arch" >/dev/null 2>&1; then
continue
fi
while read -r line; do
dep_name=$(echo "$line" | sed -E 's|.*@executable_path/../Frameworks/([^ ]+).*|\1|')
if [ ! -f "$UNI_FW/$dep_name" ]; then
echo " MISSING ($arch, $label): $dep_name"
missing_deps=1
fi
done < <(otool -arch "$arch" -L "$binary" 2>/dev/null | grep '@executable_path/../Frameworks/' || true)
if otool -arch "$arch" -L "$binary" 2>/dev/null | grep -E '/opt/homebrew|/usr/local'; then
echo " EXTERNAL HOMEBREW DEPENDENCY ($arch, $label)"
missing_deps=1
fi
done
}
check_framework_refs "$MAIN_BIN" "Amiberry"
for dylib in "$UNI_PLUGINS"/*.dylib "$UNI_FW"/*.dylib; do
[ -f "$dylib" ] || continue
[ -L "$dylib" ] && continue
check_framework_refs "$dylib" "$(basename "$dylib")"
done
if [ "$missing_deps" = "1" ]; then
echo "::error::Some dylib references are unresolved or still point at Homebrew paths"
exit 1
fi
- name: Install the Apple certificate
env:
APPLE_DEVID_CERT_BASE64: ${{ secrets.APPLE_DEVID_CERT_BASE64 }}
APPLE_DEVID_CERT_P12_PASSWORD: ${{ secrets.APPLE_DEVID_CERT_P12_PASSWORD }}
APPLE_KEYCHAIN_PASSWORD: ${{ secrets.APPLE_KEYCHAIN_PASSWORD }}
run: |
set +x # Mask output for security
CERTIFICATE_PATH=$RUNNER_TEMP/apple_devid_cert.p12
KEYCHAIN_PATH=$RUNNER_TEMP/app-signing.keychain-db
echo -n "$APPLE_DEVID_CERT_BASE64" | base64 --decode -o $CERTIFICATE_PATH
security create-keychain -p $APPLE_KEYCHAIN_PASSWORD $KEYCHAIN_PATH
security set-keychain-settings -lut 21600 $KEYCHAIN_PATH
security unlock-keychain -p $APPLE_KEYCHAIN_PASSWORD $KEYCHAIN_PATH
security import $CERTIFICATE_PATH -P $APPLE_DEVID_CERT_P12_PASSWORD -A -t cert -f pkcs12 -k $KEYCHAIN_PATH
security set-key-partition-list -S apple-tool:,apple: -s -k $APPLE_KEYCHAIN_PASSWORD $KEYCHAIN_PATH
security list-keychains -d user -s $KEYCHAIN_PATH
- name: Codesign the dylibs
env:
CODESIGN_IDENTITY: ${{ secrets.APPLE_CODESIGN_IDENTITY }}
run: |
for file in universal-app/Amiberry.app/Contents/Frameworks/*.dylib; do
[ -f "$file" ] || continue
[ -L "$file" ] && continue
codesign -s "$CODESIGN_IDENTITY" -f -o runtime,hard "$file"
done
for file in universal-app/Amiberry.app/Contents/Resources/plugins/*.dylib; do
[ -f "$file" ] || continue
[ -L "$file" ] && continue
codesign -s "$CODESIGN_IDENTITY" -f -o runtime,hard "$file"
done
- name: Codesign the app
env:
CODESIGN_IDENTITY: ${{ secrets.APPLE_CODESIGN_IDENTITY }}
run: |
codesign -s "$CODESIGN_IDENTITY" -f -o runtime,hard --entitlements packaging/macos/Amiberry.entitlements universal-app/Amiberry.app
- name: Verify app entitlements and signature
run: |
codesign -d --entitlements :- universal-app/Amiberry.app
codesign --verify --deep --strict universal-app/Amiberry.app
echo "Signature verification passed"
- name: Create a zip to send to the notary service
run: |
ditto -c -k --keepParent universal-app/Amiberry.app Amiberry-${{ github.sha }}-macOS-universal.zip
- name: Send the file to be notarized by Apple
run: |
set -uo pipefail
ZIP="Amiberry-${{ github.sha }}-macOS-universal.zip"
# Stream notarytool output to both the log and a file, without
# letting `set -e` kill the script before we can echo the rejection.
xcrun notarytool submit "$ZIP" --wait \
--apple-id "midwan@gmail.com" \
--password ${{ secrets.APPLE_NOTARY_APP_PASSWORD }} \
--team-id ${{ secrets.APPLE_TEAM_ID }} 2>&1 | tee notary.log
STATUS=${PIPESTATUS[0]}
SUBMISSION_ID=$(awk '/id:/ {print $2; exit}' notary.log)
if [ "$STATUS" -eq 0 ] && grep -q 'status: Accepted' notary.log; then
echo "Notarization accepted."
else
echo "::error::Notarization failed (notarytool exit=$STATUS) — fetching rejection log"
if [ -n "$SUBMISSION_ID" ]; then
xcrun notarytool log "$SUBMISSION_ID" \
--apple-id "midwan@gmail.com" \
--password ${{ secrets.APPLE_NOTARY_APP_PASSWORD }} \
--team-id ${{ secrets.APPLE_TEAM_ID }} || true
fi
exit 1
fi
- name: Staple the notary receipt to the application bundle
run: |
xcrun stapler staple universal-app/Amiberry.app
rm Amiberry-${{ github.sha }}-macOS-universal.zip
- name: Create DMG package
run: |
set -euo pipefail
# Read version from CMakeLists.txt (BSD-compatible, no grep -P)
VERSION=$(sed -n 's/.*VERSION \([0-9]*\.[0-9]*\.[0-9]*\).*/\1/p' CMakeLists.txt | head -1)
PRE_RELEASE=$(sed -n 's/.*VERSION_PRE_RELEASE "\([0-9]*\)".*/\1/p' CMakeLists.txt | head -1)
if [ -n "$PRE_RELEASE" ]; then
DMG_VERSION="${VERSION}~pre${PRE_RELEASE}"
else
DMG_VERSION="${VERSION}"
fi
DMG_NAME="Amiberry-${DMG_VERSION}-macOS-universal"
# Create a staging directory for DMG contents
STAGING="dmg-staging"
rm -rf "$STAGING"
mkdir -p "$STAGING"
cp -R universal-app/Amiberry.app "$STAGING/"
ln -s /Applications "$STAGING/Applications"
# Copy background image
mkdir -p "$STAGING/.background"
cp packaging/dmg/AppDMGBackground.tiff "$STAGING/.background/background.tiff"
# Create a writable DMG, apply Finder layout/background, then compress.
RW_DMG="${DMG_NAME}-rw.dmg"
hdiutil create -volname "Amiberry" \
-srcfolder "$STAGING" \
-ov -format UDRW \
"$RW_DMG"
DEVICE=""
cleanup() {
if [ -n "$DEVICE" ]; then
hdiutil detach "$DEVICE" || true
fi
}
trap cleanup EXIT
DEVICE=$(hdiutil attach -readwrite -noverify -noautoopen "$RW_DMG" | awk '/\/Volumes\/Amiberry/ {print $1; exit}')
if [ -z "$DEVICE" ]; then
echo "Failed to attach DMG."
exit 1
fi
osascript packaging/dmg/AppDMGSetup.scpt "Amiberry"
hdiutil detach "$DEVICE"
DEVICE=""
trap - EXIT
hdiutil convert "$RW_DMG" -format UDZO -imagekey zlib-level=9 -ov -o "${DMG_NAME}.dmg"
rm -f "$RW_DMG"
rm -rf "$STAGING"
echo "DMG_NAME=${DMG_NAME}" >> "$GITHUB_ENV"
- name: Upload artifact
uses: actions/upload-artifact@v7
with:
name: amiberry-macOS-universal
path: Amiberry-*.dmg
retention-days: 7
build-ubuntu:
runs-on: ${{ matrix.runner }}
container: ${{ matrix.container }}
timeout-minutes: 30
permissions:
contents: read
actions: write
strategy:
fail-fast: false
matrix:
include:
- name: 22.04-amd64
runner: ubuntu-24.04
container: ubuntu:22.04
artifact_name: amiberry-ubuntu-22.04-amd64
sdl_source: setup-sdl
codename: jammy
extra_cmake_args: -DBUNDLE_SDL=ON
qemu_uae_asset: qemu-uae-linux-x86_64.tar.xz
- name: 24.04-amd64
runner: ubuntu-24.04
container: ubuntu:24.04
artifact_name: amiberry-ubuntu-24.04-amd64
sdl_source: setup-sdl
codename: noble
extra_cmake_args: -DBUNDLE_SDL=ON
qemu_uae_asset: qemu-uae-linux-x86_64.tar.xz
- name: 25.10-amd64
runner: ubuntu-24.04
container: ubuntu:25.10
artifact_name: amiberry-ubuntu-25.10-amd64
sdl_source: setup-sdl
codename: questing
extra_cmake_args: -DBUNDLE_SDL=ON
qemu_uae_asset: qemu-uae-linux-x86_64.tar.xz
- name: 25.10-arm64
runner: ubuntu-24.04-arm
container: ubuntu:25.10
artifact_name: amiberry-ubuntu-25.10-arm64
sdl_source: apt
codename: questing
extra_cmake_args:
qemu_uae_asset: qemu-uae-linux-aarch64.tar.xz
- name: 26.04-amd64
runner: ubuntu-24.04
container: ubuntu:26.04
artifact_name: amiberry-ubuntu-26.04-amd64
sdl_source: apt
codename: resolute
extra_cmake_args:
qemu_uae_asset: qemu-uae-linux-x86_64.tar.xz
- name: 26.04-arm64
runner: ubuntu-24.04-arm
container: ubuntu:26.04
artifact_name: amiberry-ubuntu-26.04-arm64
sdl_source: apt
codename: resolute
extra_cmake_args:
qemu_uae_asset: qemu-uae-linux-aarch64.tar.xz
steps:
- name: Install prerequisites
run: |
apt-get update
apt-get install -y sudo git gh
- name: Check out repository code
uses: actions/checkout@v6
with:
submodules: recursive
- name: Install ccache
run: sudo apt-get install -y ccache
- name: Cache ccache
uses: actions/cache@v5
with:
path: ~/.ccache
key: ${{ runner.os }}-${{ matrix.name }}-ccache-${{ github.ref }}-${{ github.sha }}
restore-keys: |
${{ runner.os }}-${{ matrix.name }}-ccache-${{ github.ref }}-
${{ runner.os }}-${{ matrix.name }}-ccache-
- name: Cache apt packages
uses: actions/cache@v5
with:
path: /var/cache/apt/archives
key: ${{ runner.os }}-${{ matrix.name }}-apt-${{ hashFiles('CMakeLists.txt', 'cmake/**/*.cmake', '.github/workflows/c-cpp.yml') }}
restore-keys: |
${{ runner.os }}-${{ matrix.name }}-apt-
- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install -y build-essential cmake ninja-build file zip libflac-dev libmpeg2-4-dev libpng-dev libasound2-dev libmpg123-dev libportmidi-dev libserialport-dev libenet-dev libpcap-dev libzstd-dev libcurl4-openssl-dev nlohmann-json3-dev libdbus-1-dev
- name: Install SDL3 and SDL3_image
if: matrix.sdl_source == 'setup-sdl'
id: sdl
# setup-sdl's v1 tag lags main; pin the reviewed main commit instead
# of tracking the mutable branch.
uses: libsdl-org/setup-sdl@4ebea449684c989388fe6bcea0460e300d13a5ae
with:
install-linux-dependencies: true
version: 3.4.10
version-sdl-image: 3.4.4
pre-release: false
- name: Install SDL3 and SDL3_image from apt
if: matrix.sdl_source == 'apt'
run: sudo apt-get install -y libsdl3-dev libsdl3-image-dev
- name: Download QEMU-UAE plugin
run: .github/scripts/download-qemu-uae-plugin.sh ${{ matrix.qemu_uae_asset }}
- name: Verify QEMU-UAE plugin dependencies
run: |
for needed in libglib-2.0.so.0 libgmodule-2.0.so.0 libz.so.1; do
readelf -d "$QEMU_UAE_PLUGIN" | grep -F "Shared library: [$needed]"
done
- name: make for Ubuntu ${{ matrix.name }} with setup-sdl
if: matrix.sdl_source == 'setup-sdl'
run: |
export CCACHE_DIR="$HOME/.ccache"
export PATH="/usr/lib/ccache:$PATH"
cmake -B build -G Ninja -DCMAKE_INSTALL_PREFIX=/usr -DCMAKE_PREFIX_PATH="${{ steps.sdl.outputs.prefix }}" -DCMAKE_C_COMPILER_LAUNCHER=ccache -DCMAKE_CXX_COMPILER_LAUNCHER=ccache -DDISTRO_CODENAME=${{ matrix.codename }} -DQEMU_UAE_PLUGIN="$QEMU_UAE_PLUGIN" ${{ matrix.extra_cmake_args }} && cmake --build build -j$(nproc)
cpack -G DEB --config build/CPackConfig.cmake
- name: make for Ubuntu ${{ matrix.name }} with apt SDL3
if: matrix.sdl_source == 'apt'
run: |
export CCACHE_DIR="$HOME/.ccache"
export PATH="/usr/lib/ccache:$PATH"
cmake -B build -G Ninja -DCMAKE_INSTALL_PREFIX=/usr -DCMAKE_C_COMPILER_LAUNCHER=ccache -DCMAKE_CXX_COMPILER_LAUNCHER=ccache -DDISTRO_CODENAME=${{ matrix.codename }} -DQEMU_UAE_PLUGIN="$QEMU_UAE_PLUGIN" && cmake --build build -j$(nproc)
cpack -G DEB --config build/CPackConfig.cmake
- name: Verify QEMU-UAE plugin in DEB
run: |
for deb in amiberry_*.deb; do
echo "Checking $deb"
dpkg-deb -c "$deb" | grep -E '/amiberry/qemu-uae\.so$'
dpkg-deb -I "$deb" control | grep -E 'Depends: .*libglib2\.0-0'
done
- name: Upload artifact
if: always() && github.ref_type != 'tag'
uses: actions/upload-artifact@v7
with:
name: ${{ matrix.artifact_name }}
path: amiberry_*.deb
retention-days: 7
- name: ZIP package for release
if: github.ref_type == 'tag'
run: zip -r ${{ matrix.artifact_name }}.zip amiberry_*.deb
- name: Upload artifact for release
if: always() && github.ref_type == 'tag'
uses: actions/upload-artifact@v7
with:
name: ${{ matrix.artifact_name }}
path: amiberry-*.zip
build-fedora:
runs-on: ${{ matrix.runner }}
timeout-minutes: 30
permissions:
contents: read
actions: write
strategy:
fail-fast: false
matrix:
include:
- name: x86_64
runner: ubuntu-24.04
image: midwan/amiberry-fedora-x86_64:latest
artifact_name: amiberry-fedora-x86_64
release_suffix: fedora-x86_64
codename: fc44
qemu_uae_asset: qemu-uae-linux-x86_64.tar.xz
- name: aarch64
runner: ubuntu-24.04-arm
image: midwan/amiberry-fedora-arm64:latest
artifact_name: amiberry-fedora-aarch64
release_suffix: fedora-aarch64
codename: fc44
qemu_uae_asset: qemu-uae-linux-aarch64.tar.xz
steps:
- uses: actions/checkout@v6
with:
submodules: recursive
- name: Download QEMU-UAE plugin
run: .github/scripts/download-qemu-uae-plugin.sh ${{ matrix.qemu_uae_asset }}
- name: Run the build process with Docker
run: |
QEMU_PLUGIN="/build/${QEMU_UAE_PLUGIN_RELATIVE}"
docker run --rm -v "${{ github.workspace }}:/build" ${{ matrix.image }} \
bash -euo pipefail -c '
QEMU_PLUGIN="$1"
test -f "$QEMU_PLUGIN"
for needed in libglib-2.0.so.0 libgmodule-2.0.so.0 libz.so.1; do
readelf -d "$QEMU_PLUGIN" | grep -F "Shared library: [$needed]"
done
cmake -B build -G Ninja -DCMAKE_INSTALL_PREFIX=/usr -DDISTRO_CODENAME=${{ matrix.codename }} -DQEMU_UAE_PLUGIN="$QEMU_PLUGIN"
cmake --build build -j$(nproc)
cpack -G RPM --config build/CPackConfig.cmake
rpm -qlp /build/amiberry-*.rpm | grep -E "/amiberry/qemu-uae\\.so$"
rpm -qpR /build/amiberry-*.rpm | grep -E "^glib2($|[ <>=])"
' bash "$QEMU_PLUGIN"
- name: Upload artifact
if: always() && github.ref_type != 'tag'
uses: actions/upload-artifact@v7
with:
name: ${{ matrix.artifact_name }}
path: amiberry-*.rpm
retention-days: 7
- name: ZIP package for release
if: github.ref_type == 'tag'
run: zip -r amiberry-${{ github.ref_name }}-${{ matrix.release_suffix }}.zip amiberry-*.rpm
- name: Upload artifact for release
if: always() && github.ref_type == 'tag'
uses: actions/upload-artifact@v7
with:
name: ${{ matrix.artifact_name }}
path: amiberry-*.zip
build-debian-amd64:
runs-on: ubuntu-24.04
timeout-minutes: 30
permissions:
contents: read
actions: write
strategy:
fail-fast: false
matrix:
include:
- name: bookworm
image: midwan/amiberry-debian-x86_64:bookworm
artifact_name: amiberry-debian-bookworm-amd64
release_name: debian-bookworm-amd64
codename: bookworm
extra_cmake_args: -DBUNDLE_SDL=ON
qemu_uae_asset: qemu-uae-linux-x86_64.tar.xz
- name: trixie
image: midwan/amiberry-debian-x86_64:trixie
artifact_name: amiberry-debian-trixie-amd64
release_name: debian-trixie-amd64
codename: trixie
extra_cmake_args:
qemu_uae_asset: qemu-uae-linux-x86_64.tar.xz
steps:
- uses: actions/checkout@v6
with:
submodules: recursive
- name: Download QEMU-UAE plugin
run: .github/scripts/download-qemu-uae-plugin.sh ${{ matrix.qemu_uae_asset }}
- name: Run the build process with Docker
run: |
QEMU_PLUGIN="/build/${QEMU_UAE_PLUGIN_RELATIVE}"
docker run --rm -v "${{ github.workspace }}:/build" ${{ matrix.image }} \
bash -euo pipefail -c '
QEMU_PLUGIN="$1"
test -f "$QEMU_PLUGIN"
for needed in libglib-2.0.so.0 libgmodule-2.0.so.0 libz.so.1; do
readelf -d "$QEMU_PLUGIN" | grep -F "Shared library: [$needed]"
done
cmake -B build -G Ninja -DCMAKE_INSTALL_PREFIX=/usr -DDISTRO_CODENAME=${{ matrix.codename }} -DQEMU_UAE_PLUGIN="$QEMU_PLUGIN" ${{ matrix.extra_cmake_args }}
cmake --build build -j$(nproc)
cpack -G DEB --config build/CPackConfig.cmake
dpkg-deb -c /build/amiberry_*.deb | grep -E "/amiberry/qemu-uae\\.so$"
dpkg-deb -I /build/amiberry_*.deb control | grep -E "Depends: .*libglib2\\.0-0"
' bash "$QEMU_PLUGIN"
- name: Upload artifact
if: always() && github.ref_type != 'tag'
uses: actions/upload-artifact@v7
with:
name: ${{ matrix.artifact_name }}
path: "amiberry_*.deb"
retention-days: 7
- name: ZIP package for release
if: github.ref_type == 'tag'
run: zip -r "amiberry-${{ github.ref_name }}-${{ matrix.release_name }}.zip" amiberry_*.deb
- name: Upload artifact for release
if: always() && github.ref_type == 'tag'
uses: actions/upload-artifact@v7
with:
name: ${{ matrix.artifact_name }}
path: "amiberry-*.zip"
build-debian-arm64:
runs-on: ubuntu-24.04
timeout-minutes: 30
permissions:
contents: read
actions: write
strategy:
fail-fast: false
matrix:
include:
- name: bookworm
image: midwan/amiberry-debian-aarch64:bookworm
artifact_name: amiberry-debian-bookworm-arm64
release_name: debian-bookworm-arm64
codename: bookworm
extra_cmake_args: -DBUNDLE_SDL=ON
qemu_uae_asset: qemu-uae-linux-aarch64.tar.xz
- name: trixie
image: midwan/amiberry-debian-aarch64:trixie
artifact_name: amiberry-debian-trixie-arm64
release_name: debian-trixie-arm64
codename: trixie
extra_cmake_args:
qemu_uae_asset: qemu-uae-linux-aarch64.tar.xz
steps:
- uses: actions/checkout@v6
with:
submodules: recursive
- name: Download QEMU-UAE plugin
run: .github/scripts/download-qemu-uae-plugin.sh ${{ matrix.qemu_uae_asset }}
- name: Run the build process with Docker
run: |
QEMU_PLUGIN="/build/${QEMU_UAE_PLUGIN_RELATIVE}"
docker run --rm -v "${{ github.workspace }}:/build" ${{ matrix.image }} \
bash -euo pipefail -c '
QEMU_PLUGIN="$1"
test -f "$QEMU_PLUGIN"
for needed in libglib-2.0.so.0 libgmodule-2.0.so.0 libz.so.1; do
readelf -d "$QEMU_PLUGIN" | grep -F "Shared library: [$needed]"
done
cmake -DCMAKE_TOOLCHAIN_FILE=cmake/Toolchain-aarch64-linux-gnu.cmake -B build -G Ninja -DCMAKE_INSTALL_PREFIX=/usr -DDISTRO_CODENAME=${{ matrix.codename }} -DQEMU_UAE_PLUGIN="$QEMU_PLUGIN" ${{ matrix.extra_cmake_args }}
cmake --build build -j$(nproc)
cpack -G DEB --config build/CPackConfig.cmake
dpkg-deb -c /build/amiberry_*.deb | grep -E "/amiberry/qemu-uae\\.so$"
dpkg-deb -I /build/amiberry_*.deb control | grep -E "Depends: .*libglib2\\.0-0"
' bash "$QEMU_PLUGIN"
- name: Upload artifact
if: always() && github.ref_type != 'tag'
uses: actions/upload-artifact@v7
with:
name: ${{ matrix.artifact_name }}
path: "amiberry_*.deb"
retention-days: 7
- name: ZIP package for release
if: github.ref_type == 'tag'
run: zip -r amiberry-${{ github.ref_name }}-${{ matrix.release_name }}.zip amiberry_*.deb
- name: Upload artifact for release
if: always() && github.ref_type == 'tag'
uses: actions/upload-artifact@v7
with:
name: ${{ matrix.artifact_name }}
path: "amiberry-*.zip"
# Windows x64: native build on windows-2025 using llvm-mingw (clang).
# Shares the toolchain with build-windows-arm64 so Windows on Arm and x64
# use a single compiler stack. Replaced the previous MSYS2/MinGW-w64 GCC
# build once the llvm-mingw shakeout was stable.
build-windows:
runs-on: windows-2025
# Cold-cache runs (vcpkg + llvm-mingw downloads) finish in ~24 min,
# warm-cache runs in ~10-15 min — see build-windows-arm64 for comparison.
# Release signing can require manual SignPath approval, so keep enough
# headroom for the build, signing round-trip, and approval window.
timeout-minutes: 120
permissions:
contents: read
actions: write
strategy:
fail-fast: false
matrix:
include:
- name: x64
artifact_name: amiberry-windows-x64
release_suffix: windows-x64
env:
LLVM_MINGW_TAG: "20260421"
LLVM_MINGW_FLAVOR: "ucrt-x86_64"
VCPKG_DEFAULT_TRIPLET: x64-mingw-dynamic
VCPKG_DEFAULT_HOST_TRIPLET: x64-mingw-dynamic
steps:
- name: Check out repository code
uses: actions/checkout@v6
with:
submodules: recursive
- name: Cache llvm-mingw toolchain
id: cache-llvm-mingw
uses: actions/cache@v5
with:
path: C:/llvm-mingw
key: llvm-mingw-${{ env.LLVM_MINGW_TAG }}-${{ env.LLVM_MINGW_FLAVOR }}
- name: Install llvm-mingw
if: steps.cache-llvm-mingw.outputs.cache-hit != 'true'
shell: pwsh
run: |
$tag = "${env:LLVM_MINGW_TAG}"
$flavor = "${env:LLVM_MINGW_FLAVOR}"
$base = "llvm-mingw-$tag-$flavor"
$url = "https://github.com/mstorsjo/llvm-mingw/releases/download/$tag/$base.zip"
Write-Host "Downloading $url"
Invoke-WebRequest -Uri $url -OutFile "$env:RUNNER_TEMP\llvm-mingw.zip"
Expand-Archive -Path "$env:RUNNER_TEMP\llvm-mingw.zip" -DestinationPath "$env:RUNNER_TEMP\llvm-mingw"
New-Item -ItemType Directory -Force -Path "C:/llvm-mingw" | Out-Null
# The archive extracts into a single subdir named $base; flatten.
Move-Item "$env:RUNNER_TEMP\llvm-mingw\$base\*" "C:/llvm-mingw" -Force
- name: Expose llvm-mingw to subsequent steps
shell: pwsh
run: |
"LLVM_MINGW_ROOT=C:/llvm-mingw" | Out-File -FilePath $env:GITHUB_ENV -Append
"C:/llvm-mingw/bin" | Out-File -FilePath $env:GITHUB_PATH -Append
- name: Bootstrap vcpkg
shell: pwsh
run: |
if (-not (Test-Path "C:/vcpkg/.git")) {
git clone --depth 1 https://github.com/microsoft/vcpkg.git C:/vcpkg
}
& C:/vcpkg/bootstrap-vcpkg.bat -disableMetrics
"VCPKG_ROOT=C:/vcpkg" | Out-File -FilePath $env:GITHUB_ENV -Append
- name: Cache vcpkg installed packages
uses: actions/cache@v5
with:
path: out/build/windows-release/vcpkg_installed
# Include LLVM_MINGW_TAG so a toolchain bump invalidates the
# cache: deps built with one CRT/runtime can be ABI-incompatible
# with binaries linked by the new toolchain (the original
# x64-mingw-dynamic + 20250910 cache showed up as
# "undefined symbol: clock_gettime64" link errors).
key: ${{ runner.os }}-x64-vcpkg-${{ env.LLVM_MINGW_TAG }}-${{ hashFiles('vcpkg.json', 'cmake/Toolchain-x86_64-w64-mingw32.cmake') }}
restore-keys: |
${{ runner.os }}-x64-vcpkg-${{ env.LLVM_MINGW_TAG }}-
- name: Download QEMU-UAE plugin
shell: pwsh
run: .github/scripts/download-qemu-uae-plugin.ps1 -Asset qemu-uae-windows-x64.zip
- name: Configure
shell: bash
run: |
cmake --preset windows-release -DQEMU_UAE_PLUGIN="$QEMU_UAE_PLUGIN" -DQEMU_UAE_PLUGIN_DIR="$QEMU_UAE_PLUGIN_DIR"
PRODUCT_VERSION="$(cat out/build/windows-release/amiberry-product-version.txt)"
if [ -z "$PRODUCT_VERSION" ]; then
echo "Could not determine the Amiberry product version from the build tree." >&2
exit 1
fi
echo "AMIBERRY_PRODUCT_VERSION=$PRODUCT_VERSION" >> "$GITHUB_ENV"
- name: Build
shell: bash
run: |
cmake --build out/build/windows-release -j$NUMBER_OF_PROCESSORS
- name: Install (portable layout)
shell: bash
run: |
rm -rf out/install/windows-release
rm -rf out/package/windows-release