#!/usr/bin/env bash # provision-windows.sh — idempotent provisioning for the Windows host runner. # # Pre-warms what compile-windows.sh would download at runtime: Flutter Windows # engine artifacts, pub packages, and the Inno Setup compiler (ISCC) used to # build the installer. The Flutter part short-circuits via a stamp keyed to the # installed Flutter version; Inno Setup is ensured on every run (cheap when # already present) so it self-heals independently of the Flutter stamp. set -euo pipefail SCRIPT_DIR="$(dirname "$0")" # shellcheck source=scripts/ci/_env.sh . "${SCRIPT_DIR}/_env.sh" STAMP_DIR="${HOME}/.cache/jiu-ci" STAMP="${STAMP_DIR}/provisioned-windows" CUR="${STAMP_DIR}/.flutter-version-win.cur" mkdir -p "$STAMP_DIR" # --- ensure Inno Setup (ISCC) for building the installer (always checked) --- ISCC="/c/Program Files (x86)/Inno Setup 6/ISCC.exe" if [ ! -f "$ISCC" ]; then echo "==> installing Inno Setup 6 (silent)" # Canonical "latest stable" entry point (redirects to the GitHub release asset). INNO_URL="https://jrsoftware.org/download.php/is.exe" powershell -NoProfile -Command \ "Invoke-WebRequest -Uri '${INNO_URL}' -OutFile \"\$env:TEMP\\innosetup.exe\"" powershell -NoProfile -Command \ "Start-Process -Wait -FilePath \"\$env:TEMP\\innosetup.exe\" -ArgumentList '/VERYSILENT','/SUPPRESSMSGBOXES','/NORESTART','/SP-'" if [ ! -f "$ISCC" ]; then echo "ERROR: Inno Setup install failed — ISCC not found at '$ISCC'." >&2 exit 1 fi echo "==> Inno Setup installed." fi # --- detection (Flutter) --- if ! command -v flutter >/dev/null 2>&1; then echo "ERROR: flutter not found on PATH. Install Flutter on this runner first." >&2 exit 1 fi flutter --version --machine > "$CUR" 2>/dev/null || flutter --version > "$CUR" 2>&1 || true if [ -s "$STAMP" ] && cmp -s "$STAMP" "$CUR"; then echo "==> provision-windows: already provisioned (Flutter unchanged), skipping." exit 0 fi echo "==> provision-windows: not provisioned (or Flutter changed) — running." # --- warm Flutter Windows engine + pub deps --- echo "==> precache Flutter engine (windows)" flutter precache --windows echo "==> flutter pub get (client)" (cd "${SCRIPT_DIR}/../../client" && flutter pub get) # --- mark provisioned --- cp "$CUR" "$STAMP" echo "==> provision-windows: done." flutter --version | head -1