-
Notifications
You must be signed in to change notification settings - Fork 17
442 lines (384 loc) · 15.5 KB
/
Copy pathbuild-multiplatform.yml
File metadata and controls
442 lines (384 loc) · 15.5 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
name: Build Multi-Platform
on:
push:
branches: [ master, main ]
tags:
- 'v*.*.*'
pull_request:
branches: [ master, main ]
types: [labeled]
workflow_dispatch:
jobs:
test:
if: github.event_name != 'pull_request' || contains(github.event.pull_request.labels.*.name, 'build')
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v6
- name: Setup Node.js
uses: actions/setup-node@v6
with:
node-version: '22'
- name: Test Docker configuration rendering
run: node --test docker/dotcraft/render-config.test.mjs
- name: Setup .NET
uses: actions/setup-dotnet@v5
with:
dotnet-version: '10.0.x'
- name: Restore dependencies
run: dotnet restore dotcraft.sln
- name: Run tests
run: dotnet test dotcraft.sln --configuration Release --no-restore
# The Satellite solution is Windows-only, so it cannot ride along with the Linux test job.
satellite:
if: github.event_name != 'pull_request' || contains(github.event.pull_request.labels.*.name, 'build')
runs-on: windows-latest
steps:
- name: Checkout code
uses: actions/checkout@v6
- name: Setup .NET
uses: actions/setup-dotnet@v5
with:
dotnet-version: '10.0.x'
- name: Build Satellite
run: dotnet build src/DotCraft.Satellite/DotCraft.Satellite.sln --configuration Release
- name: Run Satellite tests
run: dotnet test tests/DotCraft.Satellite.Tests/DotCraft.Satellite.Tests.csproj --configuration Release --no-build
build:
needs: test
if: github.event_name != 'pull_request' || contains(github.event.pull_request.labels.*.name, 'build')
strategy:
matrix:
include:
- os: ubuntu-latest
os_name: linux
runtime_id: linux-x64
output_name: DotCraft-linux-x64
electron_builder_args: ''
- os: windows-latest
os_name: windows
runtime_id: win-x64
output_name: DotCraft-win-x64
companion_platform: win32
companion_arch: x64
electron_builder_args: --win --x64
- os: windows-latest
os_name: windows
runtime_id: win-arm64
output_name: DotCraft-win-arm64
companion_platform: win32
companion_arch: arm64
electron_builder_args: --win --arm64
- os: macos-15-intel
os_name: macos
runtime_id: osx-x64
output_name: DotCraft-macos-x64
file_arch: x86_64
companion_platform: darwin
companion_arch: x64
electron_builder_args: --mac --x64
- os: macos-15
os_name: macos
runtime_id: osx-arm64
output_name: DotCraft-macos-arm64
file_arch: arm64
companion_platform: darwin
companion_arch: arm64
electron_builder_args: --mac --arm64
runs-on: ${{ matrix.os }}
steps:
- name: Checkout code
uses: actions/checkout@v6
- name: Setup .NET
uses: actions/setup-dotnet@v5
with:
dotnet-version: '10.0.x'
- name: Restore dependencies
run: |
dotnet restore src/DotCraft.App/DotCraft.App.csproj
dotnet restore src/DotCraft.Oratorio/DotCraft.Oratorio.csproj -r ${{ matrix.runtime_id }}
- name: Build ${{ matrix.os_name }}
run: dotnet publish src/DotCraft.App/DotCraft.App.csproj -c Release -r ${{ matrix.runtime_id }} -p:PublishProfile=ReleaseProfile -o ./publish/${{ matrix.output_name }}
- name: Build Oratorio Server for Desktop
if: runner.os != 'Linux'
run: dotnet publish src/DotCraft.Oratorio/DotCraft.Oratorio.csproj -c Release -r ${{ matrix.runtime_id }} --self-contained true -p:PublishSingleFile=true -p:IncludeNativeLibrariesForSelfExtract=true -o ./publish/oratorio-${{ matrix.runtime_id }}
- name: Verify macOS binary architectures
if: runner.os == 'macOS'
shell: bash
run: |
expected_arch="${{ matrix.file_arch }}"
file_output="$(file publish/${{ matrix.output_name }}/dotcraft)"
echo "$file_output"
if ! grep -q "dotcraft:.*Mach-O.*${expected_arch}" <<< "$file_output"; then
echo "::error::dotcraft is not a ${expected_arch} Mach-O binary"
exit 1
fi
oratorio_file_output="$(file publish/oratorio-${{ matrix.runtime_id }}/oratorio)"
echo "$oratorio_file_output"
if ! grep -q "oratorio:.*Mach-O.*${expected_arch}" <<< "$oratorio_file_output"; then
echo "::error::oratorio is not a ${expected_arch} Mach-O binary"
exit 1
fi
- name: Create archive for Linux/macOS
if: runner.os != 'Windows'
run: |
cd publish/${{ matrix.output_name }}
tar -czf ../../${{ matrix.output_name }}.tar.gz *
cd ../..
- name: Create archive for Windows
if: runner.os == 'Windows'
run: |
Compress-Archive -Path publish/${{ matrix.output_name }}/* -DestinationPath ${{ matrix.output_name }}.zip
- name: Upload artifact - Linux/macOS
if: runner.os != 'Windows'
uses: actions/upload-artifact@v6
with:
name: ${{ matrix.output_name }}
path: ${{ matrix.output_name }}.tar.gz
- name: Upload artifact - Windows
if: runner.os == 'Windows'
uses: actions/upload-artifact@v6
with:
name: ${{ matrix.output_name }}
path: ${{ matrix.output_name }}.zip
# ── Desktop (Electron) build ──────────────────────────────────────────────
- name: Setup Node.js
if: runner.os != 'Linux'
uses: actions/setup-node@v6
with:
node-version: '22'
cache: 'npm'
cache-dependency-path: |
desktop/package-lock.json
sdk/typescript/package-lock.json
- name: Install desktop dependencies
if: runner.os != 'Linux'
run: npm ci
working-directory: desktop
- name: Install Windows ARM64 optional runtime packages
if: matrix.runtime_id == 'win-arm64'
run: node scripts/install-target-optional-deps.mjs win32 arm64
working-directory: desktop
- name: Install TypeScript SDK dependencies
if: runner.os != 'Linux'
run: npm ci
working-directory: sdk/typescript
- name: Build TypeScript SDK
if: runner.os != 'Linux'
run: npm run build:all
working-directory: sdk/typescript
- name: Stage Feishu CLI companion for desktop
if: runner.os != 'Linux'
run: >-
node sdk/typescript/packages/channel-feishu/scripts/stage-official-cli.mjs
--platform ${{ matrix.companion_platform }}
--arch ${{ matrix.companion_arch }}
--output desktop/resources/modules/channel-feishu/vendor
- name: Stage embedded binary for desktop - Windows
if: runner.os == 'Windows'
shell: pwsh
run: |
New-Item -ItemType Directory -Force -Path desktop/resources/bin | Out-Null
Copy-Item -Path publish/${{ matrix.output_name }}/dotcraft.exe -Destination desktop/resources/bin/dotcraft.exe -Force
Copy-Item -Path publish/oratorio-${{ matrix.runtime_id }}/oratorio.exe -Destination desktop/resources/bin/oratorio.exe -Force
- name: Stage embedded binary for desktop - macOS
if: runner.os == 'macOS'
shell: bash
run: |
mkdir -p desktop/resources/bin
cp publish/${{ matrix.output_name }}/dotcraft desktop/resources/bin/dotcraft
cp publish/oratorio-${{ matrix.runtime_id }}/oratorio desktop/resources/bin/oratorio
chmod +x desktop/resources/bin/oratorio
- name: Stage bundled modules for desktop - Windows
if: runner.os == 'Windows'
shell: pwsh
run: |
$modules = @('channel-feishu', 'channel-qq', 'channel-wecom', 'channel-weixin', 'channel-telegram')
foreach ($mod in $modules) {
$src = "sdk/typescript/packages/$mod"
$dst = "desktop/resources/modules/$mod"
New-Item -ItemType Directory -Force -Path $dst | Out-Null
Copy-Item -Path "$src/manifest.json" -Destination "$dst/manifest.json" -Force
Copy-Item -Path "$src/package.json" -Destination "$dst/package.json" -Force
Copy-Item -Path "$src/dist" -Destination "$dst/dist" -Recurse -Force
if (Test-Path "$src/assets") {
Copy-Item -Path "$src/assets" -Destination "$dst/assets" -Recurse -Force
}
}
- name: Stage bundled modules for desktop - macOS
if: runner.os == 'macOS'
shell: bash
run: |
for mod in channel-feishu channel-qq channel-wecom channel-weixin channel-telegram; do
src="sdk/typescript/packages/$mod"
dst="desktop/resources/modules/$mod"
mkdir -p "$dst"
cp "$src/manifest.json" "$dst/manifest.json"
cp "$src/package.json" "$dst/package.json"
cp -r "$src/dist" "$dst/dist"
if [ -d "$src/assets" ]; then
cp -r "$src/assets" "$dst/assets"
fi
done
# Match build.bat: avoid stale dist confusing electron-builder; safe on fresh checkouts too.
- name: Clean desktop dist
if: runner.os != 'Linux'
shell: bash
run: rm -rf desktop/dist
- name: Build desktop app
if: runner.os != 'Linux'
run: npm run dist:package -- ${{ matrix.electron_builder_args }}
working-directory: desktop
env:
# No code signing cert in CI; skip discovery so macOS/Windows builds do not fail.
CSC_IDENTITY_AUTO_DISCOVERY: 'false'
- name: Prepare Windows artifacts
if: runner.os == 'Windows'
shell: bash
run: |
mkdir -p desktop/dist/installer
mv desktop/dist/*Setup*.exe desktop/dist/installer/ || true
- name: Upload app installer - Windows
if: runner.os == 'Windows'
uses: actions/upload-artifact@v6
with:
name: DotCraft-Installer-${{ matrix.runtime_id }}
path: desktop/dist/installer/*.exe
- name: Upload app artifacts - macOS
if: runner.os == 'macOS'
uses: actions/upload-artifact@v6
with:
name: ${{ matrix.output_name }}-dmg
path: desktop/dist/*.dmg
# ── Satellite (WinUI tray client) ─────────────────────────────────────────
- name: Build Satellite
if: runner.os == 'Windows'
run: dotnet publish src/DotCraft.Satellite/DotCraft.Satellite.csproj -c Release -r ${{ matrix.runtime_id }} -o ./publish/satellite-${{ matrix.runtime_id }}
- name: Package Satellite installer
if: runner.os == 'Windows'
shell: pwsh
env:
WINDOWS_CERT_BASE64: ${{ secrets.WINDOWS_CERT_BASE64 }}
WINDOWS_CERT_PASSWORD: ${{ secrets.WINDOWS_CERT_PASSWORD }}
run: |
dotnet tool restore
$version = (Select-Xml -Path src/DotCraft.App/DotCraft.App.csproj -XPath '//Version').Node.InnerText
$arguments = @(
'vpk', 'pack',
'--packId', 'DotCraft.Satellite',
'--packVersion', $version,
'--packDir', "./publish/satellite-${{ matrix.runtime_id }}",
'--mainExe', 'dotcraft-satellite.exe',
'--packTitle', 'DotCraft Satellite',
'--icon', 'src/DotCraft.Satellite/Assets/satellite.ico',
'--noPortable', '--delta', 'none',
'--outputDir', "./satellite-installer/${{ matrix.runtime_id }}"
)
if ($env:WINDOWS_CERT_BASE64) {
[IO.File]::WriteAllBytes("$env:RUNNER_TEMP/signing.pfx", [Convert]::FromBase64String($env:WINDOWS_CERT_BASE64))
$arguments += @('--signParams', "/fd sha256 /f `"$env:RUNNER_TEMP/signing.pfx`" /p `"$env:WINDOWS_CERT_PASSWORD`" /tr http://timestamp.digicert.com /td sha256")
}
else {
Write-Host 'No signing certificate is configured; the installer ships unsigned.'
}
dotnet @arguments
- name: Upload Satellite installer
if: runner.os == 'Windows'
uses: actions/upload-artifact@v6
with:
name: DotCraft-Satellite-${{ matrix.runtime_id }}
path: satellite-installer/${{ matrix.runtime_id }}/*Setup.exe
release:
needs: build
if: startsWith(github.ref, 'refs/tags/v')
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Checkout code
uses: actions/checkout@v6
- name: Download all artifacts
uses: actions/download-artifact@v7
with:
path: artifacts
- name: Rename artifacts with version
run: |
VERSION=${GITHUB_REF#refs/tags/}
echo "Version: $VERSION"
# Create release directory
mkdir -p release
# Rename CLI artifacts
for file in artifacts/DotCraft-*/DotCraft-*.tar.gz; do
[ -f "$file" ] || continue
target=$(basename "$file")
target=${target#DotCraft-}
target=${target%.tar.gz}
new_name="DotCraft-${VERSION}-${target}.tar.gz"
cp "$file" "release/$new_name"
echo "Renamed: $(basename "$file") -> $new_name"
done
for file in artifacts/DotCraft-*/DotCraft-*.zip; do
[ -f "$file" ] || continue
target=$(basename "$file")
target=${target#DotCraft-}
target=${target%.zip}
new_name="DotCraft-${VERSION}-${target}.zip"
cp "$file" "release/$new_name"
echo "Renamed: $(basename "$file") -> $new_name"
done
# Rename app artifacts - Windows
for file in artifacts/DotCraft-Installer-win-*/*.exe; do
[ -f "$file" ] || continue
target=$(basename "$(dirname "$file")")
target=${target#DotCraft-Installer-}
new_name="DotCraft-${VERSION}-${target}-Setup.exe"
cp "$file" "release/$new_name"
echo "Renamed: $(basename "$file") -> $new_name"
done
# Rename Satellite installers
for file in artifacts/DotCraft-Satellite-win-*/*Setup.exe; do
[ -f "$file" ] || continue
target=$(basename "$(dirname "$file")")
target=${target#DotCraft-Satellite-}
new_name="DotCraft-Satellite-${VERSION}-${target}-Setup.exe"
cp "$file" "release/$new_name"
echo "Renamed: $(basename "$file") -> $new_name"
done
# Rename app artifacts - macOS
for file in artifacts/DotCraft-macos-*-dmg/*.dmg; do
[ -f "$file" ] || continue
target=$(basename "$(dirname "$file")")
target=${target#DotCraft-}
target=${target%-dmg}
new_name="DotCraft-${VERSION}-${target}.dmg"
cp "$file" "release/$new_name"
echo "Renamed: $(basename "$file") -> $new_name"
done
echo "Final release files:"
ls -lh release/
- name: Prepare Release Notes
id: release_notes
run: |
VERSION=${GITHUB_REF#refs/tags/}
REPO=${{ github.repository }}
# Use template file when available.
if [ -f ".github/release_template.md" ]; then
sed \
-e "s|{{ VERSION }}|$VERSION|g" \
-e "s|{{ REPO }}|$REPO|g" \
-e "s|{{ CHANGELOG }}|- See auto-generated notes below.|g" \
".github/release_template.md" > "release_notes.md"
else
echo "Automatic release $VERSION" > "release_notes.md"
fi
- name: Create Release
uses: softprops/action-gh-release@v2
with:
files: release/*
body_path: release_notes.md
append_body: true
draft: false
prerelease: false
generate_release_notes: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}