chore: deploy.ps1 entfernt (Logik in publish-apk.ps1)
This commit is contained in:
parent
76ad50e3aa
commit
f3eab7b10d
1 changed files with 0 additions and 133 deletions
133
deploy.ps1
133
deploy.ps1
|
|
@ -1,133 +0,0 @@
|
||||||
<#
|
|
||||||
.SYNOPSIS
|
|
||||||
Bollwerk App in einem Schritt deployen.
|
|
||||||
.DESCRIPTION
|
|
||||||
Führt den vollständigen Release-Workflow aus:
|
|
||||||
1. versionCode automatisch erhöhen (versionName optional setzen)
|
|
||||||
2. APK bauen (./gradlew assembleDebug)
|
|
||||||
3. APK per SCP auf VPS hochladen
|
|
||||||
4. Server-Version per API aktualisieren (kein Container-Neustart)
|
|
||||||
5. Version-Bump committen und pushen
|
|
||||||
.PARAMETER VersionName
|
|
||||||
Neue versionName (z.B. "1.8"). Wenn weggelassen, bleibt die aktuelle.
|
|
||||||
.PARAMETER SkipBuild
|
|
||||||
Gradle-Build überspringen (wenn APK bereits gebaut).
|
|
||||||
.PARAMETER SkipPush
|
|
||||||
Git-Push überspringen (nur lokaler Commit).
|
|
||||||
.EXAMPLE
|
|
||||||
.\deploy.ps1
|
|
||||||
.\deploy.ps1 -VersionName "2.0"
|
|
||||||
.\deploy.ps1 -SkipBuild
|
|
||||||
#>
|
|
||||||
param(
|
|
||||||
[string] $VersionName,
|
|
||||||
[switch] $SkipBuild,
|
|
||||||
[switch] $SkipPush
|
|
||||||
)
|
|
||||||
|
|
||||||
$ErrorActionPreference = "Stop"
|
|
||||||
$VPS = "root@195.246.231.210"
|
|
||||||
$RemoteDir = "/opt/bollwerk"
|
|
||||||
$ServerUrl = "https://bollwerk.online"
|
|
||||||
$BuildGradle = "app/build.gradle.kts"
|
|
||||||
$ApkPath = "app/build/outputs/apk/debug/app-debug.apk"
|
|
||||||
|
|
||||||
# --- Admin-Token ---
|
|
||||||
$AdminToken = $env:BOLLWERK_ADMIN_TOKEN
|
|
||||||
if (-not $AdminToken) {
|
|
||||||
Write-Error @"
|
|
||||||
BOLLWERK_ADMIN_TOKEN nicht gesetzt.
|
|
||||||
Bitte einmalig in der Session setzen:
|
|
||||||
`$env:BOLLWERK_ADMIN_TOKEN = 'tRIdxACDDjJDOXRd0WDnIN2f'
|
|
||||||
"@
|
|
||||||
exit 1
|
|
||||||
}
|
|
||||||
|
|
||||||
# --- Version lesen ---
|
|
||||||
$content = Get-Content $BuildGradle -Raw
|
|
||||||
$currentCode = [int]([regex]::Match($content, 'versionCode\s*=\s*(\d+)').Groups[1].Value)
|
|
||||||
$currentName = [regex]::Match($content, 'versionName\s*=\s*"([^"]+)"').Groups[1].Value
|
|
||||||
$newCode = $currentCode + 1
|
|
||||||
$newName = if ($VersionName) { $VersionName } else { $currentName }
|
|
||||||
|
|
||||||
Write-Host ""
|
|
||||||
Write-Host "╔══════════════════════════════════════╗" -ForegroundColor Cyan
|
|
||||||
Write-Host "║ Bollwerk Deploy ║" -ForegroundColor Cyan
|
|
||||||
Write-Host "╚══════════════════════════════════════╝" -ForegroundColor Cyan
|
|
||||||
Write-Host " Version: $currentName ($currentCode) → $newName ($newCode)" -ForegroundColor White
|
|
||||||
Write-Host ""
|
|
||||||
|
|
||||||
# --- build.gradle.kts patchen ---
|
|
||||||
$updated = $content -replace "versionCode\s*=\s*$currentCode", "versionCode = $newCode"
|
|
||||||
if ($VersionName) {
|
|
||||||
$updated = $updated -replace 'versionName\s*=\s*"[^"]+"', "versionName = `"$newName`""
|
|
||||||
}
|
|
||||||
[System.IO.File]::WriteAllText((Resolve-Path $BuildGradle).Path, $updated)
|
|
||||||
Write-Host "[✓] build.gradle.kts aktualisiert" -ForegroundColor Green
|
|
||||||
|
|
||||||
# --- Build ---
|
|
||||||
if (-not $SkipBuild) {
|
|
||||||
Write-Host ""
|
|
||||||
Write-Host "[1/4] APK bauen..." -ForegroundColor Yellow
|
|
||||||
& ./gradlew assembleDebug
|
|
||||||
if ($LASTEXITCODE -ne 0) { Write-Error "Build fehlgeschlagen."; exit 1 }
|
|
||||||
Write-Host "[✓] APK gebaut" -ForegroundColor Green
|
|
||||||
} else {
|
|
||||||
Write-Host "[1/4] Build übersprungen (-SkipBuild)" -ForegroundColor DarkYellow
|
|
||||||
}
|
|
||||||
|
|
||||||
if (-not (Test-Path $ApkPath)) {
|
|
||||||
Write-Error "APK nicht gefunden: $ApkPath"
|
|
||||||
exit 1
|
|
||||||
}
|
|
||||||
|
|
||||||
# --- SSH-Agent prüfen ---
|
|
||||||
$null = ssh-add -l 2>&1
|
|
||||||
if ($LASTEXITCODE -ne 0) {
|
|
||||||
Write-Error "SSH-Agent hat keinen Key. Bitte 'ssh-add' ausführen."
|
|
||||||
exit 1
|
|
||||||
}
|
|
||||||
|
|
||||||
# --- APK hochladen ---
|
|
||||||
Write-Host ""
|
|
||||||
Write-Host "[2/4] APK hochladen → VPS..." -ForegroundColor Yellow
|
|
||||||
ssh $VPS "mkdir -p $RemoteDir/data" 2>&1 | Out-Null
|
|
||||||
scp $ApkPath "${VPS}:${RemoteDir}/data/app-latest.apk"
|
|
||||||
if ($LASTEXITCODE -ne 0) { Write-Error "APK-Upload fehlgeschlagen."; exit 1 }
|
|
||||||
Write-Host "[✓] APK hochgeladen" -ForegroundColor Green
|
|
||||||
|
|
||||||
# --- Server-Version setzen ---
|
|
||||||
Write-Host ""
|
|
||||||
Write-Host "[3/4] Server-Version aktualisieren..." -ForegroundColor Yellow
|
|
||||||
$body = @{ versionCode = $newCode; versionName = $newName } | ConvertTo-Json -Compress
|
|
||||||
try {
|
|
||||||
$resp = Invoke-WebRequest -Uri "$ServerUrl/api/admin/version" `
|
|
||||||
-Method POST `
|
|
||||||
-Headers @{ "Authorization" = "Bearer $AdminToken"; "Content-Type" = "application/json" } `
|
|
||||||
-Body $body `
|
|
||||||
-UseBasicParsing
|
|
||||||
Write-Host "[✓] Version gesetzt: $newName ($newCode)" -ForegroundColor Green
|
|
||||||
} catch {
|
|
||||||
Write-Error "Version-Update fehlgeschlagen: $_"
|
|
||||||
exit 1
|
|
||||||
}
|
|
||||||
|
|
||||||
# --- Git Commit + Push ---
|
|
||||||
Write-Host ""
|
|
||||||
Write-Host "[4/4] Committen..." -ForegroundColor Yellow
|
|
||||||
git add $BuildGradle
|
|
||||||
git commit -m "chore: release v$newName ($newCode)"
|
|
||||||
if (-not $SkipPush) {
|
|
||||||
git push
|
|
||||||
Write-Host "[✓] Gepusht" -ForegroundColor Green
|
|
||||||
}
|
|
||||||
|
|
||||||
# --- Fertig ---
|
|
||||||
Write-Host ""
|
|
||||||
Write-Host "╔══════════════════════════════════════╗" -ForegroundColor Green
|
|
||||||
Write-Host "║ Deploy abgeschlossen ✓ ║" -ForegroundColor Green
|
|
||||||
Write-Host "╚══════════════════════════════════════╝" -ForegroundColor Green
|
|
||||||
Write-Host " App-Version : $newName ($newCode)"
|
|
||||||
Write-Host " Homepage : $ServerUrl/"
|
|
||||||
Write-Host " APK-Download: $ServerUrl/static/app-latest.apk"
|
|
||||||
Write-Host ""
|
|
||||||
Loading…
Reference in a new issue