114 lines
3.4 KiB
PowerShell
114 lines
3.4 KiB
PowerShell
# Umbrix Windows Build & Package Script (Hiddify-style)
|
|
# Creates Setup.exe (Inno Setup) + Portable.zip
|
|
|
|
param(
|
|
[string]$Version = "1.7.4",
|
|
[switch]$SkipBuild = $false
|
|
)
|
|
|
|
$ErrorActionPreference = "Stop"
|
|
|
|
function Write-ColorOutput($ForegroundColor, $Message) {
|
|
$fc = $host.UI.RawUI.ForegroundColor
|
|
$host.UI.RawUI.ForegroundColor = $ForegroundColor
|
|
Write-Output $Message
|
|
$host.UI.RawUI.ForegroundColor = $fc
|
|
}
|
|
|
|
Write-ColorOutput "Cyan" "==============================================="
|
|
Write-ColorOutput "Cyan" " Umbrix Windows Build System v$Version"
|
|
Write-ColorOutput "Cyan" "==============================================="
|
|
Write-Output ""
|
|
|
|
$ProjectRoot = Split-Path -Parent $PSScriptRoot
|
|
$BuildDir = "$ProjectRoot\build\windows\x64\runner\Release"
|
|
$DistDir = "$ProjectRoot\dist"
|
|
$OutDir = "$ProjectRoot\out"
|
|
$InnoSetupCompiler = "C:\Program Files (x86)\Inno Setup 6\ISCC.exe"
|
|
|
|
# Check Inno Setup
|
|
if (-not (Test-Path $InnoSetupCompiler)) {
|
|
Write-ColorOutput "Yellow" "WARNING: Inno Setup not found!"
|
|
Write-Output "Download from: https://jrsoftware.org/isdl.php"
|
|
Write-Output ""
|
|
$CreateSetup = $false
|
|
} else {
|
|
$CreateSetup = $true
|
|
}
|
|
|
|
# Step 1: Build Flutter Release
|
|
if (-not $SkipBuild) {
|
|
Write-ColorOutput "Yellow" "[1/3] Building Flutter Windows Release..."
|
|
Push-Location $ProjectRoot
|
|
|
|
Stop-Process -Name "Umbrix" -Force -ErrorAction SilentlyContinue
|
|
Start-Sleep -Seconds 1
|
|
|
|
& C:\flutter\bin\flutter.bat build windows --release
|
|
if ($LASTEXITCODE -ne 0) {
|
|
Write-ColorOutput "Red" "ERROR: Flutter build failed!"
|
|
exit 1
|
|
}
|
|
Pop-Location
|
|
Write-ColorOutput "Green" "SUCCESS: Build complete"
|
|
} else {
|
|
Write-ColorOutput "Cyan" "[1/3] Skip build (using existing)"
|
|
}
|
|
|
|
# Check build
|
|
if (-not (Test-Path "$BuildDir\Umbrix.exe")) {
|
|
Write-ColorOutput "Red" "ERROR: Umbrix.exe not found!"
|
|
exit 1
|
|
}
|
|
|
|
# Step 2: Create Setup.exe via Inno Setup
|
|
Write-Output ""
|
|
Write-ColorOutput "Yellow" "[2/3] Creating installer (Setup.exe)..."
|
|
|
|
if ($CreateSetup) {
|
|
$IssFile = "$ProjectRoot\windows\installer.iss"
|
|
|
|
if (-not (Test-Path $IssFile)) {
|
|
Write-ColorOutput "Red" "ERROR: installer.iss not found!"
|
|
exit 1
|
|
}
|
|
|
|
# Compile installer
|
|
& $InnoSetupCompiler /Q $IssFile
|
|
|
|
if ($LASTEXITCODE -eq 0) {
|
|
Write-ColorOutput "Green" "SUCCESS: Setup.exe created"
|
|
} else {
|
|
Write-ColorOutput "Red" "ERROR: Inno Setup compilation failed!"
|
|
}
|
|
} else {
|
|
Write-ColorOutput "Yellow" "SKIPPED (Inno Setup not installed)"
|
|
}
|
|
|
|
# Step 3: Package (package_windows.ps1)
|
|
Write-Output ""
|
|
Write-ColorOutput "Yellow" "[3/3] Packaging releases..."
|
|
Push-Location $ProjectRoot
|
|
& .\scripts\package_windows.ps1
|
|
Pop-Location
|
|
|
|
# Summary
|
|
Write-Output ""
|
|
Write-ColorOutput "Cyan" "==============================================="
|
|
Write-ColorOutput "Green" " BUILD COMPLETED SUCCESSFULLY!"
|
|
Write-ColorOutput "Cyan" "==============================================="
|
|
Write-Output ""
|
|
Write-Output "Release files:"
|
|
if (Test-Path $OutDir) {
|
|
Get-ChildItem $OutDir -File | ForEach-Object {
|
|
$size = [math]::Round($_.Length / 1MB, 2)
|
|
Write-Output " * $($_.Name) ($size MB)"
|
|
}
|
|
} else {
|
|
Write-ColorOutput "Yellow" "WARNING: out/ folder not found"
|
|
}
|
|
Write-Output ""
|
|
Write-ColorOutput "Yellow" "Upload files to Gitea:"
|
|
Write-Output " https://update.umbrix.net/vodorod/umbrix/releases"
|
|
Write-Output ""
|