99 lines
4.3 KiB
PowerShell
99 lines
4.3 KiB
PowerShell
param (
|
|
[switch]$SkipTests = $false
|
|
)
|
|
|
|
$ErrorActionPreference = "Stop"
|
|
|
|
# Repository-Wurzelverzeichnis ermitteln
|
|
$ScriptDir = Split-Path -Parent $MyInvocation.MyCommand.Path
|
|
$ProjectRoot = Split-Path -Parent $ScriptDir
|
|
Set-Location $ProjectRoot
|
|
|
|
# Toolchain-Pfade sicherstellen (WinLibs GCC + Cargo)
|
|
$env:PATH = "C:\Users\pansih\AppData\Local\Microsoft\WinGet\Packages\BrechtSanders.WinLibs.POSIX.UCRT_Microsoft.Winget.Source_8wekyb3d8bbwe\mingw64\bin;C:\Users\pansih\.cargo\bin;C:\Program Files\Git\cmd;C:\Users\pansih\AppData\Local\Microsoft\WinGet\Links;" + $env:PATH
|
|
|
|
# Version aus Cargo.toml auslesen
|
|
$CargoToml = Get-Content (Join-Path $ProjectRoot "Cargo.toml") -Raw
|
|
if ($CargoToml -match 'version\s*=\s*"([^"]+)"') {
|
|
$Version = $matches[1]
|
|
} else {
|
|
Write-Error "Konnte Versionsnummer nicht aus Cargo.toml ermitteln."
|
|
exit 1
|
|
}
|
|
|
|
Write-Host "============================================================" -ForegroundColor Cyan
|
|
Write-Host " Sanctum Release Packaging v$Version (Windows x86_64)" -ForegroundColor Cyan
|
|
Write-Host "============================================================" -ForegroundColor Cyan
|
|
|
|
# 1. Tests ausfuehren
|
|
if (-not $SkipTests) {
|
|
Write-Host "`n[1/4] Fuehre Testsuite aus (cargo test --all)..." -ForegroundColor Yellow
|
|
cargo test --all
|
|
if ($LASTEXITCODE -ne 0) {
|
|
Write-Error "Tests fehlgeschlagen! Release-Erstellung abgebrochen."
|
|
exit $LASTEXITCODE
|
|
}
|
|
Write-Host "[OK] Alle Tests erfolgreich bestanden." -ForegroundColor Green
|
|
} else {
|
|
Write-Host "`n[1/4] Tests uebersprungen (-SkipTests)." -ForegroundColor DarkYellow
|
|
}
|
|
|
|
# 2. Release-Binary bauen
|
|
Write-Host "`n[2/4] Kompiliere Release-Binary mit LTO (cargo build --release)..." -ForegroundColor Yellow
|
|
cargo build --release
|
|
if ($LASTEXITCODE -ne 0) {
|
|
Write-Error "Release-Build fehlgeschlagen!"
|
|
exit $LASTEXITCODE
|
|
}
|
|
Write-Host "[OK] Release-Binary erfolgreich gebaut." -ForegroundColor Green
|
|
|
|
# 3. Release-Verzeichnisstruktur vorbereiten
|
|
Write-Host "`n[3/4] Erstelle Distributionspaket..." -ForegroundColor Yellow
|
|
|
|
$DistDir = Join-Path $ProjectRoot "dist"
|
|
$PackageName = "sanctum-v$Version-windows-x86_64"
|
|
$StagingDir = Join-Path $DistDir $PackageName
|
|
$ZipFile = Join-Path $DistDir "$PackageName.zip"
|
|
|
|
if (Test-Path $DistDir) {
|
|
Remove-Item $DistDir -Recurse -Force
|
|
}
|
|
New-Item -ItemType Directory -Path $StagingDir -Force | Out-Null
|
|
|
|
$ExeSource = Join-Path $ProjectRoot "target\release\sanctum.exe"
|
|
Copy-Item $ExeSource (Join-Path $StagingDir "sanctum.exe")
|
|
Copy-Item (Join-Path $ProjectRoot "README.md") (Join-Path $StagingDir "README.md")
|
|
Copy-Item (Join-Path $ProjectRoot "LICENSE") (Join-Path $StagingDir "LICENSE")
|
|
Copy-Item (Join-Path $ProjectRoot "LEGAL.md") (Join-Path $StagingDir "LEGAL.md")
|
|
Copy-Item (Join-Path $ProjectRoot "THIRD_PARTY_LICENSES.md") (Join-Path $StagingDir "THIRD_PARTY_LICENSES.md")
|
|
Copy-Item (Join-Path $ProjectRoot "CHANGELOG.md") (Join-Path $StagingDir "CHANGELOG.md")
|
|
Copy-Item (Join-Path $ProjectRoot "assets") (Join-Path $StagingDir "assets") -Recurse
|
|
|
|
# ZIP-Archiv schnueren
|
|
Compress-Archive -Path "$StagingDir\*" -DestinationPath $ZipFile -Force
|
|
Remove-Item $StagingDir -Recurse -Force
|
|
|
|
Write-Host "[OK] Archiv erstellt: $ZipFile" -ForegroundColor Green
|
|
|
|
# 4. SHA-256 Pruefsummen generieren
|
|
Write-Host "`n[4/4] Generiere SHA-256 Pruefsummen..." -ForegroundColor Yellow
|
|
|
|
$ZipHash = (Get-FileHash -Path $ZipFile -Algorithm SHA256).Hash.ToLower()
|
|
$ExeHash = (Get-FileHash -Path $ExeSource -Algorithm SHA256).Hash.ToLower()
|
|
|
|
$ChecksumFile = Join-Path $DistDir "SHA256SUMS.txt"
|
|
@("$ZipHash $PackageName.zip", "$ExeHash sanctum.exe") | Set-Content -Path $ChecksumFile -Encoding utf8
|
|
|
|
Write-Host "[OK] Pruefsummen in SHA256SUMS.txt gespeichert." -ForegroundColor Green
|
|
|
|
# Abschluss-Zusammenfassung
|
|
$ZipSize = (Get-Item $ZipFile).Length / 1MB
|
|
Write-Host "`n============================================================" -ForegroundColor Green
|
|
Write-Host " Sanctum Release v$Version erfolgreich gepackt!" -ForegroundColor Green
|
|
Write-Host "============================================================" -ForegroundColor Green
|
|
Write-Host " Archiv: dist\$PackageName.zip ($([math]::Round($ZipSize, 2)) MB)"
|
|
Write-Host " ZIP SHA-256: $ZipHash"
|
|
Write-Host " EXE SHA-256: $ExeHash"
|
|
Write-Host " Checksum-File: dist\SHA256SUMS.txt"
|
|
Write-Host "`nBereit fuer Gitea Release / Verteilung.`n"
|