51 lines
1.5 KiB
PowerShell
51 lines
1.5 KiB
PowerShell
param(
|
|
[string]$Version = "0.1.0",
|
|
[int]$VersionCode = 1,
|
|
[string]$Channel = "stable"
|
|
)
|
|
|
|
$ErrorActionPreference = "Stop"
|
|
$root = Resolve-Path "$PSScriptRoot\.."
|
|
$apk = Join-Path $root "android\app\build\outputs\apk\release\app-release.apk"
|
|
$releaseDir = Join-Path $root "deploy\releases\android"
|
|
|
|
Push-Location (Join-Path $root "android")
|
|
try {
|
|
.\gradlew.bat :app:assembleRelease --console=plain --no-daemon
|
|
}
|
|
finally {
|
|
Pop-Location
|
|
}
|
|
|
|
if (!(Test-Path $apk)) {
|
|
throw "Release APK was not produced: $apk"
|
|
}
|
|
|
|
New-Item -ItemType Directory -Force -Path $releaseDir | Out-Null
|
|
$targetName = "qmax-$Version-$Channel.apk"
|
|
$target = Join-Path $releaseDir $targetName
|
|
Copy-Item -LiteralPath $apk -Destination $target -Force
|
|
|
|
$hash = (Get-FileHash -Algorithm SHA256 -LiteralPath $target).Hash.ToLowerInvariant()
|
|
$size = (Get-Item -LiteralPath $target).Length
|
|
$manifest = [ordered]@{
|
|
slug = "qmax"
|
|
name = "QMAX"
|
|
version = $Version
|
|
androidVersionCode = $VersionCode
|
|
channel = $Channel
|
|
platform = "android"
|
|
packageKind = "apk"
|
|
downloadPath = "/api/app-updates/android/download/$targetName"
|
|
packageSizeBytes = $size
|
|
sha256 = $hash
|
|
notes = "QMAX $Version"
|
|
publishedAt = (Get-Date).ToUniversalTime().ToString("O")
|
|
}
|
|
|
|
$manifestJson = $manifest | ConvertTo-Json -Depth 4
|
|
$utf8NoBom = New-Object System.Text.UTF8Encoding($false)
|
|
[System.IO.File]::WriteAllText((Join-Path $releaseDir "latest.json"), $manifestJson, $utf8NoBom)
|
|
Write-Host "Packaged $targetName"
|
|
Write-Host "SHA-256 $hash"
|