- 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
50 lines
1.6 KiB
PowerShell
50 lines
1.6 KiB
PowerShell
param(
|
|
[Parameter(Mandatory=$true)]
|
|
[string]$Channel,
|
|
|
|
[ValidateSet("release", "debug")]
|
|
[string]$BuildType = "release"
|
|
)
|
|
|
|
$ErrorActionPreference = "Stop"
|
|
|
|
$AppId = "25653777174321448"
|
|
$Token = "OC|25653777174321448|b861e3eeaf58edf097812b5fe588dabb"
|
|
$OvrUtil = "$PSScriptRoot\ovr-platform-util.exe"
|
|
|
|
# --- 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" }
|
|
Write-Host "Building $BuildType APK..." -ForegroundColor Cyan
|
|
& "$PSScriptRoot\gradlew.bat" $task
|
|
if ($LASTEXITCODE -ne 0) { Write-Error "Build failed" }
|
|
|
|
$apk = "$PSScriptRoot\app\build\outputs\apk\$BuildType\app-$BuildType.apk"
|
|
if (-not (Test-Path $apk)) { Write-Error "APK not found: $apk" }
|
|
|
|
Write-Host "APK: $apk" -ForegroundColor Green
|
|
|
|
# --- Upload ---
|
|
Write-Host "Uploading to channel '$Channel'..." -ForegroundColor Cyan
|
|
& $OvrUtil upload-quest-build `
|
|
--app-id $AppId `
|
|
--token $Token `
|
|
--apk $apk `
|
|
--channel $Channel `
|
|
--age-group MIXED_AGES `
|
|
--notes "$displayVersion $BuildType build"
|
|
|
|
if ($LASTEXITCODE -ne 0) { Write-Error "Upload failed" }
|
|
|
|
Write-Host "Deployed $displayVersion ($BuildType) to '$Channel'" -ForegroundColor Green
|