diff --git a/.github/workflows/build-baseline.yml b/.github/workflows/build-baseline.yml index b2ca8f08..672b5e0e 100644 --- a/.github/workflows/build-baseline.yml +++ b/.github/workflows/build-baseline.yml @@ -225,7 +225,9 @@ jobs: - name: Build frontend run: npm run build --workspace @bandscope/desktop - name: Build native shell - run: npm exec --workspace @bandscope/desktop -- tauri build --target "$BANDSCOPE_TARGET_TRIPLE" --bundles dmg + env: + BANDSCOPE_TAURI_BUILD_ATTEMPTS: "2" + run: scripts/release/build_tauri_bundle_with_retry.sh @bandscope/desktop "$BANDSCOPE_TARGET_TRIPLE" dmg - name: Package macOS amd64 artifact run: python3 scripts/release/package_desktop_artifact.py - name: Upload macOS amd64 artifact @@ -271,7 +273,9 @@ jobs: - name: Build frontend run: npm run build --workspace @bandscope/desktop - name: Build native shell - run: npm exec --workspace @bandscope/desktop -- tauri build --target "$BANDSCOPE_TARGET_TRIPLE" --bundles dmg + env: + BANDSCOPE_TAURI_BUILD_ATTEMPTS: "2" + run: scripts/release/build_tauri_bundle_with_retry.sh @bandscope/desktop "$BANDSCOPE_TARGET_TRIPLE" dmg - name: Package macOS arm64 artifact run: python3 scripts/release/package_desktop_artifact.py - name: Upload macOS arm64 artifact diff --git a/scripts/release/build_tauri_bundle_with_retry.sh b/scripts/release/build_tauri_bundle_with_retry.sh new file mode 100755 index 00000000..07756116 --- /dev/null +++ b/scripts/release/build_tauri_bundle_with_retry.sh @@ -0,0 +1,46 @@ +#!/usr/bin/env bash +set -euo pipefail + +if [ "$#" -ne 3 ]; then + echo "usage: $0 " >&2 + exit 2 +fi + +workspace="$1" +target_triple="$2" +bundles="$3" +attempts="${BANDSCOPE_TAURI_BUILD_ATTEMPTS:-1}" + +if ! [[ "$attempts" =~ ^[1-9][0-9]*$ ]]; then + echo "BANDSCOPE_TAURI_BUILD_ATTEMPTS must be a positive integer" >&2 + exit 2 +fi + +cleanup_macos_dmg_state() { + local dmg_dir="apps/desktop/src-tauri/target/${target_triple}/release/bundle/dmg" + rm -rf "$dmg_dir" + + if command -v hdiutil >/dev/null 2>&1; then + hdiutil info || true + hdiutil detach "/Volumes/BandScope" -force || true + hdiutil detach "/Volumes/BandScope 0.1.3" -force || true + fi +} + +for ((attempt = 1; attempt <= attempts; attempt++)); do + echo "Tauri bundle build attempt ${attempt}/${attempts} for ${target_triple} (${bundles})" + if npm exec --workspace "$workspace" -- tauri build --target "$target_triple" --bundles "$bundles"; then + exit 0 + fi + + status="$?" + if [ "$attempt" -eq "$attempts" ]; then + exit "$status" + fi + + echo "::warning::Tauri bundle build failed with exit ${status}; cleaning partial DMG state before retry." + if [[ "$bundles" == *dmg* ]]; then + cleanup_macos_dmg_state + fi + sleep 10 +done