feat: import Sea vHost single-server testing release

This commit is contained in:
canglan committed 2026-10-30 08:39:10 +08:00
commit 248badd33e
441 files changed
+63221

No files matched your search

+81
View File
@@ -0,0 +1,81 @@
$ErrorActionPreference = 'Stop'
Set-StrictMode -Version Latest
$repoRoot = [IO.Path]::GetFullPath((Join-Path $PSScriptRoot '..'))
$buildRoot = [IO.Path]::GetFullPath((Join-Path $repoRoot 'build'))
$binaryRoot = Join-Path $buildRoot 'bin'
$webRoot = Join-Path $buildRoot 'web'
$archive = Join-Path $buildRoot 'sea-vhost-linux-amd64.tar.gz'
foreach ($script in Get-ChildItem -LiteralPath (Join-Path $repoRoot 'deploy') -Filter '*.sh' -File) {
if ([IO.File]::ReadAllText($script.FullName).Contains("`r")) {
throw "Linux shell script must use LF line endings: $($script.Name)"
}
}
function Assert-BuildPath([string]$path) {
$absolute = [IO.Path]::GetFullPath($path)
$prefix = $buildRoot.TrimEnd([IO.Path]::DirectorySeparatorChar) + [IO.Path]::DirectorySeparatorChar
if (-not $absolute.StartsWith($prefix, [StringComparison]::OrdinalIgnoreCase)) {
throw "Refusing to modify a path outside the build directory: $absolute"
}
}
foreach ($path in @($binaryRoot, $webRoot)) {
Assert-BuildPath $path
if (Test-Path -LiteralPath $path) {
Remove-Item -LiteralPath $path -Recurse -Force
}
New-Item -ItemType Directory -Path $path | Out-Null
}
Push-Location (Join-Path $repoRoot 'backend')
try {
$goCommand = if ([string]::IsNullOrWhiteSpace($env:SEA_GO_BINARY)) { 'go' } else { [IO.Path]::GetFullPath($env:SEA_GO_BINARY) }
if ($goCommand -ne 'go' -and -not (Test-Path -LiteralPath $goCommand -PathType Leaf)) { throw "Configured Go binary does not exist: $goCommand" }
$env:CGO_ENABLED = '0'
$env:GOOS = 'linux'
$env:GOARCH = 'amd64'
$goVersion = (& $goCommand env GOVERSION).Trim()
if ($LASTEXITCODE -ne 0 -or [string]::IsNullOrWhiteSpace($goVersion)) { throw 'Cannot determine the Go toolchain version' }
$env:GOCACHE = Join-Path $repoRoot ".cache\go-build-linux-amd64-$goVersion"
New-Item -ItemType Directory -Path $env:GOCACHE -Force | Out-Null
& $goCommand build -trimpath -ldflags '-s -w' -o (Join-Path $binaryRoot 'sea-vhost-api') ./cmd/server
& $goCommand build -trimpath -ldflags '-s -w' -o (Join-Path $binaryRoot 'sea-vhost-agent') ./cmd/agent
& $goCommand build -trimpath -ldflags '-s -w' -o (Join-Path $binaryRoot 'sea-vhost-panel-broker') ./cmd/panel-broker
& $goCommand build -trimpath -ldflags '-s -w' -o (Join-Path $binaryRoot 'sea-vhost-node') ./cmd/node
& $goCommand build -trimpath -ldflags '-s -w' -o (Join-Path $binaryRoot 'sea-vhost-run') ./cmd/runner
& $goCommand build -trimpath -ldflags '-s -w' -o (Join-Path $binaryRoot 'sea-vhost-scheduler') ./cmd/scheduler
if ($LASTEXITCODE -ne 0) { throw 'Go cross compilation failed' }
foreach ($binary in @('sea-vhost-api', 'sea-vhost-agent', 'sea-vhost-panel-broker','sea-vhost-node','sea-vhost-run','sea-vhost-scheduler')) {
$metadata = @(& $goCommand version -m (Join-Path $binaryRoot $binary))
if ($LASTEXITCODE -ne 0 -or $metadata.Count -eq 0 -or -not $metadata[0].EndsWith(": $goVersion", [StringComparison]::Ordinal)) {
throw "$binary was not linked by the requested $goVersion toolchain"
}
}
} finally {
Pop-Location
}
Push-Location (Join-Path $repoRoot 'frontend')
try {
# Local Windows development can keep node_modules open briefly (for
# example after browser tests). The opt-out is only for an already
# restored lockfile-compatible dependency tree; CI remains the default.
if ($env:SEA_BUILD_SKIP_NPM_CI -ne 'true') {
& npm ci
if ($LASTEXITCODE -ne 0) { throw 'npm ci failed' }
}
$env:VITE_API_MODE = 'true'
& npm run build
if ($LASTEXITCODE -ne 0) { throw 'Frontend build failed' }
Copy-Item -Path (Join-Path $PWD 'dist\*') -Destination $webRoot -Recurse -Force
} finally {
Pop-Location
}
Assert-BuildPath $archive
& node (Join-Path $PSScriptRoot 'package-release.mjs')
if ($LASTEXITCODE -ne 0) { throw 'Curated release packaging failed' }
Write-Host "Build completed: $archive"
Write-Host 'Runtime/source archives, SHA-256 files and manifests are in build/.'