From 26902b7616b1a35222ebb0d7df9f0e5d5f6570d4 Mon Sep 17 00:00:00 2001 From: Armand <4831c0@proton.me> Date: Wed, 4 Mar 2026 21:10:09 +0100 Subject: [PATCH] add build script for windows --- build.ps1 | 52 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 build.ps1 diff --git a/build.ps1 b/build.ps1 new file mode 100644 index 0000000..6e31e70 --- /dev/null +++ b/build.ps1 @@ -0,0 +1,52 @@ +$ErrorActionPreference = 'Stop' + +$ROOT = $PSScriptRoot +$SHA = (git -C $ROOT rev-parse --short HEAD) +$COMMIT_COUNT = [int](git -C $ROOT rev-list --count HEAD) + +function Build-App { + param([string]$App) + + $pubspec = Join-Path $ROOT $App "pubspec.yaml" + if (-not (Test-Path $pubspec)) { + Write-Error "Not found: $pubspec" + } + + $versionLine = Get-Content $pubspec | Select-String -Pattern '^\s*version:\s*' | Select-Object -First 1 + if (-not $versionLine) { + Write-Error "No version line in $pubspec" + } + $line = $versionLine.Line + if ($line -match '^\s*version:\s*([^+\s]+)') { + $baseVersion = $Matches[1].Trim() + } else { + Write-Error "Could not parse version from: $line" + } + + $buildName = "${baseVersion}-${SHA}" + $versionCode = 2000 + $COMMIT_COUNT + if ($App -eq "firka_wear") { + $versionCode += 1 + } + + Write-Host "Building $App : version $buildName (version code: $versionCode)" + Push-Location (Join-Path $ROOT $App) + try { + flutter pub get + dart run scripts/codegen.dart + flutter build appbundle --build-name="$buildName" --build-number="$versionCode" --verbose + } finally { + Pop-Location + } +} + +$target = if ($args.Count -gt 0) { $args[0] } else { "all" } + +switch ($target) { + "firka" { Build-App firka } + "firka_wear" { Build-App firka_wear } + "all" { Build-App firka; Build-App firka_wear } + default { + Write-Error "Usage: $MyInvocation.MyCommand.Name [firka|firka_wear|all]" + } +}