cmvr-wms/mobile-app/scripts/Build-Production.ps1

31 lines
1.8 KiB
PowerShell
Raw Normal View History

param([string]$ApiUrl = 'http://192.168.28.10/prod-api', [string]$UpdateOrigin = 'http://192.168.28.10')
$ErrorActionPreference = 'Stop'
$taskApp = Split-Path $PSScriptRoot -Parent
$taskRepo = Split-Path $taskApp -Parent
$taskSigning = Join-Path $taskApp 'keys/production'
try {
$taskSecret = (Get-Content -LiteralPath (Join-Path $taskSigning 'credentials.dpapi') -Raw).Trim() | ConvertTo-SecureString
$taskPtr = [Runtime.InteropServices.Marshal]::SecureStringToBSTR($taskSecret)
try { $taskCredentials = [Runtime.InteropServices.Marshal]::PtrToStringBSTR($taskPtr) | ConvertFrom-Json }
finally { [Runtime.InteropServices.Marshal]::ZeroFreeBSTR($taskPtr) }
} catch {
$taskProtected = [IO.File]::ReadAllBytes((Join-Path $taskSigning 'credentials.machine.dpapi'))
$taskUnprotected = [System.Security.Cryptography.ProtectedData]::Unprotect($taskProtected, $null, [System.Security.Cryptography.DataProtectionScope]::LocalMachine)
$taskCredentials = [Text.Encoding]::UTF8.GetString($taskUnprotected) | ConvertFrom-Json
[Array]::Clear($taskUnprotected, 0, $taskUnprotected.Length)
}
try {
$env:APP_API_URL = $ApiUrl
$env:APP_UPDATE_ORIGIN = $UpdateOrigin
$env:CMVR_KEYSTORE = Join-Path $taskSigning 'cmvr-production.p12'
$env:CMVR_STORE_PASSWORD = $taskCredentials.storePassword
$env:CMVR_KEY_PASSWORD = $taskCredentials.storePassword
$env:CMVR_KEY_ALIAS = $taskCredentials.alias
& (Join-Path $PSScriptRoot 'Build-Android.ps1') -Environment prod -GradlePath (Join-Path $taskRepo '.codex-tmp/expo-tools/gradle-9.4.1/bin/gradle.bat')
} finally {
foreach ($taskName in @('CMVR_KEYSTORE','CMVR_STORE_PASSWORD','CMVR_KEY_PASSWORD','CMVR_KEY_ALIAS')) {
Remove-Item -LiteralPath "Env:$taskName" -ErrorAction SilentlyContinue
}
$taskCredentials = $null
}