Add git-based versioning and build version display

- versionCode from commit count + offset (always incremental)
- versionName from git tag (semantic versioning)
- BuildConfig.DISPLAY_VERSION shows "0.1.0+N.hash" in login screen
- Updated deploy.ps1 to use git versioning instead of manual bumps
This commit is contained in:
2026-02-24 12:06:57 +01:00
parent 82aa207f9a
commit 9259b0fb28
2 changed files with 21 additions and 19 deletions

View File

@@ -10,20 +10,18 @@ $ErrorActionPreference = "Stop"
$AppId = "25653777174321448"
$Token = "OC|25653777174321448|b861e3eeaf58edf097812b5fe588dabb"
$BuildGradle = "$PSScriptRoot\app\build.gradle.kts"
$OvrUtil = "$PSScriptRoot\ovr-platform-util.exe"
# --- Bump versionCode ---
$content = Get-Content $BuildGradle -Raw
if ($content -match 'versionCode\s*=\s*(\d+)') {
$oldCode = [int]$Matches[1]
$newCode = $oldCode + 1
$content = $content -replace "versionCode\s*=\s*$oldCode", "versionCode = $newCode"
Set-Content $BuildGradle $content -NoNewline
Write-Host "Bumped versionCode: $oldCode -> $newCode" -ForegroundColor Cyan
} else {
Write-Error "Could not find versionCode in build.gradle.kts"
}
# --- Git version info ---
$versionName = (git describe --tags --abbrev=0 2>$null) -replace '^v', ''
if (-not $versionName) { $versionName = "0.1.0" }
$commitCount = git rev-list --count HEAD 2>$null
if (-not $commitCount) { $commitCount = "1" }
$shortHash = git rev-parse --short HEAD 2>$null
if (-not $shortHash) { $shortHash = "unknown" }
$displayVersion = "$versionName+$commitCount.$shortHash"
Write-Host "Version: $displayVersion (versionCode=$commitCount)" -ForegroundColor Cyan
# --- Build APK ---
$task = if ($BuildType -eq "release") { ":app:assembleRelease" } else { ":app:assembleDebug" }
@@ -44,8 +42,8 @@ Write-Host "Uploading to channel '$Channel'..." -ForegroundColor Cyan
--apk $apk `
--channel $Channel `
--age-group MIXED_AGES `
--notes "v$newCode $BuildType build"
--notes "$displayVersion $BuildType build"
if ($LASTEXITCODE -ne 0) { Write-Error "Upload failed" }
Write-Host "Deployed versionCode $newCode ($BuildType) to '$Channel'" -ForegroundColor Green
Write-Host "Deployed $displayVersion ($BuildType) to '$Channel'" -ForegroundColor Green