48 lines
1.6 KiB
PowerShell
48 lines
1.6 KiB
PowerShell
param()
|
|
|
|
$ErrorActionPreference = 'Stop'
|
|
|
|
$required = @(
|
|
'DESKHUB_RELEASE_STORE_FILE',
|
|
'DESKHUB_RELEASE_STORE_PASSWORD',
|
|
'DESKHUB_RELEASE_KEY_ALIAS',
|
|
'DESKHUB_RELEASE_KEY_PASSWORD'
|
|
)
|
|
|
|
$missing = @($required | Where-Object { [string]::IsNullOrWhiteSpace([Environment]::GetEnvironmentVariable($_)) })
|
|
if ($missing.Count -gt 0) {
|
|
throw "Fehlende Umgebungsvariablen: $($missing -join ', ')"
|
|
}
|
|
|
|
$storeFile = [Environment]::GetEnvironmentVariable('DESKHUB_RELEASE_STORE_FILE')
|
|
if (-not (Test-Path -LiteralPath $storeFile -PathType Leaf)) {
|
|
throw "Keystore nicht gefunden: $storeFile"
|
|
}
|
|
|
|
$projectRoot = $PSScriptRoot
|
|
$javaHome = [Environment]::GetEnvironmentVariable('JAVA_HOME')
|
|
if ([string]::IsNullOrWhiteSpace($javaHome)) {
|
|
throw 'JAVA_HOME muss auf ein JDK 17 zeigen.'
|
|
}
|
|
|
|
Push-Location $projectRoot
|
|
try {
|
|
& "$projectRoot\gradlew.bat" clean assembleRelease --no-daemon --console=plain
|
|
if ($LASTEXITCODE -ne 0) {
|
|
throw "Release-Build fehlgeschlagen (Exitcode $LASTEXITCODE)."
|
|
}
|
|
|
|
$source = "$projectRoot\build\outputs\apk\release\DeskHubMobile-release.apk"
|
|
if (-not (Test-Path -LiteralPath $source -PathType Leaf)) {
|
|
throw 'Signierte Release-APK wurde nicht erzeugt.'
|
|
}
|
|
|
|
$artifactDirectory = "$projectRoot\artifacts"
|
|
New-Item -ItemType Directory -Path $artifactDirectory -Force | Out-Null
|
|
$target = "$artifactDirectory\deskhub-employee-release.apk"
|
|
Copy-Item -LiteralPath $source -Destination $target -Force
|
|
Get-FileHash -Algorithm SHA256 -LiteralPath $target
|
|
} finally {
|
|
Pop-Location
|
|
}
|