-
-
Notifications
You must be signed in to change notification settings - Fork 18
708 lines (685 loc) · 26.6 KB
/
Copy pathbuild.yml
File metadata and controls
708 lines (685 loc) · 26.6 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
name: Build SnapX
on:
workflow_dispatch:
push:
branches:
- "**"
tags:
- "v[0-9]+.[0-9]+.[0-9]+"
paths-ignore:
- "**/*.md"
- "**/*.gitignore"
- "**/*.gitattributes"
permissions:
contents: read
jobs:
freebsd:
name: FreeBSD Build
runs-on: ${{matrix.os}}
continue-on-error: true # FreeBSD is not a first class citizen yet.
# Prevent Ubuntu runner starvation from regular builds. FreeBSD builds are slightly slower than normal builds.
needs: build
timeout-minutes: 50
env:
ALLOW_DOTNET_DOWNLOAD: 1
DisableGitVersionTask: 1
strategy:
fail-fast: false
matrix:
# I haven't built binaries for FreeBSD ARM64 yet. Sorry.
os: [ubuntu-24.04]
configuration:
- Release
- Debug
steps:
- name: Free Disk Space (Ubuntu)
uses: jlumbroso/free-disk-space@main
with:
# this might remove tools that are actually needed,
# if set to "true" but frees about 6 GB
tool-cache: false
# all of these default to true, but feel free to set to
# "false" if necessary for your workflow
android: false
dotnet: false
haskell: true
large-packages: false
docker-images: false
swap-storage: false
- name: Get relevant env variable names
id: envnames
run: |
envs=$(printenv \
| cut -d= -f1 \
| grep -E '^(GITHUB|CI|ALLOW|KEY|API|Disable|Git)' \
| grep -v '^GITHUB_WORKSPACE$' \
| sort \
| tr '\n' ' ')
echo "envs=$envs" >> "$GITHUB_OUTPUT"
- name: Setup FreeBSD VM
id: vm
uses: vmactions/freebsd-vm@v1
with:
envs: ${{ steps.envnames.outputs.envs }}
# usesh: true
sync: sshfs
prepare: |
pkg install -y curl bash icu terminfo-db libunwind libinotify brotli openssl lttng-ust krb5 llvm21 sqlite3 sudo patchelf git flock xorg xorg-vfbserver dbus glx-utils pciutils dmidecode cmake rust-coreutils gawk onnxruntime
mkdir -p /usr/lib/dotnet
wcurl -O /tmp/dotnet.tar.gz https://github.com/Thefrank/dotnet-freebsd-crossbuild/releases/download/v10.0.103-amd64-freebsd-14/dotnet-sdk-10.0.103-freebsd-x64.tar.gz
echo "778012ecfd32151647e109d772a253b4a0734a5bfe927d1d81b4365284463660 /tmp/dotnet.tar.gz" | sha256sum -c -
tar -xzf /tmp/dotnet.tar.gz -C /usr/lib/dotnet --strip-components=1
rm /tmp/dotnet.tar.gz
ln -sf /usr/lib/dotnet/dotnet /usr/local/bin/dotnet
ln -sf /usr/lib/dotnet/dnx /usr/local/bin/dnx 2>/dev/null || true
dotnet nuget add source https://pkgs.dev.azure.com/IFailAt/freebsd-dotnet-runtime-nightly/_packaging/freebsd-dotnet/nuget/v3/index.json --name freebsd-dotnet
find /usr/lib/dotnet/packs \( -name "ilc" -o -name "crossgen2" \) -exec chmod +x {} +
wcurl -O /tmp/libskiasharp.pkg https://github.com/SnapXL/freebsd-libskiasharp3/releases/download/3.119.1/libskiasharp-3.119.1_1-amd64.pkg
echo "3e041526f3f9b28ecab3a5adf86de0eb3f66f12ff5407867040dce4648aecb7c /tmp/libskiasharp.pkg" | sha256sum -c -
pkg install -y /tmp/libskiasharp.pkg
rm /tmp/libskiasharp.pkg
for f in /usr/local/bin/uu*; do mv -f "$f" "/usr/local/bin/${f##*/uu}"; done
ln -sf /usr/local/bin/gawk /usr/local/bin/awk
# Install pre compiled FreeBSD FFmpeg 8 (amd64 ONLY)
curl -fsSL https://github.com/Thefrank/ffmpeg-static-freebsd/releases/download/v8.0/ffmpeg -o /usr/local/bin/ffmpeg
echo "5aa91471cf9c56af033b451fe5c3cb56769eb33f4f6824aabf22551bbfb0f625 /usr/local/bin/ffmpeg" | sha256sum -c -
chmod +x /usr/local/bin/ffmpeg
curl -fsSL https://svn.exactcode.de/t2/trunk/package/xorg/xorg-server/xvfb-run.sh -o /usr/local/bin/xvfb-run
echo "68902b9151219d0e954306d3dc309cee3924cd17b92349acfe3f05fdeaf0e71c /usr/local/bin/xvfb-run" | sha256sum -c -
chmod +x /usr/local/bin/xvfb-run
chsh -s /usr/local/bin/bash
pw useradd runner -m -s /usr/local/bin/bash
pw groupmod wheel -m runner
echo 'runner ALL=(ALL) NOPASSWD: ALL' >> /usr/local/etc/sudoers.d/runner
chmod 440 /usr/local/etc/sudoers.d/runner
echo "Runner user created with sudo privileges."
# Ensure bash profile exists
install -d -o runner -g runner /home/runner
- name: Ready VM
shell: freebsd {0}
run: |
printenv | grep -E '^(GITHUB|CI|ALLOW)' | while IFS= read -r line; do
echo "export $line" >> /etc/profile.d/github-envs.sh
done
workspace="$GITHUB_WORKSPACE"
chown -R runner:runner "$workspace"
# Make runner auto-cd to the workspace
echo "cd \"$workspace\"" >> ~/.profile
echo "cd \"$workspace\"" >> /home/runner/.bash_profile
chown runner:runner /home/runner/.bash_profile
# sudo -u runner bash
- name: Checkout repository
shell: freebsd {0}
run: |
cd "$GITHUB_WORKSPACE"
sudo -u runner bash
mkdir -p /tmp/repo
git config --global --add safe.directory "$GITHUB_WORKSPACE"
git config --global --add safe.directory /tmp/repo
git clone --branch "$GITHUB_REF_NAME" "$GITHUB_SERVER_URL/$GITHUB_REPOSITORY.git" /tmp/repo
cp -R /tmp/repo/. "$GITHUB_WORKSPACE"
rm -rf /tmp/repo
git reset --hard "$GITHUB_SHA"
git config user.name "${GITHUB_ACTOR}"
git config user.email "${GITHUB_ACTOR}@users.noreply.github.com"
- name: Download API keys
env:
API_KEYS: ${{ secrets.API_KEYS }}
if: env.API_KEYS != ''
shell: bash
run: |
set -euo pipefail
curl -fsSL "$API_KEYS" -o SnapX.Core/Upload/APIKeysLocal.cs
- name: Remove version requirement
shell: freebsd {0}
run: |
cd $GITHUB_WORKSPACE;
rm global.json
mkdir -p build/obj
- name: Install GitVersion
uses: gittools/actions/gitversion/setup@v4.4.2
with:
versionSpec: "6.5.x"
- name: Run GitVersion
uses: gittools/actions/gitversion/command@v4.4.2
with:
arguments: '/output file /outputfile "build/obj/gitversion.json"'
- name: Update project files with GitVersion
uses: gittools/actions/gitversion/command@v4.4.2
with:
arguments: "/updateprojectfiles"
- name: Copy GitVersion data
shell: freebsd {0}
run: |
cd $GITHUB_WORKSPACE;
sudo -u runner bash
for dir in SnapX*/; do
[ -d "$dir" ] || continue
mkdir -p "$dir/obj"
cp build/obj/gitversion.json "$dir/obj/"
done
- name: Publish
shell: freebsd {0}
run: |
cd $GITHUB_WORKSPACE;
rm -rf .git # GitVersion keeps being a pain in the ass.
sudo -u runner bash build.sh --configuration ${{ matrix.configuration }}
- name: Embed extra libraries
shell: freebsd {0}
run: |
cd $GITHUB_WORKSPACE;
cp /usr/local/lib/libsqlite3.so /usr/local/lib/libonnxruntime.so /usr/local/lib/libonnxruntime_providers_shared.so /usr/local/lib/libSkiaSharp.so /usr/local/lib/libHarfBuzzSharp.so Output/snapx-ui/
- name: Tarball
shell: freebsd {0}
run: |
cd $GITHUB_WORKSPACE;
sudo -u runner bash build.sh tarball --configuration ${{ matrix.configuration }} --assembly snapx-ui
- name: Upload artifact
uses: actions/upload-artifact@v7
with:
name: SnapX-UI-${{ matrix.configuration }}-FreeBSD-${{ runner.arch }}
path: "SnapX-UI*"
if-no-files-found: error
alpine:
name: Alpine Build
runs-on: ${{matrix.os}}
needs: build
timeout-minutes: 50
env:
ALLOW_DOTNET_DOWNLOAD: 1
strategy:
fail-fast: false
matrix:
os: [ ubuntu-24.04, ubuntu-24.04-arm ]
configuration:
- Release
- Debug
steps:
- uses: actions/checkout@v6
with:
fetch-depth: 0
- name: Setup Alpine Linux
uses: bgilbert/setup-alpine@aarch64
with:
packages: >
clang
curl
bash
build-base
sudo
git
libunwind-dev
libunwind-static
xz-dev
xz-static
zlib-dev
icu-libs
patchelf
zstd
tar
uutils-coreutils
onnxruntime
- name: Symlink ONNXRuntime
run: sudo ln -sf /usr/lib/libonnxruntime.so.1 /usr/lib/libonnxruntime.so
shell: alpine.sh {0}
- name: Download API keys
env:
API_KEYS: ${{ secrets.API_KEYS }}
if: env.API_KEYS != ''
shell: alpine.sh {0}
run: |
set -euo pipefail
curl -fsSL "$API_KEYS" -o SnapX.Core/Upload/APIKeysLocal.cs
- name: Remove version requirement
run: rm global.json
shell: alpine.sh {0}
- name: Publish
# NativeAOT builds on Alpine Linux seem to be broken and complain about Call from invalid thread
# I do not have enough time on my deadline to deal with this properly, so...
run: ./build.sh --configuration ${{ matrix.configuration }} --extra-args="-p:PublishAot=false"
shell: alpine.sh {0}
- name: Embed ONNXRuntime
run: cp -pv /usr/lib/libonnxruntime.so /usr/lib/libonnxruntime_providers_shared.so Output/snapx-ui/
shell: alpine.sh {0}
- name: Tarball
run: ./build.sh tarball --configuration ${{ matrix.configuration }} --assembly snapx-ui
shell: alpine.sh {0}
- name: Upload artifact
uses: actions/upload-artifact@v7
with:
name: SnapX-UI-${{ matrix.configuration }}-${{ runner.os }}-musl-${{ runner.arch }}
path: "SnapX-UI*"
if-no-files-found: error
rpms:
name: RPMs
runs-on: ${{matrix.os}}
# Building the RPMs causes Ubuntu runner starvation due to it triggering multiple jobs. Normal builds take priority.
# needs: build
timeout-minutes: 360
container:
image: ${{ matrix.container }}
env:
ALLOW_DOTNET_DOWNLOAD: 1
strategy:
fail-fast: false
matrix:
os: [ubuntu-24.04, ubuntu-24.04-arm]
container: [fedora:42]
steps:
- uses: actions/checkout@v6
with:
fetch-depth: 0
- name: Setup environment
run: |
dnf -y upgrade --refresh
dnf -y install git rpmdevtools rpm-build libicu
- name: Build RPM
id: build_rpm
env:
API_KEYS: ${{ secrets.API_KEYS }}
run: |
cd packaging
VERSION_STRING=$(../build.sh --version | tail -n1 | tr -d '\n')
DEFINES=(
--define "passed_version ${VERSION_STRING}"
--define "github_repo ${{ github.repository }}"
--define "github_sha ${{ github.sha }}"
)
dnf builddep -y snapx.spec "${DEFINES[@]}"
spectool -g -R snapx.spec "${DEFINES[@]}"
rpmdev-setuptree
rpmbuild -ba snapx.spec "${DEFINES[@]}" | tee rpmbuild.log
grep '^Wrote:' rpmbuild.log | awk '{print $2}' > rpm_files.txt
mkdir -p rpm-artifacts
while IFS= read -r file; do
if [[ "$file" == *.rpm ]]; then
cp "$file" rpm-artifacts/
fi
done < rpm_files.txt
echo "rpm_paths=$(paste -sd ' ' rpm_files.txt)" >> $GITHUB_OUTPUT
- name: Format Container Name
id: format
run: |
CONTAINER_NAME="${{ matrix.container }}"
formattedName=$(echo "${CONTAINER_NAME}" | awk -F: '{
printf "%s", toupper(substr($1,1,1)) tolower(substr($1,2)) "-" toupper(substr($2,1,1)) tolower(substr($2,2))
}')
echo "formattedName=${formattedName}" >> "$GITHUB_OUTPUT"
- name: Upload artifact (RPM - Release on Linux)
uses: actions/upload-artifact@v7
with:
name: SnapX-RPM-${{ steps.format.outputs.formattedName }}-${{ runner.arch }}
path: packaging/rpm-artifacts/
if-no-files-found: error
ubuntu:
name: DEB/Snap Build
runs-on: ${{matrix.os}}
# needs: build
timeout-minutes: 50
permissions:
packages: write
strategy:
fail-fast: false
matrix:
# os: [ ubuntu-latest, ubuntu-24.04-arm ]
include:
- os: ubuntu-latest
arch: X64
- os: ubuntu-24.04-arm
arch: ARM64
env:
API_KEYS: ${{ secrets.API_KEYS }}
steps:
- uses: actions/checkout@v6
with:
fetch-depth: 0
- name: Free Disk Space (Ubuntu)
uses: jlumbroso/free-disk-space@main
with:
# this might remove tools that are actually needed,
# if set to "true" but frees about 6 GB
tool-cache: false
# all of these default to true, but feel free to set to
# "false" if necessary for your workflow
android: true
dotnet: false
haskell: true
large-packages: false
docker-images: false
swap-storage: false
- name: Download API keys
env:
API_KEYS: ${{ secrets.API_KEYS }}
if: env.API_KEYS != ''
shell: bash
run: |
set -euo pipefail
curl -fsSL "$API_KEYS" -o SnapX.Core/Upload/APIKeysLocal.cs
- name: Grab pretty OS name
id: osname
run: |
. /etc/os-release
echo "prettyName=${NAME// /-}-${VERSION_ID}" >> "$GITHUB_OUTPUT"
- name: Setup environment
if: matrix.pretty_arch == ''
run: |
sudo apt update
sudo apt -y install git gpg snapd
sudo snap install snapcraft --classic
sudo bash -c "$(curl -fsSL https://pacstall.dev/q/install)"
- name: Build Deb
if: matrix.pretty_arch == ''
working-directory: packaging
run: |
pacstall -B -K -I -P -Q snapx.pacscript
- name: Build Snap
id: build_snap # Add this ID
if: matrix.pretty_arch == ''
working-directory: packaging
run: |
sudo snapcraft pack --destructive-mode
SNAP_PATH=$(ls *.snap | head -n 1)
echo "snap_file=packaging/$SNAP_PATH" >> $GITHUB_OUTPUT
- name: Upload artifact (DEB)
uses: actions/upload-artifact@v7
with:
name: SnapX-DEB-${{steps.osname.outputs.prettyName}}-${{ matrix.arch }}
path: packaging/*.deb
if-no-files-found: error
- name: Upload artifact (Snap)
uses: actions/upload-artifact@v7
with:
name: SnapX-Snap-${{ matrix.pretty_arch || matrix.arch }}
path: ${{ steps.build_snap.outputs.snap_file }}
if-no-files-found: error
generate-sources:
name: Generate Flatpak Sources (${{ matrix.variant.arch }})
runs-on: ${{ matrix.variant.runner }}
# needs: build
permissions:
contents: write
strategy:
matrix:
variant:
- arch: x86_64
runner: ubuntu-24.04
- arch: aarch64
runner: ubuntu-24.04-arm
outputs:
artifact-name: flatpak-sources-${{ matrix.variant.arch }}
steps:
- name: Checkout code
uses: actions/checkout@v6
with:
fetch-depth: 0
- name: Setup dotnet
uses: actions/setup-dotnet@v5
with:
dotnet-version: 10.x.x
- name: 🔷 Update Flatpak Sources
run: |
sudo apt update
sudo apt install -y flatpak flatpak-builder
flatpak remote-add --if-not-exists --user flathub https://dl.flathub.org/repo/flathub.flatpakrepo
flatpak install --user -y org.freedesktop.Sdk//25.08 org.freedesktop.Sdk.Extension.dotnet10//25.08
dotnet tool install --global Nickvision.FlatpakGenerator
Nickvision.FlatpakGenerator generate -i SnapX.Avalonia/SnapX.Avalonia.csproj -o packaging/flathub/sources.json --destination-name vendor -s false -u
./packaging/flathub/update_hashes.sh # Script to fix possible bug in FlatpakGenerator that affects Avalonia
Nickvision.FlatpakGenerator generate -i build/build.csproj -o packaging/flathub/build-sources.json --destination-name vendor -s false -u
- name: 🌐 Upload Sources
uses: actions/upload-artifact@v7
with:
name: flatpak-sources-${{ matrix.variant.arch }}
path: packaging/flathub/*.json
- name: Commit file
uses: tohgarashi/verified-commit@v2.x
if: ${{ runner.arch == 'X64' && !startsWith(github.ref, 'refs/heads/dep/') }}
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
files: |
packaging/flathub/sources.json
packaging/flathub/build-sources.json
commit-message: "build(flathub): update nuget vendor sources [skip ci]"
flatpak:
name: Flatpak (${{ matrix.variant.arch }})
needs: generate-sources
runs-on: ${{ matrix.variant.runner }}
container:
image: ghcr.io/flathub-infra/flatpak-github-actions:gnome-49
options: --privileged
volumes:
- /usr/local:/host/usr/local
strategy:
matrix:
variant:
- arch: x86_64
runner: ubuntu-24.04
- arch: aarch64
runner: ubuntu-24.04-arm
steps:
- name: Checkout
uses: actions/checkout@v6
with:
fetch-depth: 0
- name: Free Disk Space (Ubuntu)
run: |
# remove tool cache: about 8.5GB (github has host /opt/hostedtoolcache mounted as /__t)
rm -rf /__t/* || true
# remove Haskell runtime: about 6.3GB (host /usr/local/.ghcup6.3GB (host /usr/local/.ghcup)
rm -rf /host/usr/local/.ghcup || true
# remove Android library: about 7.8GB (host /usr/local/lib/android)
rm -rf /host/usr/local/lib/android || true
- name: Download Generated Sources
uses: actions/download-artifact@v8
with:
name: flatpak-sources-${{ matrix.variant.arch }}
path: packaging/flathub/
- name: Download API keys
env:
API_KEYS: ${{ secrets.API_KEYS }}
if: env.API_KEYS != ''
shell: bash
run: |
set -euo pipefail
curl -fsSL "$API_KEYS" -o SnapX.Core/Upload/APIKeysLocal.cs
- name: Prepare Flatpak build directory
run: |
# Copy flatpak files to workspace root, preserving directory structure
cp -r packaging/flathub/* . || true
cp -r packaging/flathub/.* . 2>/dev/null || true
sed -i 's|^\([[:space:]]*[^:[:space:]]*:[[:space:]]*\)\.\./.*|\1./|g' io.github.SnapXL.SnapX.yml
- name: Build
uses: flatpak/flatpak-github-actions/flatpak-builder@v6
with:
arch: ${{ matrix.variant.arch }}
bundle: io.github.SnapXL.SnapX.flatpak
manifest-path: io.github.SnapXL.SnapX.yml
cache-key: flatpak-builder-${{ matrix.variant.arch }}-${{ github.sha }}
build:
name: Build
runs-on: ${{matrix.os}}
timeout-minutes: 50
permissions:
contents: write
strategy:
fail-fast: false
matrix:
os:
[
ubuntu-24.04,
ubuntu-24.04-arm,
macos-15,
macos-15-intel,
windows-2025,
windows-11-arm,
]
configuration:
- Release
- Debug
exclude:
- os: windows-11-arm
configuration: Debug
env:
SOLUTION_FILE_PATH: SnapX.slnx
ASSEMBLY_INFO_PATH: Directory.build.props
steps:
- name: Checkout
uses: actions/checkout@v6
with:
fetch-depth: 0
- name: Free Disk Space (Ubuntu)
if: runner.os == 'Linux'
uses: jlumbroso/free-disk-space@main
with:
# this might remove tools that are actually needed,
# if set to "true" but frees about 6 GB
tool-cache: false
# all of these default to true, but feel free to set to
# "false" if necessary for your workflow
android: true
dotnet: false
haskell: true
large-packages: false
docker-images: false
swap-storage: false
- name: Setup dotnet
uses: actions/setup-dotnet@v5
with:
dotnet-version: 10.x.x
- name: Restore
run: dotnet restore --packages ./vendor SnapX.slnx
- name: Restore build project
run: dotnet restore --packages ./vendor build/build.csproj
- name: Cache .NET NuGet packages
if: runner.os != 'macOS'
uses: actions/cache@v5
with:
path: vendor
key: ${{ runner.os }}-${{ runner.arch }}-nuget-${{ hashFiles('**/*.csproj') }}
restore-keys: |
${{ runner.os }}-${{ runner.arch }}-nuget-
- name: Install Build Linux Deps
if: runner.os == 'Linux'
run: "sudo add-apt-repository -y ppa:kisak/kisak-mesa && sudo add-apt-repository -y ppa:ubuntuhandbook1/ffmpeg8 && sudo apt update && sudo apt install -y clang zlib1g-dev patchelf xorg ffmpeg mesa-utils pciutils dmidecode xvfb"
# - name: Build & Install msquic
# if: runner.os == 'Linux'
# run: |
# git clone --branch v2.5.6 --recursive https://github.com/microsoft/msquic.git
# cd msquic
# cmake -S . -B build -DCMAKE_INSTALL_PREFIX=/usr
# cmake --build build --parallel
# sudo cmake --install build
- name: Install xmlstarlet
if: matrix.configuration == 'Debug' && runner.os == 'Linux'
run: sudo apt install -y xmlstarlet
- name: Prepare Fallback Version
id: prep_version
if: matrix.configuration == 'Debug' && runner.os == 'Linux' && runner.arch == 'X64' && always()
run: |
raw_version=$(./build.sh --version | grep -Eo '^[0-9]+\.[0-9]+\.[0-9]+(-[A-Za-z0-9.\+]+)?')
fallback_version=$(echo "$raw_version" | sed 's/-.*//')
sed -i "s|<Version>.*</Version>|<Version>${fallback_version}</Version>|" Directory.Build.props
echo "version=$fallback_version" >> "$GITHUB_OUTPUT"
if ! git diff --quiet Directory.Build.props; then
echo "changed=true" >> "$GITHUB_OUTPUT"
else
echo "changed=false" >> "$GITHUB_OUTPUT"
fi
- name: Commit fallback version
if: steps.prep_version.outputs.changed == 'true'
uses: tohgarashi/verified-commit@v2.x
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
files: Directory.Build.props
commit-message: "chore(release): update fallback version to ${{ steps.prep_version.outputs.version }}"
- name: 🛠 Generate NuGet.config
if: matrix.configuration == 'Debug' && runner.os == 'Linux'
run: |
printf '%s\n' \
'<?xml version="1.0" encoding="utf-8"?>' \
'<configuration>' \
' <packageSources>' \
' <clear />' \
' <add key="Local" value="vendor" />' \
' </packageSources>' \
'</configuration>' > NuGet.config
- name: 🛠 Ensure RestorePackagesPath in Directory.Build.props
if: matrix.configuration == 'Debug' && runner.os == 'Linux'
run: |
FILE="Directory.Build.props"
PATH_NODE="//Project/PropertyGroup/RestorePackagesPath"
# If file exists and node is missing, insert it
if [ -f "$FILE" ]; then
if ! xmlstarlet sel -t -v "$PATH_NODE" "$FILE" 2>/dev/null | grep -q .; then
echo "🔧 Inserting <RestorePackagesPath>vendor</RestorePackagesPath>..."
xmlstarlet ed --inplace \
-s "//Project/PropertyGroup[1]" -t elem -n "RestorePackagesPath" -v "vendor" \
"$FILE"
else
echo "✅ RestorePackagesPath already set."
fi
else
echo "❌ Directory.Build.props does not exist. Cannot insert RestorePackagesPath for Vendored build. Build will FAIL."
exit 1
fi
# Packagers: This vendored source does not have the APIKeys SnapX uses.
# I cannot provide them in public source code.
- name: Upload Source With Dependencies
if: matrix.configuration == 'Debug' && runner.os == 'Linux'
uses: actions/upload-artifact@v7
with:
name: SnapX-Vendored-Source-${{ runner.arch }}
path: .
include-hidden-files: false
- name: Download API keys
env:
API_KEYS: ${{ secrets.API_KEYS }}
if: env.API_KEYS != ''
shell: bash
run: |
set -euo pipefail
curl -fsSL "$API_KEYS" -o SnapX.Core/Upload/APIKeysLocal.cs
# - name: Enforce code style using dotnet format
# if: matrix.configuration == 'Debug' && runner.os == 'Linux' && runner.arch == 'X64'
# run: |
# dotnet format --verify-no-changes -v diagnostic SnapX.slnx \
# --include $(find . -type f -name '*.cs' ! -path './build/*' ! -path './SnapX.Core/Upload/APIKeysLocal.cs')
- name: Publish
shell: bash
run: ./build.sh --configuration ${{ matrix.configuration }}
- name: Assemble SnapX UI Tarball
shell: bash
run: "./build.sh tarball --assembly snapx-ui"
- name: Install WIXToolset
if: runner.os == 'Windows' && matrix.configuration == 'Release'
run: |
dotnet tool install --global wix --version 6.0.2
wix.exe extension add -g WixToolset.UI.wixext/6.0.2
- name: Assemble MSI
if: runner.os == 'Windows' && matrix.configuration == 'Release'
run: "./build.ps1 msi"
# - name: Assemble MSIX
# if: runner.os == 'Windows' && matrix.configuration == 'Release'
# run: "./build.ps1 msix"
- name: Upload MSI
if: runner.os == 'Windows' && matrix.configuration == 'Release'
uses: actions/upload-artifact@v7
with:
name: SnapX-UI-MSI-${{ runner.arch }}
path: "packaging/*.msi"
if-no-files-found: error
# - name: Upload MSIX
# if: runner.os == 'Windows' && matrix.configuration == 'Release'
# uses: actions/upload-artifact@v6
# with:
# name: SnapX-UI-MSIX-${{ runner.arch }}
# path: "packaging/*.msix"
# if-no-files-found: error
- name: Upload artifact
uses: actions/upload-artifact@v7
with:
name: SnapX-UI-${{ matrix.configuration }}-${{ runner.os }}-${{ runner.arch }}
path: "SnapX-UI*"
if-no-files-found: error