Files
Warlock-Studio-Universal/build-scripts/build-windows.ps1
T
vlad.os 586160b1a0
Build and Release / Validate source (push) Failing after 25s
Build and Release / Build (linux) (push) Has been skipped
Build and Release / Create Release (push) Has been skipped
Build and Release / Build (windows) (push) Has been skipped
Add Gitea Actions CI/CD pipeline
- .gitea/workflows/release.yml — multi-platform build (linux native + windows cross via wine)
- requirements.txt — all pip dependencies with version pins
- PKGBUILD — Arch Linux build reference
- build-scripts/build-linux-portable.sh — Linux portable/AppImage builder
- build-scripts/build-windows.ps1 — Windows PyInstaller + Inno Setup builder
2026-06-27 03:26:18 +03:00

103 lines
4.0 KiB
PowerShell

# =============================================================================
# Warlock Studio — Windows Build Script (PowerShell)
# =============================================================================
# Builds with PyInstaller and optionally packages into an installer via Inno Setup.
#
# Usage:
# .\build-scripts\build-windows.ps1 [-InnoSetup] [-OutputDir .\dist]
#
# Requires: Python 3.10+, pip, PyInstaller
# Optional: Inno Setup (for -InnoSetup flag)
# =============================================================================
param(
[switch]$InnoSetup,
[string]$OutputDir = (Join-Path (Get-Location) "dist")
)
$ErrorActionPreference = "Stop"
$ProjectRoot = Split-Path -Parent (Split-Path -Parent $PSCommandPath)
$AppName = "Warlock-Studio"
Write-Host "==========================================" -ForegroundColor Cyan
Write-Host " Warlock Studio — Windows Build" -ForegroundColor Cyan
Write-Host "==========================================" -ForegroundColor Cyan
# ---- Step 1: Install Python dependencies ----
Write-Host "[1/5] Installing Python dependencies..." -ForegroundColor Yellow
python -m pip install --upgrade pip wheel setuptools
pip install -r (Join-Path $ProjectRoot "requirements.txt")
pip install pyinstaller onnxruntime-directml
# ---- Step 2: Build with PyInstaller ----
Write-Host "[2/5] Building with PyInstaller..." -ForegroundColor Yellow
$specFile = Join-Path $ProjectRoot "Warlock-Studio.spec"
$distPath = $OutputDir
pyinstaller $specFile --noconfirm --distpath $distPath
# Verify output
$binaryPath = Join-Path $distPath $AppName "$AppName.exe"
if (-not (Test-Path $binaryPath)) {
Write-Error "Build failed: $binaryPath not found"
exit 1
}
Write-Host " Binary: $binaryPath" -ForegroundColor Green
# ---- Step 3: Create versioned archive ----
Write-Host "[3/5] Creating ZIP archive..." -ForegroundColor Yellow
$version = "dev"
$tag = git describe --tags --abbrev=0 2>$null
if ($tag) { $version = $tag.TrimStart('v') }
$archiveName = "$AppName-$version-win64.zip"
$archivePath = Join-Path $ProjectRoot $archiveName
$buildDir = Join-Path $distPath $AppName
Compress-Archive -Path "$buildDir\*" -DestinationPath $archivePath -Force
Write-Host " Archive: $archivePath" -ForegroundColor Green
# ---- Step 4: Build Inno Setup installer (optional) ----
if ($InnoSetup) {
Write-Host "[4/5] Building Inno Setup installer..." -ForegroundColor Yellow
# Check if ISCC is available
$iscc = Get-Command "iscc" -ErrorAction SilentlyContinue
if (-not $iscc) {
$possiblePaths = @(
"${env:ProgramFiles(x86)}\Inno Setup 6\ISCC.exe",
"${env:ProgramFiles}\Inno Setup 6\ISCC.exe",
"${env:ProgramFiles(x86)}\Inno Setup 5\ISCC.exe"
)
$isccPath = $possiblePaths | Where-Object { Test-Path $_ } | Select-Object -First 1
if (-not $isccPath) {
Write-Warning "Inno Setup not found. Skipping installer build."
Write-Warning " Install from: https://jrsoftware.org/isdl.php"
} else {
$iscc = $isccPath
}
}
if ($iscc) {
$issFile = Join-Path $ProjectRoot "Setup.iss"
if (Test-Path $issFile) {
& $iscc $issFile
Write-Host " Installer built." -ForegroundColor Green
} else {
Write-Warning "Setup.iss not found. Skipping installer."
}
}
} else {
Write-Host "[4/5] Skipped (use -InnoSetup to build installer)" -ForegroundColor Gray
}
# ---- Step 5: Cleanup ----
Write-Host "[5/5] Cleanup..." -ForegroundColor Yellow
Remove-Item -Recurse -Force "build" -ErrorAction SilentlyContinue
Write-Host ""
Write-Host "==========================================" -ForegroundColor Cyan
Write-Host " BUILD COMPLETE" -ForegroundColor Cyan
Write-Host "==========================================" -ForegroundColor Cyan
Write-Host "Output: $archiveName" -ForegroundColor Green
if ($InnoSetup -and $iscc) {
Write-Host "Installer: Output\Warlock-Studio-$version-Full-Installer.exe" -ForegroundColor Green
}