26 lines
891 B
PowerShell
26 lines
891 B
PowerShell
param([string]$ApkPath = 'app\build\outputs\apk\debug\app-debug.apk')
|
|
|
|
$ErrorActionPreference = 'Stop'
|
|
$toolchain = . (Join-Path $PSScriptRoot 'env.ps1')
|
|
$artifact = if ([IO.Path]::IsPathRooted($ApkPath)) { $ApkPath } else { Join-Path $toolchain.Root $ApkPath }
|
|
$artifact = Get-DPath $artifact
|
|
$signer = Get-DPath (Join-Path $env:ANDROID_HOME 'build-tools\34.0.0\apksigner.bat')
|
|
|
|
foreach ($path in @($artifact, $signer, $toolchain.Java)) {
|
|
if (-not (Test-Path -LiteralPath $path -PathType Leaf)) {
|
|
throw "Missing APK verification input: $path"
|
|
}
|
|
}
|
|
|
|
Push-Location -LiteralPath $toolchain.Root
|
|
try {
|
|
& $signer verify --verbose --print-certs $artifact
|
|
$signatureExitCode = $LASTEXITCODE
|
|
} finally {
|
|
Pop-Location
|
|
}
|
|
if ($signatureExitCode -ne 0) {
|
|
exit $signatureExitCode
|
|
}
|
|
Get-FileHash -LiteralPath $artifact -Algorithm SHA256 | Format-List Algorithm, Hash, Path
|