Skip to content

Commit 3086cfc

Browse files
updated build pipeline
1 parent 2342e04 commit 3086cfc

3 files changed

Lines changed: 100 additions & 5 deletions

File tree

.github/workflows/build.yml

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,10 +167,21 @@ jobs:
167167
shell: pwsh
168168
run: .\build-windows.ps1
169169

170+
- name: Verify Windows artifact
171+
shell: pwsh
172+
run: |
173+
$artifacts = Get-ChildItem -Path . -Filter "Moonfin_Windows_v*.exe" -File -ErrorAction SilentlyContinue
174+
if (-not $artifacts -or $artifacts.Count -eq 0) {
175+
throw "Windows build did not produce Moonfin_Windows_v*.exe"
176+
}
177+
Write-Host "Found Windows artifact(s):"
178+
$artifacts | ForEach-Object { Write-Host " - $($_.Name)" }
179+
170180
- uses: actions/upload-artifact@v4
171181
with:
172182
name: windows-exe
173183
path: Moonfin_Windows_v*.exe
184+
if-no-files-found: error
174185

175186
# ─────────────────────────────────────────────
176187
# Linux (6 formats weeeeee)
@@ -204,11 +215,47 @@ jobs:
204215
- name: Install snapcraft
205216
run: sudo snap install snapcraft --classic
206217

218+
- name: Prepare snapd and core22
219+
run: |
220+
sudo snap wait system seed.loaded
221+
sudo snap list core22 >/dev/null 2>&1 || sudo snap install core22 --channel=latest/stable
222+
207223
- name: Build all Linux packages
208224
run: |
209225
chmod +x build-linux.sh
210226
./build-linux.sh all
211227
228+
- name: Verify Linux artifacts
229+
run: |
230+
set -euo pipefail
231+
shopt -s nullglob
232+
patterns=(
233+
"Moonfin_Linux_v*.tar.gz"
234+
"Moonfin_Linux_v*.AppImage"
235+
"Moonfin_Linux_v*.deb"
236+
"Moonfin_Linux_v*.rpm"
237+
"Moonfin_Linux_v*.snap"
238+
"Moonfin_Linux_v*.flatpak"
239+
)
240+
241+
missing=0
242+
for pattern in "${patterns[@]}"; do
243+
matches=( $pattern )
244+
if [ ${#matches[@]} -eq 0 ]; then
245+
echo "Missing artifact for pattern: $pattern"
246+
missing=1
247+
else
248+
for m in "${matches[@]}"; do
249+
echo "Found artifact: $m"
250+
done
251+
fi
252+
done
253+
254+
if [ $missing -ne 0 ]; then
255+
echo "One or more Linux package artifacts are missing."
256+
exit 1
257+
fi
258+
212259
- uses: actions/upload-artifact@v4
213260
with:
214261
name: linux-packages
@@ -219,6 +266,7 @@ jobs:
219266
Moonfin_Linux_v*.rpm
220267
Moonfin_Linux_v*.snap
221268
Moonfin_Linux_v*.flatpak
269+
if-no-files-found: error
222270

223271
# ─────────────────────────────────────────────
224272
# GitHub Release

build-linux.sh

Lines changed: 41 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -544,6 +544,27 @@ EOF
544544
fi
545545
}
546546

547+
retry_with_backoff() {
548+
local max_attempts="$1"
549+
shift
550+
551+
local attempt=1
552+
while true; do
553+
if "$@"; then
554+
return 0
555+
fi
556+
557+
if [ "$attempt" -ge "$max_attempts" ]; then
558+
return 1
559+
fi
560+
561+
local delay=$((attempt * 10))
562+
echo "Command failed (attempt $attempt/$max_attempts). Retrying in ${delay}s..."
563+
sleep "$delay"
564+
attempt=$((attempt + 1))
565+
done
566+
}
567+
547568
build_snap() {
548569
echo "=== Building Snap Package ==="
549570
if ! command -v snapcraft >/dev/null 2>&1; then
@@ -552,6 +573,21 @@ build_snap() {
552573
return 1
553574
fi
554575

576+
if command -v snap >/dev/null 2>&1; then
577+
echo "Waiting for snapd seed to complete..."
578+
if ! snap wait system seed.loaded >/dev/null 2>&1; then
579+
echo "Warning: snapd seed wait failed; continuing and letting snapcraft attempt build."
580+
fi
581+
582+
if ! snap list core22 >/dev/null 2>&1; then
583+
echo "core22 not found. Installing core22 base snap..."
584+
if ! retry_with_backoff 3 sudo snap install core22 --channel=latest/stable; then
585+
echo "Failed to install core22 after retries."
586+
return 1
587+
fi
588+
fi
589+
fi
590+
555591
local snap_dir="$TEMP_DIR/snap"
556592
local version="$(get_app_version)"
557593

@@ -603,7 +639,10 @@ EOF
603639
[ -f "$APP_ICON" ] && cp "$APP_ICON" "$snap_dir/${APP_ID}.png"
604640

605641
cd "$snap_dir"
606-
snapcraft --destructive-mode || true
642+
if ! retry_with_backoff 3 snapcraft pack --destructive-mode; then
643+
echo "Snap build failed after retries"
644+
return 1
645+
fi
607646

608647
local snap_file
609648
snap_file=$(find "$snap_dir" -maxdepth 1 -name "*.snap" 2>/dev/null | head -1)
@@ -612,6 +651,7 @@ EOF
612651
echo "✓ Created: $REPO_ROOT/${APP_NAME}_Linux_v${version}.snap"
613652
else
614653
echo "Snap build did not produce a .snap file"
654+
return 1
615655
fi
616656
}
617657

build-windows.ps1

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
$ErrorActionPreference = 'Continue'
1+
$ErrorActionPreference = 'Stop'
22

33
$repoRoot = Split-Path -Parent $MyInvocation.MyCommand.Path
44

@@ -64,12 +64,19 @@ function Assert-ToolchainVersions {
6464
$minFlutter = [Version]::Parse('3.41.0')
6565
$minDart = [Version]::Parse('3.11.0')
6666

67-
$versionJson = & $FlutterExe --version --machine
68-
if ($LASTEXITCODE -ne 0 -or [string]::IsNullOrWhiteSpace($versionJson)) {
67+
$rawOutput = (& $FlutterExe --version --machine | Out-String)
68+
if ($LASTEXITCODE -ne 0 -or [string]::IsNullOrWhiteSpace($rawOutput)) {
6969
throw "Failed to query Flutter version. Run 'flutter --version' manually and verify your SDK installation."
7070
}
7171

72-
$versionInfo = $versionJson | ConvertFrom-Json
72+
# Flutter can emit setup chatter (e.g. "Running pub upgrade...") before JSON.
73+
# Extract the JSON object from mixed output to avoid ConvertFrom-Json failures.
74+
$jsonMatch = [regex]::Match($rawOutput, '\{[\s\S]*\}')
75+
if (-not $jsonMatch.Success) {
76+
throw "Failed to parse Flutter --version --machine output as JSON. Raw output: $rawOutput"
77+
}
78+
79+
$versionInfo = $jsonMatch.Value | ConvertFrom-Json
7380
$flutterVersion = Get-NormalizedVersion $versionInfo.frameworkVersion
7481
$dartVersion = Get-NormalizedVersion $versionInfo.dartSdkVersion
7582

0 commit comments

Comments
 (0)