From 3f9bb8ffd44670235de0ead182bd77cba5693789 Mon Sep 17 00:00:00 2001 From: deepend-tildeclub <58404188+deepend-tildeclub@users.noreply.github.com> Date: Mon, 12 Jan 2026 21:04:27 -0700 Subject: [PATCH] Refactor Windows ARM64 build workflow Updated Windows ARM64 build workflow to include Python and CFFI installation, modified paths for Inno Setup, and added error handling for missing files. --- .github/workflows/windows-arm64-msys2.yml | 124 +++++++++++++++++++--- 1 file changed, 111 insertions(+), 13 deletions(-) diff --git a/.github/workflows/windows-arm64-msys2.yml b/.github/workflows/windows-arm64-msys2.yml index d59ffbbc..5e8130d8 100644 --- a/.github/workflows/windows-arm64-msys2.yml +++ b/.github/workflows/windows-arm64-msys2.yml @@ -43,7 +43,10 @@ jobs: export MSGFMT="/clangarm64/bin/msgfmt" export GETTEXTDATADIR="/clangarm64/share/gettext" - rm -rf build dist rel + # Defensive: ensure python + cffi exist even if the setup action had a bad day + pacman -S --noconfirm --needed mingw-w64-clang-aarch64-python mingw-w64-clang-aarch64-python-cffi + + rm -rf build dist mkdir -p dist meson setup build \ @@ -60,6 +63,11 @@ jobs: /clangarm64/bin/python.exe -c "import sys, cffi; print('python:', sys.version); print('cffi:', cffi.__version__)" + # Export app version from Meson for the Inno script defines + APPVER="$(meson introspect build --projectinfo | /clangarm64/bin/python.exe -c 'import json,sys; print(json.load(sys.stdin)[\"version\"])')" + echo "APPVER=$APPVER" >> "$GITHUB_ENV" + echo "Meson APPVER=$APPVER" + - name: Build shell: msys2 {0} run: | @@ -79,6 +87,7 @@ jobs: run: | set -euxo pipefail export PATH="/clangarm64/bin:$PATH" + DESTDIR="$PWD/dist" ninja -C build install echo "Installed files (debug):" @@ -92,6 +101,7 @@ jobs: shopt -s nullglob mapfile -t targets < <(find dist -type f \( -iname 'zoitechat*.exe' -o -ipath '*/plugins/*.dll' \) 2>/dev/null || true) + if [ "${#targets[@]}" -eq 0 ]; then echo "No installed binaries/plugins found under dist/ (skipping dep harvest)" exit 0 @@ -122,28 +132,32 @@ jobs: ) done - - name: Prepare Inno Setup source tree (rel/) + - name: Prepare Inno Setup source tree (win32/rel) shell: msys2 {0} run: | set -euxo pipefail export PATH="/clangarm64/bin:$PATH" - rm -rf rel - mkdir -p rel + rm -rf win32/rel + mkdir -p win32/rel app_exe="$(find dist -type f -iname 'zoitechat.exe' | head -n1 || true)" if [ -z "$app_exe" ]; then echo "zoitechat.exe not found under dist/; cannot build installer." + find dist -maxdepth 8 -type f -print || true exit 1 fi bin_dir="$(dirname "$app_exe")" install_root="$(cd "$bin_dir/.." && pwd)" - cp -a "$install_root/." rel/ + echo "app_exe: $app_exe" + echo "install_root: $install_root" - echo "rel/ contents (debug):" - find rel -maxdepth 5 -type f \( -iname 'zoitechat*.exe' -o -iname '*.dll' \) -print || true + cp -a "$install_root/." win32/rel/ + + echo "win32/rel contents (debug):" + find win32/rel -maxdepth 5 -type f \( -iname 'zoitechat*.exe' -o -iname '*.dll' \) -print || true - name: Install Inno Setup (find real ISCC.exe) shell: pwsh @@ -157,20 +171,20 @@ jobs: iex ((New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1')) } - # Force reinstall so we get real binaries in expected locations on these odd runners choco install innosetup -y --force --no-progress | Out-Host $candidates = @() $pf = ${env:ProgramFiles} $pfx86 = ${env:ProgramFiles(x86)} - if ($pf) { $candidates += (Join-Path $pf "Inno Setup 6\ISCC.exe") } + if ($pf) { $candidates += (Join-Path $pf "Inno Setup 6\ISCC.exe") } if ($pfx86) { $candidates += (Join-Path $pfx86 "Inno Setup 6\ISCC.exe") } $chocoRoot = ${env:ChocolateyInstall} if ($chocoRoot -and (Test-Path $chocoRoot)) { $candidates += (Join-Path $chocoRoot "lib\innosetup\tools\ISCC.exe") $candidates += (Get-ChildItem -Path (Join-Path $chocoRoot "lib\innosetup") -Recurse -Filter "ISCC.exe" -ErrorAction SilentlyContinue | + Where-Object { $_.FullName -notmatch '\\chocolatey\\bin\\' } | Select-Object -ExpandProperty FullName -First 10) } @@ -197,6 +211,68 @@ jobs: "ISCC_PATH=$iscc" | Out-File -FilePath $env:GITHUB_ENV -Append -Encoding utf8 + - name: Patch ARM64 .iss for CI (disable missing idp.iss) + shell: pwsh + run: | + $ErrorActionPreference = "Stop" + + $issIn = "win32\installer\zoitechat-arm64.iss" + if (-not (Test-Path $issIn)) { + throw "Missing: $issIn" + } + + $projectDir = (Resolve-Path "win32\installer").Path + # double trailing backslash avoids Windows arg-quoting weirdness, and still works as a path + $projectDirArg = ($projectDir.TrimEnd('\') + "\\") + "PROJECTDIR=$projectDirArg" | Out-File -FilePath $env:GITHUB_ENV -Append -Encoding utf8 + + $text = Get-Content $issIn -Raw + + # Comment out the IDP include (it isn't present on the runner; and IDP plugin support on ARM64 is not reliable) + $text = [regex]::Replace($text, '^\s*#include\s+\s*$', '; CI: idp.iss disabled for ARM64 builds', 'Multiline') + + if ($text -notmatch '; CI: IDP STUBS') { + $stub = @" +; CI: IDP STUBS (no-op on ARM64 CI) +procedure idpDownloadAfter(PageID: Integer); +begin +end; + +procedure idpClearFiles; +begin +end; + +procedure idpAddFile(const Url, DestFile: string); +begin +end; + +procedure idpAddFileComp(const Url, DestFile: string; const Components: string); +begin +end; + +procedure idpAddFileSize(const Url, DestFile: string; const Size: Int64); +begin +end; + +procedure idpAddFileSizeComp(const Url, DestFile: string; const Size: Int64; const Components: string); +begin +end; + +function idpDownloadFiles: Boolean; +begin + Result := True; +end; + +"@ + + # Inject stubs immediately after the [Code] header (so [Setup] stays first) + $text = [regex]::Replace($text, '(\[Code\]\s*\r?\n)', "`$1$stub", 'Singleline') + } + + $issOut = "win32\installer\zoitechat-arm64.ci.iss" + Set-Content -Path $issOut -Value $text -Encoding UTF8 + Write-Host "Wrote patched CI script: $issOut" + - name: Build ARM64 installer shell: pwsh run: | @@ -207,16 +283,38 @@ jobs: throw "ISCC_PATH missing or invalid." } - if (-not (Test-Path "win32\installer\zoitechat-arm64.iss")) { - throw "win32\installer\zoitechat-arm64.iss not found." + $iss = "win32\installer\zoitechat-arm64.ci.iss" + if (-not (Test-Path $iss)) { + throw "Patched CI script missing: $iss" } - & $iscc "win32\installer\zoitechat-arm64.iss" | Out-Host + if (-not $env:APPVER) { + throw "APPVER missing (Meson version export failed)." + } + if (-not $env:PROJECTDIR) { + throw "PROJECTDIR missing." + } + + & $iscc "/DAPPARCH=arm64" "/DAPPVER=$env:APPVER" "/DPROJECTDIR=$env:PROJECTDIR" $iss | Out-Host if ($LASTEXITCODE -ne 0) { throw "ISCC failed with exit code $LASTEXITCODE" } + $exe = Get-ChildItem -Path "win32" -Recurse -Filter "*.exe" | + Where-Object { $_.Name -match 'Setup' -or $_.Name -match 'Installer' } | + Sort-Object LastWriteTime -Descending | + Select-Object -First 1 + + if (-not $exe) { + Write-Host "win32 tree (debug):" + Get-ChildItem -Path "win32" -Recurse -Depth 4 | Select-Object FullName | Out-Host + throw "Installer exe not found under win32/" + } + + Write-Host "Installer built:" $exe.FullName + "INSTALLER_EXE=$($exe.FullName)" | Out-File -FilePath $env:GITHUB_ENV -Append -Encoding utf8 + - uses: actions/upload-artifact@v4 with: name: zoitechat-windows-arm64-installer - path: win32\installer\Output\*.exe + path: ${{ env.INSTALLER_EXE }}