SafeBite/build_apks.ps1
Bruno Charest c4add0a3fe feat: add user testing plan for SafeBite app
- Created a comprehensive user testing plan document to validate the app's usability, reliability, accessibility, and resilience.
- Included various test scenarios covering onboarding, product scanning, manual barcode entry, and accessibility features.

chore: update dependencies for code quality tools

- Added ktlint version 12.2.0 for Kotlin code style enforcement.
- Added detekt version 1.23.7 for static code analysis.

chore: increment version numbers

- Updated MINOR version to 32 and CODE to 43 in version.properties to reflect recent changes.
2026-05-11 15:13:18 -04:00

107 lines
3.2 KiB
PowerShell

param(
[switch]$Major,
[switch]$Minor,
[switch]$Patch,
[switch]$Help
)
if ($Help) {
Write-Host "Usage: .\build_apks.ps1 [-Major | -Minor | -Patch] [-Help]" -ForegroundColor White
Write-Host ""
Write-Host "Options:" -ForegroundColor White
Write-Host " -Major Increment the major version (X.0.0) and rebuild."
Write-Host " -Minor Increment the minor version (x.Y.0) and rebuild."
Write-Host " -Patch Increment the patch version (x.y.Z) and rebuild."
Write-Host " -Help Show this help message."
Write-Host ""
Write-Host "If no version switch is provided, the current version is used."
exit 0
}
$versionFile = Join-Path $PSScriptRoot "version.properties"
if (-not (Test-Path $versionFile)) {
Write-Host "version.properties not found! Creating default..." -ForegroundColor Yellow
"MAJOR=1`nMINOR=0`nPATCH=0`nCODE=1" | Out-File $versionFile -Encoding ascii
}
# Read properties using .NET file API to avoid locking
$rawContent = [System.IO.File]::ReadAllText($versionFile)
$properties = @{}
$rawContent -split "`r?`n" | ForEach-Object {
if ($_ -match "^(.*?)=(.*)$") {
$properties[$matches[1].Trim()] = $matches[2].Trim()
}
}
[int]$vMajor = $properties["MAJOR"]
[int]$vMinor = $properties["MINOR"]
[int]$vPatch = $properties["PATCH"]
[int]$vCode = $properties["CODE"]
$versionChanged = $false
if ($Major) {
$vMajor++
$vMinor = 0
$vPatch = 0
$versionChanged = $true
} elseif ($Minor) {
$vMinor++
$vPatch = 0
$versionChanged = $true
} elseif ($Patch) {
$vPatch++
$versionChanged = $true
}
if ($versionChanged) {
$vCode++
$newContent = "MAJOR=$vMajor`r`nMINOR=$vMinor`r`nPATCH=$vPatch`r`nCODE=$vCode"
[System.IO.File]::WriteAllText($versionFile, $newContent, [System.Text.Encoding]::ASCII)
Write-Host "Version incremented to: $vMajor.$vMinor.$vPatch (Code: $vCode)" -ForegroundColor Cyan
} else {
Write-Host "Current version: $vMajor.$vMinor.$vPatch (Code: $vCode)" -ForegroundColor Cyan
}
Write-Host "`n--- Cleaning and Building ---" -ForegroundColor Green
# Use cmd /c to ensure gradlew runs correctly from PowerShell if it's not in the PATH
$gradlew = ".\gradlew.bat"
if (-not (Test-Path $gradlew)) {
$gradlew = ".\gradlew"
if (-not (Test-Path $gradlew)) {
Write-Host "gradlew not found!" -ForegroundColor Red
exit 1
}
}
Write-Host "Task: :app:assembleDebug" -ForegroundColor Gray
if ($gradlew.EndsWith(".bat")) {
& cmd.exe /c $gradlew :app:assembleDebug
} else {
& $gradlew :app:assembleDebug
}
if ($LASTEXITCODE -ne 0) {
Write-Host "Debug build failed!" -ForegroundColor Red
exit $LASTEXITCODE
}
Write-Host "`nTask: :app:assembleRelease" -ForegroundColor Gray
if ($gradlew.EndsWith(".bat")) {
& cmd.exe /c $gradlew :app:assembleRelease
} else {
& $gradlew :app:assembleRelease
}
if ($LASTEXITCODE -ne 0) {
Write-Host "Release build failed!" -ForegroundColor Red
exit $LASTEXITCODE
}
Write-Host "`n--- Build Successful ---" -ForegroundColor Green
Write-Host "APKs available at:"
Write-Host " Debug: app\build\outputs\apk\debug\app-debug.apk" -ForegroundColor Yellow
Write-Host " Release: app\build\outputs\apk\release\app-release.apk" -ForegroundColor Yellow