-
Notifications
You must be signed in to change notification settings - Fork 6
750 lines (652 loc) · 28.3 KB
/
Copy pathbuild.yml
File metadata and controls
750 lines (652 loc) · 28.3 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
name: Build and Release Applications
on:
push:
branches:
- develop
workflow_dispatch:
env:
FLUTTER_VERSION: '3.44.0'
STRAVA_CLIENT_ID: ${{ secrets.STRAVA_CLIENT_ID }}
STRAVA_CLIENT_SECRET: ${{ secrets.STRAVA_CLIENT_SECRET }}
INTERVALS_CLIENT_ID: ${{ secrets.INTERVALS_CLIENT_ID }}
INTERVALS_CLIENT_SECRET: ${{ secrets.INTERVALS_CLIENT_SECRET }}
permissions:
contents: write
pull-requests: write
jobs:
prepare:
runs-on: ubuntu-latest
outputs:
version: ${{ steps.set_version.outputs.version }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
# Download and extract latest SmartSpin2k firmware.bin from GitHub release
- name: Download and extract latest SmartSpin2k firmware
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
set -e
mkdir -p assets
# Get latest release info
release_json=$(curl -s -H "Authorization: token $GITHUB_TOKEN" \
https://api.github.com/repos/doudar/SmartSpin2k/releases/latest)
# Find .bin.zip asset URL
asset_url=$(echo "$release_json" | grep 'browser_download_url' | grep '.bin.zip' | head -n1 | cut -d '"' -f4)
if [ -z "$asset_url" ]; then
echo "No .bin.zip asset found in latest release!" >&2
exit 1
fi
echo "Downloading: $asset_url"
curl -L -o /tmp/firmware.zip "$asset_url"
unzip -o /tmp/firmware.zip -d /tmp/firmware_extracted
if [ ! -f /tmp/firmware_extracted/firmware.bin ]; then
echo "firmware.bin not found in zip!" >&2
exit 1
fi
mv /tmp/firmware_extracted/firmware.bin assets/firmware.bin
echo "Firmware placed at assets/firmware.bin"
# Extract version tag and write to assets/version.txt
version_tag=$(echo "$release_json" | grep '"tag_name"' | head -n1 | cut -d '"' -f4)
if [ -z "$version_tag" ]; then
echo "No version tag found in release!" >&2
exit 1
fi
echo "$version_tag" > assets/version.txt
echo "Version written to assets/version.txt: $version_tag"
# Commit and push firmware.bin and version.txt to the repository
- name: Commit, push, and open PR for updated firmware and version
if: github.ref == 'refs/heads/develop' || github.ref == 'refs/heads/main'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
set -e
git config --global user.name "github-actions[bot]"
git config --global user.email "github-actions[bot]@users.noreply.github.com"
git fetch origin
git checkout ${{ github.ref_name }}
git add assets/firmware.bin assets/version.txt
if git diff --cached --quiet; then
echo "No changes to commit."
exit 0
fi
git commit -m "chore: update firmware.bin and version.txt from latest SmartSpin2k release"
# Try to push to the current branch (will fail if protected)
if git push origin HEAD:${{ github.ref_name }}; then
echo "Pushed directly to ${{ github.ref_name }}."
exit 0
fi
# If push fails, create a new branch and open a PR
update_branch="auto/firmware-update-$(date +%Y%m%d%H%M%S)"
git checkout -b "$update_branch"
git push origin "$update_branch"
echo "Creating pull request to ${{ github.ref_name }}..."
# Install GitHub CLI if not present
if ! command -v gh >/dev/null 2>&1; then
echo "Installing GitHub CLI..."
sudo apt-get update && sudo apt-get install -y gh
fi
# Use GH_TOKEN for authentication (no gh auth login needed in CI)
gh pr create --base "${{ github.ref_name }}" --head "$update_branch" --title "chore: update firmware.bin and version.txt from latest SmartSpin2k release" --body "Automated update of firmware.bin and version.txt from the latest SmartSpin2k release."
- name: Extract version from pubspec.yaml
id: extract_version
run: |
VERSION=$(grep 'version: ' pubspec.yaml | sed 's/version: //' | xargs)
echo "VERSION=${VERSION}" >> $GITHUB_ENV
- name: Check if tag exists
id: check_tag
run: |
TAG_EXISTS=$(git tag -l "$VERSION")
if [[ "$TAG_EXISTS" == "$VERSION" ]]; then
SUFFIX=1
NEW_TAG="$VERSION-$SUFFIX"
while [[ $(git tag -l "$NEW_TAG") == "$NEW_TAG" ]]; do
SUFFIX=$((SUFFIX+1))
NEW_TAG="$VERSION-$SUFFIX"
done
echo "NEW_TAG=$NEW_TAG" >> $GITHUB_ENV
else
echo "NEW_TAG=$VERSION" >> $GITHUB_ENV
fi
- name: Set output
id: set_version
run: echo "version=$NEW_TAG" >> "$GITHUB_OUTPUT"
build-android:
needs: prepare
runs-on: ubuntu-latest
env:
GRADLE_OPTS: -Dorg.gradle.vfs.watch=false
steps:
- uses: actions/checkout@v4
- name: Setup Java
uses: actions/setup-java@v4
with:
java-version: '21'
distribution: 'temurin'
- name: Setup Flutter
uses: subosito/flutter-action@v2
with:
flutter-version: ${{ env.FLUTTER_VERSION }}
channel: stable
cache: true
- name: Accept Android SDK licenses
shell: bash
run: |
yes | sdkmanager --licenses || true
sdkmanager --install "platforms;android-36" "build-tools;36.0.0" || true
- name: Create env.local.dart
env:
STRAVA_CLIENT_ID: ${{ secrets.STRAVA_CLIENT_ID }}
STRAVA_CLIENT_SECRET: ${{ secrets.STRAVA_CLIENT_SECRET }}
INTERVALS_CLIENT_ID: ${{ secrets.INTERVALS_CLIENT_ID }}
INTERVALS_CLIENT_SECRET: ${{ secrets.INTERVALS_CLIENT_SECRET }}
run: |
mkdir -p lib/config
umask 077
cat > lib/config/env.local.dart <<EOL
class Environment {
static const String stravaClientId = '${STRAVA_CLIENT_ID}';
static const String stravaClientSecret = '${STRAVA_CLIENT_SECRET}';
static const String intervalsClientId = '${INTERVALS_CLIENT_ID}';
static const String intervalsClientSecret = '${INTERVALS_CLIENT_SECRET}';
static bool get hasStravaConfig =>
stravaClientId.isNotEmpty && stravaClientSecret.isNotEmpty;
static bool get hasIntervalsConfig =>
intervalsClientId.isNotEmpty && intervalsClientSecret.isNotEmpty;
}
EOL
- name: Configure Android signing
env:
SIGNING_KEY: ${{ secrets.SIGNING_KEY }}
KEY_STORE_PASSWORD: ${{ secrets.KEY_STORE_PASSWORD }}
KEY_ALIAS: ${{ secrets.KEY_ALIAS }}
KEY_PASSWORD: ${{ secrets.KEY_PASSWORD }}
run: |
if [ -z "$SIGNING_KEY" ]; then
echo "No signing key provided; using debug signing."
exit 0
fi
echo "$SIGNING_KEY" | base64 -d > android/app/release.keystore
echo "KEYSTORE_PATH=$PWD/android/app/release.keystore" >> $GITHUB_ENV
echo "KEY_STORE_PASSWORD=$KEY_STORE_PASSWORD" >> $GITHUB_ENV
echo "KEY_ALIAS=$KEY_ALIAS" >> $GITHUB_ENV
echo "KEY_PASSWORD=$KEY_PASSWORD" >> $GITHUB_ENV
- name: Build Android APK
run: flutter build apk
- name: Create artifacts
run: |
mkdir -p artifacts
mv build/app/outputs/flutter-apk/app-release.apk artifacts/ss2kconfigapp-${{ needs.prepare.outputs.version }}.apk
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: android-artifacts
path: artifacts/
build-macos:
needs: prepare
runs-on: macos-latest
steps:
- uses: actions/checkout@v4
- name: Setup Flutter
uses: subosito/flutter-action@v2
with:
flutter-version: ${{ env.FLUTTER_VERSION }}
channel: stable
cache: true
# Debug environment variables
- name: Debug Environment Variables
run: |
echo "Checking environment variables (secrets will be masked):"
env | grep -i STRAVA || true
- name: Create env.local.dart
env:
STRAVA_CLIENT_ID: ${{ secrets.STRAVA_CLIENT_ID }}
STRAVA_CLIENT_SECRET: ${{ secrets.STRAVA_CLIENT_SECRET }}
INTERVALS_CLIENT_ID: ${{ secrets.INTERVALS_CLIENT_ID }}
INTERVALS_CLIENT_SECRET: ${{ secrets.INTERVALS_CLIENT_SECRET }}
run: |
mkdir -p lib/config
umask 077
cat > lib/config/env.local.dart <<EOL
class Environment {
static const String stravaClientId = '${STRAVA_CLIENT_ID}';
static const String stravaClientSecret = '${STRAVA_CLIENT_SECRET}';
static const String intervalsClientId = '${INTERVALS_CLIENT_ID}';
static const String intervalsClientSecret = '${INTERVALS_CLIENT_SECRET}';
static bool get hasStravaConfig =>
stravaClientId.isNotEmpty && stravaClientSecret.isNotEmpty;
static bool get hasIntervalsConfig =>
intervalsClientId.isNotEmpty && intervalsClientSecret.isNotEmpty;
}
EOL
# Verify file exists but don't show contents
ls -l lib/config/env.local.dart
- name: Build iOS App
run: flutter build ios --release --no-codesign
- name: Build macOS App
run: flutter build macos --release
- name: Create artifacts
run: |
mkdir -p artifacts
zip -r artifacts/ss2kconfigapp-${{ needs.prepare.outputs.version }}.zip build/ios/iphoneos build/macos/Build/Products/Release
# Clean up sensitive files
- name: Clean up env.local.dart
if: always()
run: |
if [ -f lib/config/env.local.dart ]; then
rm lib/config/env.local.dart
echo "Cleaned up env.local.dart"
fi
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: macos-artifacts
path: artifacts/
build-linux:
needs: prepare
# Use native runners for each architecture (amd64 & arm64) instead of emulation
runs-on: ${{ matrix.runner }}
strategy:
matrix:
include:
- arch: amd64
runner: ubuntu-latest
- arch: arm64
runner: ubuntu-24.04-arm
steps:
- uses: actions/checkout@v4
# Use official action for amd64
- name: Setup Flutter (amd64)
if: matrix.arch == 'amd64'
uses: subosito/flutter-action@v2
with:
flutter-version: ${{ env.FLUTTER_VERSION }}
channel: stable
cache: true
# Manual install for arm64 (action currently fails to resolve some versions on ubuntu-24.04-arm)
- name: Setup Flutter (arm64 manual)
if: matrix.arch == 'arm64'
run: |
set -e
sudo apt-get update
sudo DEBIAN_FRONTEND=noninteractive apt-get install -y git curl unzip xz-utils zip
git clone https://github.com/flutter/flutter.git -b "$FLUTTER_VERSION" --depth 1 $HOME/flutter
echo "$HOME/flutter/bin" >> $GITHUB_PATH
$HOME/flutter/bin/flutter config --no-analytics
$HOME/flutter/bin/flutter doctor -v || true
- name: Create env.local.dart
env:
STRAVA_CLIENT_ID: ${{ secrets.STRAVA_CLIENT_ID }}
STRAVA_CLIENT_SECRET: ${{ secrets.STRAVA_CLIENT_SECRET }}
INTERVALS_CLIENT_ID: ${{ secrets.INTERVALS_CLIENT_ID }}
INTERVALS_CLIENT_SECRET: ${{ secrets.INTERVALS_CLIENT_SECRET }}
run: |
mkdir -p lib/config
umask 077
cat > lib/config/env.local.dart <<EOL
class Environment {
static const String stravaClientId = '${STRAVA_CLIENT_ID}';
static const String stravaClientSecret = '${STRAVA_CLIENT_SECRET}';
static const String intervalsClientId = '${INTERVALS_CLIENT_ID}';
static const String intervalsClientSecret = '${INTERVALS_CLIENT_SECRET}';
static bool get hasStravaConfig =>
stravaClientId.isNotEmpty && stravaClientSecret.isNotEmpty;
static bool get hasIntervalsConfig =>
intervalsClientId.isNotEmpty && intervalsClientSecret.isNotEmpty;
}
EOL
- name: Install Linux dependencies
run: |
sudo apt-get update
sudo DEBIAN_FRONTEND=noninteractive apt-get install -y \
libgtk-3-dev libx11-dev pkg-config cmake ninja-build \
libblkid-dev liblzma-dev libsecret-1-dev libjsoncpp-dev \
libgstreamer1.0-dev libgstreamer-plugins-base1.0-dev libunwind-dev
- name: Enable Linux Desktop
run: flutter config --enable-linux-desktop
- name: Fetch Linux dependencies
run: flutter pub get
- name: Preload fvp Linux SDK
run: |
set -euo pipefail
fvp_path=$(python3 - <<'PY'
import json
from pathlib import Path
deps = json.loads(Path(".flutter-plugins-dependencies").read_text())
for plugin in deps.get("plugins", {}).get("linux", []):
if plugin.get("name") == "fvp":
print(plugin["path"])
break
PY
)
if [ -z "$fvp_path" ]; then
echo "fvp is not registered for Linux; skipping SDK preload."
exit 0
fi
fvp_linux_dir="${fvp_path}/linux"
sdk_marker="${fvp_linux_dir}/mdk-sdk/lib/cmake/FindMDK.cmake"
mdk_library=$(find "${fvp_linux_dir}/mdk-sdk" -name 'libmdk.so*' -print -quit 2>/dev/null || true)
if [ -f "$sdk_marker" ] && [ -n "$mdk_library" ]; then
echo "fvp MDK SDK already exists at $fvp_linux_dir"
exit 0
fi
if [ "${{ matrix.arch }}" = "arm64" ]; then
package_name="mdk-sdk-linux.tar.xz"
else
package_name="mdk-sdk-linux-x64.tar.xz"
fi
archive_path="${fvp_linux_dir}/${package_name}"
download_urls=()
if [[ "${FVP_DEPS_URL:-}" =~ ^https?:// ]]; then
base_url="${FVP_DEPS_URL%/}"
download_urls+=("${base_url}/${package_name}")
if [[ "$base_url" == https://sourceforge.net/* ]]; then
download_urls+=("${base_url}/${package_name}/download")
fi
else
download_urls+=("https://master.dl.sourceforge.net/project/mdk-sdk/nightly/${package_name}?viasf=1")
download_urls+=("https://cfhcable.dl.sourceforge.net/project/mdk-sdk/nightly/${package_name}?viasf=1")
download_urls+=("https://downloads.sourceforge.net/project/mdk-sdk/nightly/${package_name}")
download_urls+=("https://sourceforge.net/projects/mdk-sdk/files/nightly/${package_name}/download")
fi
downloaded=0
for download_url in "${download_urls[@]}"; do
echo "Downloading $package_name from $download_url"
rm -f "$archive_path"
if ! curl -fL --retry 3 --retry-delay 2 \
-A "GitHubActions-SS2kConfigApp/1.0" \
-o "$archive_path" \
"$download_url"; then
echo "Download failed from $download_url"
continue
fi
if tar -tf "$archive_path" >/dev/null 2>&1; then
downloaded=1
break
fi
echo "Downloaded content from $download_url was not a tar archive. Size: $(wc -c < "$archive_path") bytes"
done
if [ "$downloaded" -ne 1 ]; then
echo "Failed to download a valid $package_name from all known MDK SDK URLs." >&2
exit 1
fi
rm -rf "${fvp_linux_dir}/mdk-sdk"
tar -xJf "$archive_path" -C "$fvp_linux_dir"
mdk_library=$(find "${fvp_linux_dir}/mdk-sdk" -name 'libmdk.so*' -print -quit 2>/dev/null || true)
if [ ! -f "$sdk_marker" ] || [ -z "$mdk_library" ]; then
echo "Failed to preload fvp MDK SDK into $fvp_linux_dir" >&2
find "$fvp_linux_dir" -maxdepth 3 -type f | sort | head -100
exit 1
fi
- name: Build Linux App
run: |
# Install additional build dependencies (clang & runtime libs)
sudo apt-get update
sudo DEBIAN_FRONTEND=noninteractive apt-get install -y \
clang libstdc++-12-dev libglu1-mesa fontconfig libpulse0 || true
# Handle ALSA time64 transition on Ubuntu 24.04 (libasound2t64)
sudo DEBIAN_FRONTEND=noninteractive apt-get install -y libasound2 || \
sudo DEBIAN_FRONTEND=noninteractive apt-get install -y libasound2t64 || true
export CXX=clang++
flutter config --no-analytics
# Build (native arch)
flutter build linux --release -v
- name: Create Debian Package
run: |
# Create package directory structure
mkdir -p debian/DEBIAN
mkdir -p debian/usr/bin
mkdir -p debian/usr/share/applications
mkdir -p debian/usr/share/icons/hicolor/256x256/apps
# Create control file
cat > debian/DEBIAN/control <<EOL
Package: ss2kconfigapp
Version: ${{ needs.prepare.outputs.version }}
Section: utils
Priority: optional
Architecture: ${{ matrix.arch }}
Maintainer: SmartSpin2k Team
Description: SmartSpin2k Configuration Application
A Flutter application for configuring and controlling SmartSpin2k devices.
EOL
# Copy application files based on architecture
BUILD_PATH=""
if [ "${{ matrix.arch }}" = "arm64" ]; then
BUILD_PATH="build/linux/arm64/release/bundle"
else
BUILD_PATH="build/linux/x64/release/bundle"
fi
# Verify build path exists
if [ ! -d "$BUILD_PATH" ]; then
echo "Error: Build output not found at $BUILD_PATH"
ls -la build/linux/
exit 1
fi
# Copy files
echo "Copying files from $BUILD_PATH to debian/usr/bin/"
cp -rv "$BUILD_PATH"/* debian/usr/bin/
# Copy icon
cp assets/icons/ss2kv3.png debian/usr/share/icons/hicolor/256x256/apps/ss2kconfigapp.png
# Create desktop file
cat > debian/usr/share/applications/ss2kconfigapp.desktop <<EOL
[Desktop Entry]
Name=SmartSpin2k Config App
Exec=/usr/bin/ss2kconfigapp
Icon=ss2kconfigapp
Type=Application
Categories=Utility;
EOL
# Set permissions
chmod 755 debian/usr/bin/ss2kconfigapp
chmod -R 755 debian/DEBIAN
# Build the package with architecture in filename
dpkg-deb --build debian ss2kconfigapp-${{ matrix.arch }}.deb
- name: Create artifacts
run: |
mkdir -p artifacts
mv ss2kconfigapp-${{ matrix.arch }}.deb artifacts/
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: linux-artifacts-${{ matrix.arch }}
path: artifacts/
build-windows:
needs: prepare
runs-on: windows-latest
steps:
- uses: actions/checkout@v4
- name: Setup Flutter
uses: subosito/flutter-action@v2
with:
flutter-version: ${{ env.FLUTTER_VERSION }}
channel: stable
cache: true
- name: Install Inno Setup
run: choco install innosetup --no-progress -y
- name: Create env.local.dart
shell: bash
env:
STRAVA_CLIENT_ID: ${{ secrets.STRAVA_CLIENT_ID }}
STRAVA_CLIENT_SECRET: ${{ secrets.STRAVA_CLIENT_SECRET }}
INTERVALS_CLIENT_ID: ${{ secrets.INTERVALS_CLIENT_ID }}
INTERVALS_CLIENT_SECRET: ${{ secrets.INTERVALS_CLIENT_SECRET }}
run: |
mkdir -p lib/config
umask 077
cat > lib/config/env.local.dart <<EOL
class Environment {
static const String stravaClientId = '${STRAVA_CLIENT_ID}';
static const String stravaClientSecret = '${STRAVA_CLIENT_SECRET}';
static const String intervalsClientId = '${INTERVALS_CLIENT_ID}';
static const String intervalsClientSecret = '${INTERVALS_CLIENT_SECRET}';
static bool get hasStravaConfig =>
stravaClientId.isNotEmpty && stravaClientSecret.isNotEmpty;
static bool get hasIntervalsConfig =>
intervalsClientId.isNotEmpty && intervalsClientSecret.isNotEmpty;
}
EOL
- name: Enable Windows Desktop
run: flutter config --enable-windows-desktop
- name: Fetch dependencies
run: flutter pub get
- name: Preload fvp Windows SDK
shell: pwsh
run: |
$ErrorActionPreference = 'Stop'
$deps = Get-Content '.flutter-plugins-dependencies' -Raw | ConvertFrom-Json
$fvp = $deps.plugins.windows | Where-Object { $_.name -eq 'fvp' } | Select-Object -First 1
if (-not $fvp) {
Write-Host 'fvp is not registered for Windows; skipping SDK preload.'
exit 0
}
$fvpWindowsDir = Join-Path $fvp.path 'windows'
$sdkMarker = Join-Path $fvpWindowsDir 'mdk-sdk\lib\cmake\FindMDK.cmake'
if (Test-Path $sdkMarker) {
Write-Host "fvp MDK SDK already exists at $fvpWindowsDir"
exit 0
}
function Test-7zArchive($Path) {
if (-not (Test-Path $Path)) {
return $false
}
[byte[]] $signature = Get-Content -Path $Path -AsByteStream -TotalCount 6
$expectedSignature = @(0x37, 0x7a, 0xbc, 0xaf, 0x27, 0x1c)
if ($signature.Length -ne $expectedSignature.Length) {
return $false
}
for ($i = 0; $i -lt $expectedSignature.Length; $i++) {
if ($signature[$i] -ne $expectedSignature[$i]) {
return $false
}
}
return $true
}
$packageName = 'mdk-sdk-windows-x64.7z'
$archivePath = Join-Path $fvpWindowsDir $packageName
$downloadUrls = @()
if ($env:FVP_DEPS_URL -match '^https?://') {
$baseUrl = $env:FVP_DEPS_URL.TrimEnd('/')
$downloadUrls += "$baseUrl/$packageName"
if ($baseUrl -like 'https://sourceforge.net/*') {
$downloadUrls += "$baseUrl/$packageName/download"
}
} else {
# Direct mirror URLs avoid occasional SourceForge HTML interstitials
# from downloads.sourceforge.net on GitHub-hosted Windows runners.
$downloadUrls += "https://master.dl.sourceforge.net/project/mdk-sdk/nightly/$packageName?viasf=1"
$downloadUrls += "https://cfhcable.dl.sourceforge.net/project/mdk-sdk/nightly/$packageName?viasf=1"
$downloadUrls += "https://downloads.sourceforge.net/project/mdk-sdk/nightly/$packageName"
$downloadUrls += "https://sourceforge.net/projects/mdk-sdk/files/nightly/$packageName/download"
}
$headers = @{ 'User-Agent' = 'GitHubActions-SS2kConfigApp/1.0' }
$downloaded = $false
foreach ($downloadUrl in $downloadUrls) {
Write-Host "Downloading $packageName from $downloadUrl"
Remove-Item -Path $archivePath -Force -ErrorAction SilentlyContinue
try {
Invoke-WebRequest `
-Uri $downloadUrl `
-OutFile $archivePath `
-Headers $headers `
-MaximumRedirection 10
} catch {
Write-Warning "Download failed from $downloadUrl`: $($_.Exception.Message)"
continue
}
if (Test-7zArchive $archivePath) {
$downloaded = $true
break
}
$contentType = ''
try {
$contentType = (Get-Item $archivePath).Length
} catch {}
Write-Warning "Downloaded content from $downloadUrl was not a 7z archive. Size: $contentType bytes"
}
if (-not $downloaded) {
throw "Failed to download a valid $packageName from all known MDK SDK URLs."
}
# Some fvp versions let CMake extract through Flutter's .plugin_symlinks path,
# which fails on current Windows runners. Extract in the real pub-cache path.
Push-Location $fvpWindowsDir
try {
cmake -E tar xvf $archivePath
} finally {
Pop-Location
}
if (-not (Test-Path $sdkMarker)) {
throw "Failed to preload fvp MDK SDK into $fvpWindowsDir"
}
- name: Build Windows App
run: flutter build windows --release
- name: Create Inno Setup installer
shell: bash
env:
VERSION: ${{ needs.prepare.outputs.version }}
run: |
mkdir -p artifacts
cat > installer.iss <<'EOL'
[Setup]
AppName=SmartSpin2k Config App
AppVersion={#Version}
AppPublisher=SmartSpin2k LLC
DefaultDirName={pf}\SmartSpin2k Config App
SetupIconFile=windows\\runner\\resources\\app_icon.ico
UninstallDisplayIcon={app}\\ss2kconfigapp.exe
OutputDir=artifacts
OutputBaseFilename=ss2kconfigapp-{#Version}-windows
Compression=lzma2
SolidCompression=yes
ArchitecturesInstallIn64BitMode=x64
[Files]
; Flutter builds Windows x64 into build/windows/x64/runner/Release
Source:"build\\windows\\x64\\runner\\Release\\*"; DestDir:"{app}"; Flags: recursesubdirs createallsubdirs
[Icons]
Name:"{group}\\SmartSpin2k Config App"; Filename:"{app}\\ss2kconfigapp.exe"
Name:"{commondesktop}\\SmartSpin2k Config App"; Filename:"{app}\\ss2kconfigapp.exe"; Tasks: desktopicon
[Tasks]
Name: "desktopicon"; Description: "Create a &desktop icon"; GroupDescription: "Additional shortcuts:"; Flags: unchecked
EOL
# Inject version into installer script
sed -i "s/{#Version}/${VERSION}/g" installer.iss
# Run Inno Setup Compiler
iscc installer.iss
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: windows-artifacts
path: artifacts/
create-release:
needs: [prepare, build-android, build-macos, build-linux, build-windows]
runs-on: ubuntu-latest
steps:
- name: Download all artifacts
uses: actions/download-artifact@v4
with:
path: all-artifacts
- name: Prepare release bundle
run: |
mkdir -p release
cp all-artifacts/android-artifacts/ss2kconfigapp-${{ needs.prepare.outputs.version }}.apk release/ss2kconfigapp-${{ needs.prepare.outputs.version }}.apk
cp all-artifacts/macos-artifacts/ss2kconfigapp-${{ needs.prepare.outputs.version }}.zip release/ss2kconfigapp-${{ needs.prepare.outputs.version }}.zip
cp all-artifacts/linux-artifacts-amd64/ss2kconfigapp-amd64.deb release/ss2kconfigapp-${{ needs.prepare.outputs.version }}-amd64.deb
cp all-artifacts/linux-artifacts-arm64/ss2kconfigapp-arm64.deb release/ss2kconfigapp-${{ needs.prepare.outputs.version }}-arm64.deb
cp all-artifacts/windows-artifacts/ss2kconfigapp-${{ needs.prepare.outputs.version }}-windows.exe release/ss2kconfigapp-${{ needs.prepare.outputs.version }}-windows.exe
- name: Create release
uses: softprops/action-gh-release@v2
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ needs.prepare.outputs.version }}
name: SmartSpin2kConfigApp ${{ needs.prepare.outputs.version }}
draft: false
prerelease: false
generate_release_notes: true
body: ${{ github.event.head_commit.message }}
files: |
release/ss2kconfigapp-${{ needs.prepare.outputs.version }}.apk
release/ss2kconfigapp-${{ needs.prepare.outputs.version }}.zip
release/ss2kconfigapp-${{ needs.prepare.outputs.version }}-amd64.deb
release/ss2kconfigapp-${{ needs.prepare.outputs.version }}-arm64.deb
release/ss2kconfigapp-${{ needs.prepare.outputs.version }}-windows.exe