param( [Parameter(Mandatory=$true)] [string]$Channel, [ValidateSet("release", "debug")] [string]$BuildType = "release" ) $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" } # --- 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 "v$newCode $BuildType build" if ($LASTEXITCODE -ne 0) { Write-Error "Upload failed" } Write-Host "Deployed versionCode $newCode ($BuildType) to '$Channel'" -ForegroundColor Green