feat: add ops center and node onboarding flow

This commit is contained in:
Your Name
2026-04-18 23:52:51 +08:00
parent 246838ae4c
commit b9c29481b5
142 changed files with 89727 additions and 186 deletions

View File

@@ -3,17 +3,44 @@ $ErrorActionPreference = "Stop"
$root = Split-Path -Parent $MyInvocation.MyCommand.Path
$releaseRoot = Join-Path $root "release"
$timestamp = Get-Date -Format "yyyyMMdd_HHmmss"
$packageName = "domaincheck_release_$timestamp"
$basePackageName = "domaincheck_release_$timestamp"
$packageName = $basePackageName
$stagingRoot = Join-Path $releaseRoot $packageName
$zipPath = Join-Path $releaseRoot "$packageName.zip"
$hashPath = Join-Path $releaseRoot "$packageName.sha256.txt"
$suffix = 1
while ((Test-Path -LiteralPath $stagingRoot) -or (Test-Path -LiteralPath $zipPath) -or (Test-Path -LiteralPath $hashPath)) {
$packageName = "${basePackageName}_$suffix"
$stagingRoot = Join-Path $releaseRoot $packageName
$zipPath = Join-Path $releaseRoot "$packageName.zip"
$hashPath = Join-Path $releaseRoot "$packageName.sha256.txt"
$suffix += 1
}
if (-not $releaseCommitSha) {
$gitCommand = Get-Command git -ErrorAction SilentlyContinue
if ($gitCommand) {
try {
$insideRepo = (& git -C $root rev-parse --is-inside-work-tree 2>$null).Trim()
if ($insideRepo -eq "true") {
$releaseCommitSha = (& git -C $root rev-parse --short=12 HEAD 2>$null).Trim()
$releaseCommitRef = (& git -C $root rev-parse --abbrev-ref HEAD 2>$null).Trim()
}
}
catch {
}
}
}
$latestTxtPath = Join-Path $releaseRoot "latest_release.txt"
$latestJsonPath = Join-Path $releaseRoot "latest_release.json"
$smokeScript = Join-Path $root "domainCheck\.venv\Scripts\python.exe"
$smokeRunner = Join-Path $root "domain-api\deploy\linux\smoke_test.py"
$smokeOutput = Join-Path $stagingRoot "smoke_test_report.json"
$apiBaseUrl = if ($env:API_BASE_URL) { $env:API_BASE_URL } else { "http://127.0.0.1:8100" }
$webUrl = if ($env:WEB_URL) { $env:WEB_URL } else { "http://127.0.0.1:3200" }
$webUrl = if ($env:WEB_URL) { $env:WEB_URL } else { "" }
$releaseCommitSha = if ($env:DOMAINCHECK_RELEASE_COMMIT_SHA) { $env:DOMAINCHECK_RELEASE_COMMIT_SHA } else { $releaseCommitSha }
$releaseCommitRef = if ($env:DOMAINCHECK_RELEASE_COMMIT_REF) { $env:DOMAINCHECK_RELEASE_COMMIT_REF } else { $releaseCommitRef }
function Copy-OptionalItem {
param(
@@ -56,7 +83,11 @@ $rootScripts = @(
"package_domain_release.ps1",
"verify_domain_release.ps1",
"prepare_final_release.ps1",
"show_latest_release.ps1"
"show_latest_release.ps1",
"package_domain_release.sh",
"verify_domain_release.sh",
"prepare_final_release.sh",
"show_latest_release.sh"
)
foreach ($script in $rootScripts) {
Copy-OptionalItem -Source (Join-Path $root $script) -Destination $scriptsTarget
@@ -99,10 +130,6 @@ $smokeMessage = ""
if ((Test-Path -LiteralPath $smokeScript) -and (Test-Path -LiteralPath $smokeRunner)) {
try {
& $smokeScript $smokeRunner --base-url $apiBaseUrl --web-url $webUrl --output $smokeOutput | Out-Null
if (Test-Path -LiteralPath $smokeOutput) {
$smokeOk = $true
$smokeMessage = "generated"
}
}
catch {
$smokeMessage = $_.Exception.Message
@@ -112,10 +139,40 @@ else {
$smokeMessage = "smoke test runtime not found"
}
if (Test-Path -LiteralPath $smokeOutput) {
try {
$smokeReport = Get-Content -LiteralPath $smokeOutput -Raw | ConvertFrom-Json
$checks = @($smokeReport.checks)
$totalChecks = $checks.Count
$failedChecks = @($checks | Where-Object { -not $_.ok } | ForEach-Object { [string]$_.name })
$passedChecks = $totalChecks - $failedChecks.Count
$smokeOk = [bool]$smokeReport.ok
if ($smokeOk) {
$smokeMessage = if ($totalChecks -gt 0) { "all checks passed ($passedChecks/$totalChecks)" } else { "all checks passed" }
}
else {
$failedPreview = ($failedChecks | Select-Object -First 5) -join ", "
$smokeMessage = if ($failedPreview) {
"$passedChecks/$totalChecks checks passed; failed: $failedPreview"
} else {
"$passedChecks/$totalChecks checks passed"
}
}
}
catch {
if (-not $smokeMessage) {
$smokeMessage = "smoke report unreadable"
}
}
}
$manifest = [ordered]@{
package_name = $packageName
package_type = "zip"
generated_at = (Get-Date).ToString("s")
root = $root
commit_sha = $releaseCommitSha
commit_ref = $releaseCommitRef
smoke_test = [ordered]@{
ok = $smokeOk
message = $smokeMessage
@@ -166,22 +223,31 @@ $zipHash = (Get-FileHash -LiteralPath $zipPath -Algorithm SHA256).Hash.ToLowerIn
$latestRelease = [ordered]@{
package_name = $packageName
package_type = "zip"
generated_at = (Get-Date).ToString("s")
staging_path = $stagingRoot
archive_path = $zipPath
zip_path = $zipPath
sha256_path = $hashPath
sha256 = $zipHash
smoke_test_ok = $smokeOk
smoke_test_message = $smokeMessage
smoke_test_report = if (Test-Path -LiteralPath $smokeOutput) { "smoke_test_report.json" } else { "" }
commit_sha = $releaseCommitSha
commit_ref = $releaseCommitRef
}
$latestRelease | ConvertTo-Json -Depth 6 | Set-Content -LiteralPath $latestJsonPath -Encoding UTF8
@(
"package_name=$packageName"
"staging_path=$stagingRoot"
"archive_path=$zipPath"
"zip_path=$zipPath"
"sha256_path=$hashPath"
"sha256=$zipHash"
"smoke_test_ok=$smokeOk"
"commit_sha=$releaseCommitSha"
"commit_ref=$releaseCommitRef"
) | Set-Content -LiteralPath $latestTxtPath -Encoding UTF8
Write-Host "release package created"