feat(linux): add static musl x86_64 build, packaging, and Freedesktop integration
Sanctum Release / Build & Release (Windows x86_64) (push) Canceled after 0s
Sanctum Release / Build & Release (Windows x86_64) (push) Canceled after 0s
This commit is contained in:
@@ -0,0 +1,119 @@
|
||||
param (
|
||||
[switch]$SkipBuild = $false
|
||||
)
|
||||
|
||||
$ErrorActionPreference = "Stop"
|
||||
|
||||
# Repository-Wurzelverzeichnis ermitteln
|
||||
$ScriptDir = Split-Path -Parent $MyInvocation.MyCommand.Path
|
||||
$ProjectRoot = Split-Path -Parent $ScriptDir
|
||||
Set-Location $ProjectRoot
|
||||
|
||||
# Toolchain-Pfade sicherstellen (Zig + Cargo Bin)
|
||||
$ZigDir = "C:\Users\pansih\AppData\Local\Microsoft\WinGet\Packages\zig.zig_Microsoft.Winget.Source_8wekyb3d8bbwe\zig-x86_64-windows-0.16.0"
|
||||
$env:PATH = "$ZigDir;C:\Users\pansih\.cargo\bin;C:\Windows\System32;" + $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 Linux Release Packaging v$Version (x86_64 musl)" -ForegroundColor Cyan
|
||||
Write-Host "============================================================" -ForegroundColor Cyan
|
||||
|
||||
# 1. Linux Release-Binary bauen
|
||||
$Target = "x86_64-unknown-linux-musl"
|
||||
$BinaryPath = Join-Path $ProjectRoot "target\$Target\release\sanctum"
|
||||
|
||||
if (-not $SkipBuild -or -not (Test-Path $BinaryPath)) {
|
||||
Write-Host "`n[1/3] Kompiliere statisches Linux-Binary via cargo-zigbuild..." -ForegroundColor Yellow
|
||||
cargo-zigbuild.exe zigbuild --target $Target --release
|
||||
if ($LASTEXITCODE -ne 0) {
|
||||
Write-Error "Linux-Build fehlgeschlagen!"
|
||||
exit $LASTEXITCODE
|
||||
}
|
||||
Write-Host "[OK] Linux-Binary erfolgreich gebaut." -ForegroundColor Green
|
||||
} else {
|
||||
Write-Host "`n[1/3] Build uebersprungen (-SkipBuild)." -ForegroundColor DarkYellow
|
||||
}
|
||||
|
||||
# 2. Release-Verzeichnisstruktur vorbereiten
|
||||
Write-Host "`n[2/3] Erstelle Linux-Distributionspaket..." -ForegroundColor Yellow
|
||||
|
||||
$DistDir = Join-Path $ProjectRoot "dist"
|
||||
if (-not (Test-Path $DistDir)) {
|
||||
New-Item -ItemType Directory -Path $DistDir -Force | Out-Null
|
||||
}
|
||||
|
||||
$PackageName = "sanctum-v$Version-linux-x86_64"
|
||||
$StagingDir = Join-Path $DistDir $PackageName
|
||||
$TarGzFile = Join-Path $DistDir "$PackageName.tar.gz"
|
||||
|
||||
if (Test-Path $StagingDir) {
|
||||
Remove-Item $StagingDir -Recurse -Force
|
||||
}
|
||||
New-Item -ItemType Directory -Path $StagingDir -Force | Out-Null
|
||||
|
||||
# Dateien kopieren
|
||||
Copy-Item $BinaryPath -Destination (Join-Path $StagingDir "sanctum") -Force
|
||||
Copy-Item (Join-Path $ProjectRoot "README.md") -Destination $StagingDir -Force
|
||||
Copy-Item (Join-Path $ProjectRoot "LICENSE") -Destination $StagingDir -Force
|
||||
Copy-Item (Join-Path $ProjectRoot "CHANGELOG.md") -Destination $StagingDir -Force
|
||||
Copy-Item (Join-Path $ProjectRoot "INSTALL.md") -Destination $StagingDir -Force
|
||||
Copy-Item (Join-Path $ProjectRoot "QUICKSTART.md") -Destination $StagingDir -Force
|
||||
Copy-Item (Join-Path $ProjectRoot "LEGAL.md") -Destination $StagingDir -Force
|
||||
Copy-Item (Join-Path $ProjectRoot "THIRD_PARTY_LICENSES.md") -Destination $StagingDir -Force
|
||||
|
||||
# .tar.gz Archiv erstellen mit Windows nativem bsdtar
|
||||
if (Test-Path $TarGzFile) {
|
||||
Remove-Item $TarGzFile -Force
|
||||
}
|
||||
|
||||
tar.exe -czf $TarGzFile -C $DistDir $PackageName
|
||||
if ($LASTEXITCODE -ne 0) {
|
||||
Write-Error "Fehler beim Erstellen des tar.gz-Archivs!"
|
||||
exit $LASTEXITCODE
|
||||
}
|
||||
|
||||
# Staging-Verzeichnis bereinigen
|
||||
Remove-Item $StagingDir -Recurse -Force
|
||||
|
||||
Write-Host "[OK] Archiv erstellt: $TarGzFile" -ForegroundColor Green
|
||||
|
||||
# 3. SHA-256 Pruefsummen berechnen und aktualisieren
|
||||
Write-Host "`n[3/3] Aktualisiere SHA-256 Pruefsummen..." -ForegroundColor Yellow
|
||||
|
||||
$ChecksumFile = Join-Path $DistDir "SHA256SUMS.txt"
|
||||
$TarHash = (Get-FileHash -Path $TarGzFile -Algorithm SHA256).Hash.ToLower()
|
||||
$ElfHash = (Get-FileHash -Path $BinaryPath -Algorithm SHA256).Hash.ToLower()
|
||||
|
||||
# Existierende Pruefsummen lesen und um Linux-Assets ergaenzen/aktualisieren
|
||||
$ExistingLines = if (Test-Path $ChecksumFile) {
|
||||
Get-Content $ChecksumFile | Where-Object { $_ -notmatch "$PackageName\.tar\.gz" -and $_ -notmatch "\s+sanctum$" }
|
||||
} else {
|
||||
@()
|
||||
}
|
||||
|
||||
$AllLines = @()
|
||||
$AllLines += $ExistingLines
|
||||
$AllLines += "$TarHash $PackageName.tar.gz"
|
||||
$AllLines += "$ElfHash sanctum"
|
||||
|
||||
$AllLines | Set-Content -Path $ChecksumFile -Encoding utf8
|
||||
|
||||
$TarSizeMB = [math]::Round((Get-Item $TarGzFile).Length / 1MB, 2)
|
||||
$ElfSizeMB = [math]::Round((Get-Item $BinaryPath).Length / 1MB, 2)
|
||||
|
||||
Write-Host "`n============================================================" -ForegroundColor Green
|
||||
Write-Host " Sanctum Linux Release v$Version erfolgreich gepackt!" -ForegroundColor Green
|
||||
Write-Host "============================================================" -ForegroundColor Green
|
||||
Write-Host " Archiv: $TarGzFile ($TarSizeMB MB)"
|
||||
Write-Host " TAR SHA-256: $TarHash"
|
||||
Write-Host " ELF SHA-256: $ElfHash"
|
||||
Write-Host " Checksum-File: $ChecksumFile"
|
||||
Write-Host "`nBereit fuer Gitea Release."
|
||||
+43
-29
@@ -108,42 +108,56 @@ if (-not $Release) {
|
||||
$UploadUrl = "$GiteaUrl/api/v1/repos/$Owner/$Repo/releases/$($Release.id)/assets"
|
||||
$AuthHeader = "Authorization: token $Token"
|
||||
|
||||
# ZIP Asset hochladen
|
||||
Write-Host "Lade sanctum-$TagName-windows-x86_64.zip hoch..." -ForegroundColor Cyan
|
||||
$ZipPathNorm = $ZipFile.Replace('\', '/')
|
||||
$ZipUrl = "${UploadUrl}?name=sanctum-$TagName-windows-x86_64.zip"
|
||||
$ZipResult = & curl.exe -sS -X POST $ZipUrl -H $AuthHeader -F "attachment=@$ZipPathNorm"
|
||||
if ($LASTEXITCODE -ne 0) {
|
||||
Write-Error "Upload von sanctum-$TagName-windows-x86_64.zip fehlgeschlagen: $ZipResult"
|
||||
exit 1
|
||||
}
|
||||
Write-Host "[OK] sanctum-$TagName-windows-x86_64.zip hochgeladen." -ForegroundColor Green
|
||||
# Hilfsfunktion zum sauberen Hochladen/Ersetzen von Assets
|
||||
function Upload-ReleaseAsset {
|
||||
param (
|
||||
[string]$FilePath,
|
||||
[string]$AssetName
|
||||
)
|
||||
|
||||
# SHA256SUMS.txt hochladen
|
||||
Write-Host "Lade SHA256SUMS.txt hoch..." -ForegroundColor Cyan
|
||||
$SumPathNorm = $ChecksumFile.Replace('\', '/')
|
||||
$SumUrl = "${UploadUrl}?name=SHA256SUMS.txt"
|
||||
$SumResult = & curl.exe -sS -X POST $SumUrl -H $AuthHeader -F "attachment=@$SumPathNorm"
|
||||
if ($LASTEXITCODE -ne 0) {
|
||||
Write-Error "Upload von SHA256SUMS.txt fehlgeschlagen: $SumResult"
|
||||
exit 1
|
||||
}
|
||||
Write-Host "[OK] SHA256SUMS.txt hochgeladen." -ForegroundColor Green
|
||||
if (-not (Test-Path $FilePath)) {
|
||||
return
|
||||
}
|
||||
|
||||
# Standalone EXE hochladen
|
||||
$ExeFile = Join-Path $ProjectRoot "target\release\sanctum.exe"
|
||||
if (Test-Path $ExeFile) {
|
||||
Write-Host "Lade sanctum.exe hoch..." -ForegroundColor Cyan
|
||||
$ExePathNorm = $ExeFile.Replace('\', '/')
|
||||
$ExeUrl = "${UploadUrl}?name=sanctum.exe"
|
||||
$ExeResult = & curl.exe -sS -X POST $ExeUrl -H $AuthHeader -F "attachment=@$ExePathNorm"
|
||||
Write-Host "Lade $AssetName hoch..." -ForegroundColor Cyan
|
||||
|
||||
# Vorhandenes Asset mit gleichem Namen ermitteln und ggf. loeschen
|
||||
$ExistingAssets = try {
|
||||
Invoke-RestMethod -Uri $UploadUrl -Headers $Headers -Method Get
|
||||
} catch {
|
||||
@()
|
||||
}
|
||||
$Duplicate = $ExistingAssets | Where-Object { $_.name -eq $AssetName }
|
||||
if ($Duplicate) {
|
||||
Write-Host " [i] Ersetze existierendes Asset '$AssetName' (ID: $($Duplicate.id))..." -ForegroundColor DarkYellow
|
||||
$DeleteUrl = "$GiteaUrl/api/v1/repos/$Owner/$Repo/releases/$($Release.id)/assets/$($Duplicate.id)"
|
||||
Invoke-RestMethod -Uri $DeleteUrl -Headers $Headers -Method Delete | Out-Null
|
||||
}
|
||||
|
||||
$PathNorm = $FilePath.Replace('\', '/')
|
||||
$TargetUrl = "${UploadUrl}?name=$AssetName"
|
||||
$Result = & curl.exe -sS -X POST $TargetUrl -H $AuthHeader -F "attachment=@$PathNorm"
|
||||
if ($LASTEXITCODE -ne 0) {
|
||||
Write-Error "Upload von sanctum.exe fehlgeschlagen: $ExeResult"
|
||||
Write-Error "Upload von $AssetName fehlgeschlagen: $Result"
|
||||
exit 1
|
||||
}
|
||||
Write-Host "[OK] sanctum.exe hochgeladen." -ForegroundColor Green
|
||||
Write-Host "[OK] $AssetName erfolgreich hochgeladen." -ForegroundColor Green
|
||||
}
|
||||
|
||||
# Windows-Assets hochladen
|
||||
Upload-ReleaseAsset -FilePath $ZipFile -AssetName "sanctum-$TagName-windows-x86_64.zip"
|
||||
$ExeFile = Join-Path $ProjectRoot "target\release\sanctum.exe"
|
||||
Upload-ReleaseAsset -FilePath $ExeFile -AssetName "sanctum.exe"
|
||||
|
||||
# Linux-Assets hochladen
|
||||
$LinuxTar = Join-Path $DistDir "sanctum-$TagName-linux-x86_64.tar.gz"
|
||||
Upload-ReleaseAsset -FilePath $LinuxTar -AssetName "sanctum-$TagName-linux-x86_64.tar.gz"
|
||||
$LinuxElf = Join-Path $ProjectRoot "target\x86_64-unknown-linux-musl\release\sanctum"
|
||||
Upload-ReleaseAsset -FilePath $LinuxElf -AssetName "sanctum"
|
||||
|
||||
# SHA256SUMS.txt hochladen
|
||||
Upload-ReleaseAsset -FilePath $ChecksumFile -AssetName "SHA256SUMS.txt"
|
||||
|
||||
|
||||
Write-Host "`n============================================================" -ForegroundColor Green
|
||||
Write-Host " Release $TagName erfolgreich auf Gitea veroeffentlicht!" -ForegroundColor Green
|
||||
|
||||
Reference in New Issue
Block a user