-
Notifications
You must be signed in to change notification settings - Fork 8
262 lines (221 loc) · 10.4 KB
/
Copy pathbuild-avalonia.yml
File metadata and controls
262 lines (221 loc) · 10.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
name: Build Avalonia (Cross-Platform)
on:
push:
branches: [avalonia, main]
pull_request:
branches: [avalonia, main]
jobs:
build:
strategy:
fail-fast: false
matrix:
include:
- os: windows-latest
rid: win-x64
artifact: EmoTracker-win-x64
- os: ubuntu-latest
rid: linux-x64
artifact: EmoTracker-linux-x64
runs-on: ${{ matrix.os }}
env:
# Allow restoring the net10.0-windows target on non-Windows (skips WPF-specific build)
EnableWindowsTargeting: true
FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: true
steps:
- uses: actions/checkout@v4
- name: Setup .NET 10
uses: actions/setup-dotnet@v4
with:
dotnet-version: 10.0.x
- name: Publish
run: dotnet publish EmoTracker/EmoTracker.csproj --framework net10.0 --configuration Release --runtime ${{ matrix.rid }} --self-contained --output publish/raw
- name: Extract version
id: version
shell: bash
run: |
VER=$(sed -n 's/.*AssemblyFileVersion("\([^"]*\)").*/\1/p' EmoTracker/Properties/AssemblyInfo.cs)
echo "app_version=$VER" >> "$GITHUB_OUTPUT"
echo "Detected version: $VER"
- name: Create Linux tar.xz
if: startsWith(matrix.rid, 'linux')
run: |
chmod +x publish/raw/EmoTracker
cd publish/raw
tar cJf ../EmoTracker-${{ steps.version.outputs.app_version }}-${{ matrix.rid }}.tar.xz .
- name: Upload Linux artifact
if: startsWith(matrix.rid, 'linux')
uses: actions/upload-artifact@v4
with:
name: EmoTracker-${{ steps.version.outputs.app_version }}-${{ matrix.rid }}
path: publish/EmoTracker-${{ steps.version.outputs.app_version }}-${{ matrix.rid }}.tar.xz
- name: Bundle PortAudio (Windows only)
if: startsWith(matrix.rid, 'win')
shell: bash
run: |
curl -fsSL "https://github.com/spatialaudio/portaudio-binaries/raw/master/libportaudio64bit.dll" \
-o "publish/raw/portaudio.dll"
- name: Bundle libvosk (Windows only)
if: startsWith(matrix.rid, 'win')
shell: bash
run: |
VOSK_VER=$(sed -n 's/.*<PackageReference Include="Vosk" Version="\([^"]*\)".*/\1/p' EmoTracker/EmoTracker.csproj)
VOSK_CACHE=$(find ~/.nuget/packages -maxdepth 3 -path "*/vosk/${VOSK_VER}/build/lib/win-x64" -type d -print -quit 2>/dev/null)
if [ -z "$VOSK_CACHE" ]; then
echo "NuGet cache miss — downloading Vosk ${VOSK_VER} from NuGet"
curl -fsSL "https://www.nuget.org/api/v2/package/Vosk/${VOSK_VER}" -o /tmp/vosk.nupkg
mkdir -p /tmp/vosk-extract
unzip -o /tmp/vosk.nupkg -d /tmp/vosk-extract
VOSK_CACHE="/tmp/vosk-extract/build/lib/win-x64"
fi
cp "$VOSK_CACHE/libvosk.dll" publish/raw/libvosk.dll
cp "$VOSK_CACHE/libstdc++-6.dll" publish/raw/ 2>/dev/null || true
cp "$VOSK_CACHE/libwinpthread-1.dll" publish/raw/ 2>/dev/null || true
cp "$VOSK_CACHE/libgcc_s_seh-1.dll" publish/raw/ 2>/dev/null || true
echo "Bundled libvosk.dll and companion DLLs"
- name: Bundle libvosk (Linux only)
if: startsWith(matrix.rid, 'linux')
shell: bash
run: |
VOSK_VER=$(sed -n 's/.*<PackageReference Include="Vosk" Version="\([^"]*\)".*/\1/p' EmoTracker/EmoTracker.csproj)
VOSK_CACHE=$(find ~/.nuget/packages -maxdepth 3 -path "*/vosk/${VOSK_VER}/build/lib/linux-x64" -type d -print -quit 2>/dev/null)
if [ -z "$VOSK_CACHE" ]; then
echo "NuGet cache miss — downloading Vosk ${VOSK_VER} from NuGet"
curl -fsSL "https://www.nuget.org/api/v2/package/Vosk/${VOSK_VER}" -o /tmp/vosk.nupkg
mkdir -p /tmp/vosk-extract
unzip -o /tmp/vosk.nupkg -d /tmp/vosk-extract
VOSK_CACHE="/tmp/vosk-extract/build/lib/linux-x64"
fi
cp "$VOSK_CACHE/libvosk.so" publish/raw/libvosk.so
echo "Bundled libvosk.so"
- name: Stage Windows output
if: startsWith(matrix.rid, 'win')
run: |
mkdir -p "publish/EmoTracker-${{ steps.version.outputs.app_version }}-${{ matrix.rid }}"
cp -R publish/raw/* "publish/EmoTracker-${{ steps.version.outputs.app_version }}-${{ matrix.rid }}/"
- name: Upload Windows artifact
if: startsWith(matrix.rid, 'win')
uses: actions/upload-artifact@v4
with:
name: EmoTracker-${{ steps.version.outputs.app_version }}-${{ matrix.rid }}
path: publish/EmoTracker-${{ steps.version.outputs.app_version }}-${{ matrix.rid }}
build-macos:
runs-on: macos-latest
env:
EnableWindowsTargeting: true
FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: true
steps:
- uses: actions/checkout@v4
- name: Setup .NET 10
uses: actions/setup-dotnet@v4
with:
dotnet-version: 10.0.x
- name: Publish x64
run: dotnet publish EmoTracker/EmoTracker.csproj --framework net10.0 --configuration Release --runtime osx-x64 --self-contained --output publish/x64
- name: Publish arm64
run: dotnet publish EmoTracker/EmoTracker.csproj --framework net10.0 --configuration Release --runtime osx-arm64 --self-contained --output publish/arm64
- name: Extract version
id: version
run: |
VER=$(sed -n 's/.*AssemblyFileVersion("\([^"]*\)").*/\1/p' EmoTracker/Properties/AssemblyInfo.cs)
echo "app_version=$VER" >> "$GITHUB_OUTPUT"
echo "Detected version: $VER"
- name: Bundle libvosk (macOS)
run: |
VOSK_VER=$(sed -n 's/.*<PackageReference Include="Vosk" Version="\([^"]*\)".*/\1/p' EmoTracker/EmoTracker.csproj)
VOSK_CACHE=$(find ~/.nuget/packages -maxdepth 3 -path "*/vosk/${VOSK_VER}/build/lib/osx-universal" -type d -print -quit 2>/dev/null)
if [ -z "$VOSK_CACHE" ]; then
echo "NuGet cache miss — downloading Vosk ${VOSK_VER} from NuGet"
curl -fsSL "https://www.nuget.org/api/v2/package/Vosk/${VOSK_VER}" -o /tmp/vosk.nupkg
mkdir -p /tmp/vosk-extract
unzip -o /tmp/vosk.nupkg -d /tmp/vosk-extract
VOSK_CACHE="/tmp/vosk-extract/build/lib/osx-universal"
fi
for arch in x64 arm64; do
cp "$VOSK_CACHE/libvosk.dylib" "publish/${arch}/libvosk.dylib"
echo "Bundled libvosk.dylib (osx-${arch})"
done
- name: Create universal binary
run: |
mkdir -p publish/universal
# Copy arm64 as the base (all managed DLLs are identical between architectures)
cp -R publish/arm64/* publish/universal/
# Find all Mach-O binaries and create universal versions with lipo
cd publish
find arm64 -type f | while read arm64_file; do
rel="${arm64_file#arm64/}"
x64_file="x64/$rel"
universal_file="universal/$rel"
if [ ! -f "$x64_file" ]; then
continue
fi
# Check if the file is a Mach-O binary
if file "$arm64_file" | grep -q "Mach-O"; then
# Get architectures of each file
arm64_archs=$(lipo -archs "$arm64_file" 2>/dev/null || true)
x64_archs=$(lipo -archs "$x64_file" 2>/dev/null || true)
if [ "$arm64_archs" = "$x64_archs" ]; then
echo "Skipping $rel (both are $arm64_archs, already identical)"
else
echo "Creating universal binary: $rel ($arm64_archs + $x64_archs)"
lipo -create "$arm64_file" "$x64_file" -output "$universal_file"
fi
fi
done
- name: Create macOS app bundle
run: |
APP="publish/EmoTracker-osx-universal/EmoTracker.app"
mkdir -p "$APP/Contents/MacOS"
mkdir -p "$APP/Contents/Resources"
# Copy universal output into the bundle
cp -R publish/universal/* "$APP/Contents/MacOS/"
cp EmoTracker/macOS/Info.plist "$APP/Contents/"
chmod +x "$APP/Contents/MacOS/EmoTracker"
# Convert .ico to .icns for the app icon
python3 -m venv .venv
source .venv/bin/activate
pip install --quiet Pillow
python3 -c "
from PIL import Image, ImageDraw
import os
ico = Image.open('EmoTracker/emohead_icon_transparent_7h3_icon.ico')
# Extract the largest frame from the ICO
best = None
for size in sorted(ico.info.get('sizes', [(ico.width, ico.height)]), reverse=True):
ico.size = size
candidate = ico.copy().convert('RGBA')
if best is None or candidate.width > best.width:
best = candidate
src = best
iconset = 'EmoTracker.iconset'
os.makedirs(iconset, exist_ok=True)
def make_icon(src, s):
# Create black rounded-rect background, composite icon on top
bg = Image.new('RGBA', (s, s), (0, 0, 0, 0))
draw = ImageDraw.Draw(bg)
r = max(s // 5, 4)
draw.rounded_rectangle([0, 0, s - 1, s - 1], radius=r, fill=(0, 0, 0, 255))
resized = src.resize((s, s), Image.LANCZOS)
bg.paste(resized, (0, 0), resized)
return bg
sizes = [16, 32, 64, 128, 256, 512]
for s in sizes:
icon = make_icon(src, s)
icon.save(os.path.join(iconset, f'icon_{s}x{s}.png'))
if s >= 32:
half = s // 2
icon.save(os.path.join(iconset, f'icon_{half}x{half}@2x.png'))
icon = make_icon(src, 1024)
icon.save(os.path.join(iconset, 'icon_512x512@2x.png'))
"
iconutil -c icns EmoTracker.iconset -o "$APP/Contents/Resources/EmoTracker.icns"
# Ad-hoc code sign so macOS doesn't report the bundle as damaged
codesign --force --deep -s - "$APP"
- name: Create macOS tar.gz
run: |
cd publish/EmoTracker-osx-universal
tar czf ../EmoTracker-${{ steps.version.outputs.app_version }}-osx-universal.tar.gz EmoTracker.app
- name: Upload macOS artifact
uses: actions/upload-artifact@v4
with:
name: EmoTracker-${{ steps.version.outputs.app_version }}-osx-universal
path: publish/EmoTracker-${{ steps.version.outputs.app_version }}-osx-universal.tar.gz