-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathbuild.ps1
More file actions
52 lines (44 loc) · 1.42 KB
/
build.ps1
File metadata and controls
52 lines (44 loc) · 1.42 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
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]"
}
}