Files
JayuCloud/docs/scripts/package-release.ps1
T
xiaowang c957994006
发布 Nacos 配置 / publish (push) Successful in 44s
环境分支晋级检查 / environment-promotion-source (pull_request_target) Successful in 1s
统一ArtList与Salon历史命名
2026-10-14 13:04:10 +08:00

149 lines
4.5 KiB
PowerShell
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
param(
[switch]$SkipTests,
[string]$MavenPath = ""
)
$ErrorActionPreference = "Stop"
$repoRoot = Split-Path -Parent $PSScriptRoot
$timestamp = Get-Date -Format "yyyyMMdd-HHmmss"
$releaseRoot = Join-Path $repoRoot "release-packages"
$releaseDir = Join-Path $releaseRoot $timestamp
$backendDir = Join-Path $releaseDir "backend"
$frontendDir = Join-Path $releaseDir "frontend"
$miniProgramDir = Join-Path $releaseDir "miniprograms"
$artlistSqlPath = Join-Path $repoRoot "docs\scripts\sql\init\jayucloud-artlist.sql"
$salonSqlPath = Join-Path $repoRoot "docs\scripts\sql\init\jayucloud-salon.sql"
function Resolve-Maven {
param([string]$PreferredPath)
if ($PreferredPath -and (Test-Path -LiteralPath $PreferredPath)) {
return (Resolve-Path -LiteralPath $PreferredPath).Path
}
$fromPath = Get-Command mvn.cmd -ErrorAction SilentlyContinue
if ($fromPath) {
return $fromPath.Source
}
$fromPath = Get-Command mvn -ErrorAction SilentlyContinue
if ($fromPath) {
return $fromPath.Source
}
throw "找不到 Maven,请通过 -MavenPath 传入 Maven 可执行文件绝对路径。"
}
function Invoke-Native {
param(
[string]$FilePath,
[string[]]$Arguments,
[string]$WorkingDirectory
)
Write-Host ">> $FilePath $($Arguments -join ' ')"
$previousLocation = Get-Location
try {
Set-Location -LiteralPath $WorkingDirectory
& $FilePath @Arguments
if ($LASTEXITCODE -ne 0) {
throw "命令执行失败,退出码 ${LASTEXITCODE}:$FilePath"
}
}
finally {
Set-Location $previousLocation
}
}
function Copy-Directory {
param(
[string]$Source,
[string]$Destination
)
if (-not (Test-Path -LiteralPath $Source)) {
throw "缺少待打包目录:$Source"
}
New-Item -ItemType Directory -Force -Path $Destination | Out-Null
Copy-Item -LiteralPath $Source -Destination $Destination -Recurse -Force
}
function Copy-RequiredFile {
param(
[string]$Source,
[string]$Destination
)
if (-not (Test-Path -LiteralPath $Source)) {
throw "缺少待打包文件:$Source"
}
Copy-Item -LiteralPath $Source -Destination $Destination -Force
}
function Write-Step {
param([string]$Message)
Write-Host ""
Write-Host "==> $Message"
}
$maven = Resolve-Maven $MavenPath
New-Item -ItemType Directory -Force -Path $backendDir, $frontendDir, $miniProgramDir | Out-Null
$mavenArgs = @("-q", "package")
if ($SkipTests) {
$mavenArgs += "-DskipTests"
}
Write-Step "构建 JC-ArtList-Core"
Invoke-Native $maven $mavenArgs (Join-Path $repoRoot "JC-ArtList-Core")
Write-Step "构建 JC-ArtList-Gateway"
Invoke-Native $maven $mavenArgs (Join-Path $repoRoot "JC-ArtList-Gateway")
Write-Step "构建 JC-ArtList-Frontend"
$frontendRoot = Join-Path $repoRoot "JC-ArtList-Frontend"
if (-not (Test-Path -LiteralPath (Join-Path $frontendRoot "node_modules"))) {
Invoke-Native "npm" @("ci") $frontendRoot
}
Invoke-Native "npm" @("run", "build") $frontendRoot
$coreJar = Join-Path $repoRoot "JC-ArtList-Core\target\JC-ArtList-Core.jar"
$gatewayJar = Join-Path $repoRoot "JC-ArtList-Gateway\target\JC-ArtList-Gateway.jar"
$frontendDist = Join-Path $frontendRoot "dist"
Copy-RequiredFile $coreJar (Join-Path $backendDir "JC-ArtList-Core.jar")
Copy-RequiredFile $gatewayJar (Join-Path $backendDir "JC-ArtList-Gateway.jar")
Copy-Directory $frontendDist (Join-Path $frontendDir "dist")
Copy-Directory (Join-Path $repoRoot "JC-ArtList-WeChat") (Join-Path $miniProgramDir "JC-ArtList-WeChat")
Copy-Directory (Join-Path $repoRoot "JC-Salon-WeChat") (Join-Path $miniProgramDir "JC-Salon-WeChat")
Copy-RequiredFile $artlistSqlPath (Join-Path $releaseDir "jayucloud-artlist.sql")
Copy-RequiredFile $salonSqlPath (Join-Path $releaseDir "jayucloud-salon.sql")
$manifest = @(
"# jayucloud-artlist Release $timestamp",
"",
"- backend/JC-ArtList-Core.jar",
"- backend/JC-ArtList-Gateway.jar",
"- frontend/dist",
"- miniprograms/JC-ArtList-WeChat",
"- miniprograms/JC-Salon-WeChat",
"- jayucloud-artlist.sql",
"- jayucloud-salon.sql",
"",
"Database initialization: docs/scripts/sql/init/jayucloud-artlist.sql and docs/scripts/sql/init/jayucloud-salon.sql",
"Database names: jayucloud_artlist and jayucloud_salon",
"Manager mini program API: https://yunail.art/api/admin"
)
$manifest | Set-Content -Encoding UTF8 (Join-Path $releaseDir "README.md")
$zipPath = "$releaseDir.zip"
Compress-Archive -Path (Join-Path $releaseDir "*") -DestinationPath $zipPath -Force
Write-Host ""
Write-Host "发布目录:$releaseDir"
Write-Host "发布压缩包:$zipPath"