Add server components
build-winui / winui (push) Has been cancelled

This commit is contained in:
QWQLwToo
2026-06-26 13:28:09 +08:00
parent 7ecc6a8923
commit 079ee4eaeb
168 changed files with 37475 additions and 0 deletions
@@ -0,0 +1,58 @@
param(
[string]$Version = "dev",
[string]$OutDir = "dist-release",
[switch]$SkipFrontend
)
$ErrorActionPreference = "Stop"
$Root = Resolve-Path (Join-Path $PSScriptRoot "..")
$Out = Join-Path $Root $OutDir
function Run-Step {
param(
[string]$WorkingDirectory,
[string]$FilePath,
[string[]]$Arguments
)
Push-Location $WorkingDirectory
try {
& $FilePath @Arguments
if ($LASTEXITCODE -ne 0) {
throw "$FilePath $($Arguments -join ' ') failed with exit code $LASTEXITCODE"
}
} finally {
Pop-Location
}
}
if (-not $SkipFrontend) {
foreach ($App in @("admin", "portal", "setup")) {
$WebDir = Join-Path $Root "web\$App"
if (-not (Test-Path (Join-Path $WebDir "node_modules"))) {
Run-Step $WebDir "npm" @("install")
}
Run-Step $WebDir "npm" @("run", "build")
}
}
New-Item -ItemType Directory -Force -Path $Out | Out-Null
$Targets = @(
@{ GOOS = "windows"; GOARCH = "amd64"; Name = "ymhut-unified-management-windows-amd64.exe" },
@{ GOOS = "linux"; GOARCH = "amd64"; Name = "ymhut-unified-management-linux-amd64" },
@{ GOOS = "linux"; GOARCH = "arm64"; Name = "ymhut-unified-management-linux-arm64" }
)
foreach ($Target in $Targets) {
$env:GOOS = $Target.GOOS
$env:GOARCH = $Target.GOARCH
$env:CGO_ENABLED = "0"
$Output = Join-Path $Out $Target.Name
Run-Step $Root "go" @("build", "-tags", "embed_web", "-buildvcs=false", "-trimpath", "-ldflags", "-s -w -X ymhut-box/server/unified-management/internal/config.Version=$Version", "-o", $Output, ".\cmd\unified-management")
}
Remove-Item Env:\GOOS -ErrorAction SilentlyContinue
Remove-Item Env:\GOARCH -ErrorAction SilentlyContinue
Remove-Item Env:\CGO_ENABLED -ErrorAction SilentlyContinue
Write-Host "Built release binaries in $Out"
@@ -0,0 +1,36 @@
#!/usr/bin/env bash
set -euo pipefail
VERSION="${VERSION:-dev}"
OUT_DIR="${OUT_DIR:-dist-release}"
SKIP_FRONTEND="${SKIP_FRONTEND:-0}"
ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
OUT="$ROOT/$OUT_DIR"
if [[ "$SKIP_FRONTEND" != "1" ]]; then
for app in admin portal; do
web_dir="$ROOT/web/$app"
if [[ ! -d "$web_dir/node_modules" ]]; then
(cd "$web_dir" && npm install)
fi
(cd "$web_dir" && npm run build)
done
fi
mkdir -p "$OUT"
build_target() {
local goos="$1"
local goarch="$2"
local name="$3"
(cd "$ROOT" && \
GOOS="$goos" GOARCH="$goarch" CGO_ENABLED=0 \
go build -tags embed_web -buildvcs=false -trimpath -ldflags "-s -w -X ymhut-box/server/unified-management/internal/config.Version=$VERSION" \
-o "$OUT/$name" ./cmd/unified-management)
}
build_target windows amd64 ymhut-unified-management-windows-amd64.exe
build_target linux amd64 ymhut-unified-management-linux-amd64
build_target linux arm64 ymhut-unified-management-linux-arm64
echo "Built release binaries in $OUT"