# publish_update.ps1 - Upload Installer + Manifest nach Hetzner # Laedt in release/ UND release/downloads/ hoch (beide Pfade). $ErrorActionPreference = "Stop" $projectRoot = $PSScriptRoot $remoteHost = "root@178.104.51.177" $remotePath = "/root/aza-app/release" $remoteDownloadsPath = "/root/aza-app/release/downloads" $installerPath = Join-Path $projectRoot "dist\installer\aza_desktop_setup.exe" $manifestPath = Join-Path $projectRoot "release\version.json" Write-Host "" # --- [1/4] --- Write-Host "[1/4] Lokale Dateien pruefen..." if (-not (Test-Path $installerPath)) { Write-Error "ABBRUCH: $installerPath nicht gefunden." exit 1 } $sizeMB = [math]::Round((Get-Item $installerPath).Length / 1MB, 2) Write-Host " Installer OK ($sizeMB MB)" if (-not (Test-Path $manifestPath)) { Write-Error "ABBRUCH: $manifestPath nicht gefunden." exit 1 } Write-Host " version.json OK" # --- [2/4] --- Write-Host "[2/4] Installer hochladen (release/ und release/downloads/)..." scp "$installerPath" "${remoteHost}:${remotePath}/aza_desktop_setup.exe" if ($LASTEXITCODE -ne 0) { Write-Error "ABBRUCH: Installer-Upload fehlgeschlagen." exit 1 } Write-Host " release/ OK" # In den oeffentlichen Downloads-Ordner kopieren # (https://api.aza-medwork.ch/downloads/aza_desktop_setup.exe) ssh $remoteHost "cp ${remotePath}/aza_desktop_setup.exe ${remoteDownloadsPath}/aza_desktop_setup.exe" if ($LASTEXITCODE -ne 0) { Write-Warning "Warnung: Kopieren in downloads/ fehlgeschlagen." } else { Write-Host " release/downloads/ OK" } # --- [3/4] --- Write-Host "[3/4] Manifest hochladen..." scp "$manifestPath" "${remoteHost}:${remotePath}/version.json" if ($LASTEXITCODE -ne 0) { Write-Error "ABBRUCH: Manifest-Upload fehlgeschlagen." exit 1 } Write-Host " version.json OK" # --- [4/4] --- Write-Host "[4/4] Remote-Verifizierung (Groesse + SHA256-Abgleich)..." ssh $remoteHost "ls -lh ${remotePath}/aza_desktop_setup.exe && ls -lh ${remoteDownloadsPath}/aza_desktop_setup.exe && ls -lh ${remotePath}/version.json" Write-Host "" Write-Host " SHA256-Vergleich (release/ vs. downloads/)..." $hashOutput = ssh $remoteHost "sha256sum ${remotePath}/aza_desktop_setup.exe ${remoteDownloadsPath}/aza_desktop_setup.exe 2>/dev/null" Write-Host $hashOutput $hashes = $hashOutput -split "`n" | Where-Object { $_ -match "^[0-9a-f]{64}" } | ForEach-Object { ($_ -split "\s+")[0] } if ($hashes.Count -eq 2 -and $hashes[0] -eq $hashes[1]) { Write-Host " SHA256 identisch: beide Pfade OK." -ForegroundColor Green } elseif ($hashes.Count -lt 2) { Write-Warning " SHA256 konnte nicht verglichen werden (Dateien fehlen?)." } else { Write-Error "WARNUNG: SHA256 der oeffentlichen URL weicht ab! release/downloads/ wurde moeglicherweise nicht aktualisiert." } Write-Host "" ssh $remoteHost "curl -sI https://api.aza-medwork.ch/downloads/aza_desktop_setup.exe | head -4" Write-Host "" Write-Host "UPLOAD FERTIG" Write-Host ""