Files
VitosUpdater/build.ps1
T

51 lines
2.1 KiB
PowerShell

<#
.SYNOPSIS
Baut VitosUpdater lokal (Installer + portable EXE) ohne Veröffentlichung.
.DESCRIPTION
Führt Frontend-Prüfung und Rust-Prüfungen aus und baut danach mit `cargo tauri build`.
Ergebnis: src-tauri\target\release\bundle\nsis\*-setup.exe sowie src-tauri\target\release\vitos-updater.exe (portabel).
Für signierte Updater-Artefakte muss der Signierschlüssel gesetzt sein (siehe README, Abschnitt "Release").
Für eine Veröffentlichung auf Gitea stattdessen scripts\release.ps1 verwenden.
#>
[CmdletBinding()]
param([switch]$SkipChecks)
Set-StrictMode -Version Latest
$ErrorActionPreference = 'Stop'
Set-Location $PSScriptRoot
function Invoke-Native([string]$Description, [scriptblock]$Command) {
& $Command
if ($LASTEXITCODE -ne 0) { throw "$Description ist fehlgeschlagen (Exit-Code $LASTEXITCODE)." }
}
$defaultKey = Join-Path $env:USERPROFILE '.vitosupdater\updater.key'
if (-not $env:TAURI_SIGNING_PRIVATE_KEY) {
# Die Tauri-CLI liest nur TAURI_SIGNING_PRIVATE_KEY (Pfad oder Inhalt); _PATH wird hier darauf abgebildet.
$keySource = $env:TAURI_SIGNING_PRIVATE_KEY_PATH
if (-not $keySource) { $keySource = $defaultKey }
if (Test-Path $keySource) { $env:TAURI_SIGNING_PRIVATE_KEY = (Get-Content $keySource -Raw -Encoding UTF8).Trim() }
}
$env:CI = 'true'
if (-not (Test-Path 'node_modules')) { Invoke-Native 'npm install' { npm install } }
if (-not $SkipChecks) {
Write-Host '==> Prüfungen' -ForegroundColor Cyan
Invoke-Native 'svelte-check' { npm run check }
Push-Location 'src-tauri'
try {
Invoke-Native 'cargo clippy' { cargo clippy --all-targets -- -D warnings }
Invoke-Native 'cargo test' { cargo test }
} finally { Pop-Location }
}
Write-Host '==> Bauen (cargo tauri build)' -ForegroundColor Cyan
Invoke-Native 'cargo tauri build' { cargo tauri build }
Write-Host ''
Write-Host 'Fertig. Ergebnisse:' -ForegroundColor Green
Get-ChildItem 'src-tauri\target\release\bundle\nsis' -Filter '*-setup.exe' | ForEach-Object { Write-Host " Installer: $($_.FullName)" }
Write-Host " Portabel: $(Resolve-Path 'src-tauri\target\release\vitos-updater.exe')"