优化windows包,优化windos可执行文件功能

This commit is contained in:
truewhile
2026-09-14 15:48:59 +08:00
parent 3aa8662c45
commit 95d8126d65
17 changed files with 680 additions and 116 deletions
+42
View File
@@ -0,0 +1,42 @@
param(
[string]$Output = "dist\mebox-windows-amd64.exe",
[string]$Version = "dev",
[switch]$SkipFrontend
)
$ErrorActionPreference = "Stop"
$root = Split-Path -Parent $PSScriptRoot
Push-Location $root
try {
if (-not $SkipFrontend) {
Push-Location web
try {
npm ci
npm run build
}
finally {
Pop-Location
}
}
if (-not (Test-Path "web\dist\index.html")) {
throw "web\dist\index.html is missing. Run without -SkipFrontend or build the frontend first."
}
$outputDir = Split-Path -Parent $Output
if ($outputDir) {
New-Item -ItemType Directory -Force -Path $outputDir | Out-Null
}
$env:CGO_ENABLED = "0"
$env:GOOS = "windows"
$env:GOARCH = "amd64"
go build -trimpath `
-ldflags="-s -w -H=windowsgui -X main.version=$Version" `
-o $Output `
./cmd/server
Write-Host "Built $Output"
}
finally {
Pop-Location
}