Use .buildcount file for unique auto-incrementing versionCode
Build counter is incremented by deploy.ps1 on every deploy, ensuring unique versionCode even from the same commit. File is gitignored.
This commit is contained in:
15
deploy.ps1
15
deploy.ps1
@@ -11,17 +11,24 @@ $ErrorActionPreference = "Stop"
|
||||
$AppId = "25653777174321448"
|
||||
$Token = "OC|25653777174321448|b861e3eeaf58edf097812b5fe588dabb"
|
||||
$OvrUtil = "$PSScriptRoot\ovr-platform-util.exe"
|
||||
$BuildCountFile = "$PSScriptRoot\.buildcount"
|
||||
|
||||
# --- Increment build count ---
|
||||
$buildCount = 1
|
||||
if (Test-Path $BuildCountFile) {
|
||||
$buildCount = [int](Get-Content $BuildCountFile -Raw).Trim() + 1
|
||||
}
|
||||
Set-Content $BuildCountFile $buildCount -NoNewline
|
||||
Write-Host "Build #$buildCount" -ForegroundColor Cyan
|
||||
|
||||
# --- 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"
|
||||
$displayVersion = "$versionName+$buildCount.$shortHash"
|
||||
|
||||
Write-Host "Version: $displayVersion (versionCode=$commitCount)" -ForegroundColor Cyan
|
||||
Write-Host "Version: $displayVersion (versionCode=$buildCount)" -ForegroundColor Cyan
|
||||
|
||||
# --- Build APK ---
|
||||
$task = if ($BuildType -eq "release") { ":app:assembleRelease" } else { ":app:assembleDebug" }
|
||||
|
||||
Reference in New Issue
Block a user