From 43d8253a6a408683e8033ad64602b94d460ab1b3 Mon Sep 17 00:00:00 2001 From: foxyz Date: Wed, 7 Oct 2026 21:44:31 +0300 Subject: [PATCH] probe: windows build --- .gitea/workflows/probe.yml | 36 ++++++++++++++++++------- tool/package_windows.ps1 | 55 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 81 insertions(+), 10 deletions(-) create mode 100644 tool/package_windows.ps1 diff --git a/.gitea/workflows/probe.yml b/.gitea/workflows/probe.yml index 673cd36..45dd618 100644 --- a/.gitea/workflows/probe.yml +++ b/.gitea/workflows/probe.yml @@ -1,16 +1,32 @@ name: probe-windows on: push jobs: - probe: + windows: runs-on: windows-latest steps: - - run: | - $PSVersionTable.PSVersion - whoami; hostname; Get-Location - [Environment]::OSVersion - foreach ($c in 'git','bash','pwsh','powershell','python','python3','curl','tar','7z','cmake','ninja','flutter','dart','node','cl','msbuild') { $p = Get-Command $c -ErrorAction SilentlyContinue; "{0,-12} {1}" -f $c, ($p.Source) } - $vw = "${env:ProgramFiles(x86)}\Microsoft Visual Studio\Installer\vswhere.exe" - if (Test-Path $vw) { & $vw -all -products * -format text | Select-String 'displayName|installationPath|installationVersion' } else { 'no vswhere' } - Get-PSDrive -PSProvider FileSystem | Select-Object Name,Free - "PATH=$env:PATH" + - name: Checkout + uses: actions/checkout@v4 + with: + fetch-depth: 0 + - name: Setup Flutter (stable, cached on the runner host) shell: powershell + run: | + $ErrorActionPreference = 'Stop' + $F = "$env:ProgramData\flutter-ci" + if (Test-Path "$F\.git") { + git -C $F fetch --depth 1 origin stable; if ($LASTEXITCODE) { exit 1 } + git -C $F reset --hard FETCH_HEAD; if ($LASTEXITCODE) { exit 1 } + } else { + git clone https://github.com/flutter/flutter.git -b stable --depth 1 $F; if ($LASTEXITCODE) { exit 1 } + } + Add-Content $env:GITHUB_PATH "$F\bin" + & "$F\bin\flutter.bat" config --no-analytics --enable-windows-desktop | Out-Null + & "$F\bin\flutter.bat" doctor -v + - name: Build zip + shell: powershell + run: powershell -NoProfile -ExecutionPolicy Bypass -File tool/package_windows.ps1 + - name: Inspect + shell: powershell + run: | + Get-ChildItem dist + tar.exe -tf (Get-ChildItem dist\*.zip)[0].FullName | Select-Object -First 40 diff --git a/tool/package_windows.ps1 b/tool/package_windows.ps1 new file mode 100644 index 0000000..872bbe7 --- /dev/null +++ b/tool/package_windows.ps1 @@ -0,0 +1,55 @@ +# Package the Windows release bundle into a versioned zip. +# Usage: powershell -File tool/package_windows.ps1 [-SkipBuild] +# Output: dist/watch-together--windows-x64.zip containing one +# top-level folder with watch_together.exe, its DLLs and data/ as built, +# plus update.bat (runs the exe with --upgrade) and +# watch-together-server.exe (dedicated server, `dart compile exe` of +# packages/server/bin/server.dart). Same layout as tool/package_linux.sh; +# the in-app updater strips the top-level folder. +# Needs: flutter on PATH, tar.exe (ships with Windows 10+, writes zip). +param([switch]$SkipBuild) +$ErrorActionPreference = 'Stop' + +$Root = Split-Path -Parent $PSScriptRoot +$App = Join-Path $Root 'apps/desktop' +$Name = 'watch-together' +$Arch = 'x64' + +$Version = (Select-String -Path "$App/pubspec.yaml" -Pattern '^version: ([0-9.]+)').Matches[0].Groups[1].Value +if (-not $Version) { throw "version not found in $App/pubspec.yaml" } + +function Invoke-Checked([string]$What, [scriptblock]$Cmd) { + & $Cmd + if ($LASTEXITCODE -ne 0) { throw "$What failed (exit $LASTEXITCODE)" } +} + +if (-not $SkipBuild) { + Push-Location $App + try { + Invoke-Checked 'flutter build windows' { flutter build windows --release "--dart-define=APP_VERSION=$Version" } + } finally { Pop-Location } +} + +$Bundle = Join-Path $App "build/windows/$Arch/runner/Release" +if (-not (Test-Path "$Bundle/watch_together.exe")) { throw "bundle missing (build first): $Bundle" } + +$Stage = Join-Path $App 'build/package-stage' +$Dist = Join-Path $Root 'dist' +$Folder = "$Name-$Version" +$Zip = Join-Path $Dist "$Folder-windows-$Arch.zip" +if (Test-Path $Stage) { Remove-Item -Recurse -Force $Stage } +New-Item -ItemType Directory -Force "$Stage/$Folder", $Dist | Out-Null +Copy-Item -Recurse "$Bundle/*" "$Stage/$Folder/" +Copy-Item "$App/lib/src/update/bundle/update.bat" "$Stage/$Folder/update.bat" + +Push-Location (Join-Path $Root 'packages/server') +try { + Invoke-Checked 'dart pub get' { dart pub get | Out-Null } + Invoke-Checked 'dart compile exe' { dart compile exe bin/server.dart -o "$Stage/$Folder/watch-together-server.exe" } +} finally { Pop-Location } + +if (Test-Path $Zip) { Remove-Item -Force $Zip } +# bsdtar writes forward-slash entry names (Compress-Archive on 5.1 doesn't). +Invoke-Checked 'tar' { tar.exe -a -c -f $Zip -C $Stage $Folder } +Remove-Item -Recurse -Force $Stage +Get-Item $Zip | Format-Table Name, Length