117 lines
3.3 KiB
PowerShell
117 lines
3.3 KiB
PowerShell
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"
|
|
|
|
function Resolve-Maven {
|
|
param([string]$PreferredPath)
|
|
|
|
if ($PreferredPath -and (Test-Path $PreferredPath)) {
|
|
return $PreferredPath
|
|
}
|
|
|
|
$fromPath = Get-Command mvn.cmd -ErrorAction SilentlyContinue
|
|
if ($fromPath) {
|
|
return $fromPath.Source
|
|
}
|
|
|
|
$fallback = "D:\开发\apache-maven-3.9.9\bin\mvn.cmd"
|
|
if (Test-Path $fallback) {
|
|
return $fallback
|
|
}
|
|
|
|
throw "Cannot find mvn.cmd. Pass -MavenPath with an absolute Maven path."
|
|
}
|
|
|
|
function Invoke-Step {
|
|
param(
|
|
[string]$Name,
|
|
[scriptblock]$Script
|
|
)
|
|
|
|
Write-Host "==> $Name"
|
|
& $Script
|
|
}
|
|
|
|
function Copy-Directory {
|
|
param(
|
|
[string]$Source,
|
|
[string]$Destination
|
|
)
|
|
|
|
if (!(Test-Path $Source)) {
|
|
throw "Missing source directory: $Source"
|
|
}
|
|
|
|
New-Item -ItemType Directory -Force -Path $Destination | Out-Null
|
|
Copy-Item -Path (Join-Path $Source "*") -Destination $Destination -Recurse -Force
|
|
}
|
|
|
|
$maven = Resolve-Maven $MavenPath
|
|
New-Item -ItemType Directory -Force -Path $backendDir, $frontendDir, $miniProgramDir | Out-Null
|
|
|
|
$mavenArgs = @("-q", "package")
|
|
if ($SkipTests) {
|
|
$mavenArgs += "-DskipTests"
|
|
}
|
|
|
|
Invoke-Step "Build YumiNail-Core" {
|
|
Push-Location (Join-Path $repoRoot "YumiNail-Core")
|
|
try { & $maven @mavenArgs } finally { Pop-Location }
|
|
}
|
|
|
|
Invoke-Step "Build YumiNail-Gateway" {
|
|
Push-Location (Join-Path $repoRoot "YumiNail-Gateway")
|
|
try { & $maven @mavenArgs } finally { Pop-Location }
|
|
}
|
|
|
|
Invoke-Step "Build YumiNail-Frontend" {
|
|
Push-Location (Join-Path $repoRoot "YumiNail-Frontend")
|
|
try {
|
|
if (!(Test-Path "node_modules")) {
|
|
npm ci
|
|
}
|
|
npm run build
|
|
} finally {
|
|
Pop-Location
|
|
}
|
|
}
|
|
|
|
Copy-Item (Join-Path $repoRoot "YumiNail-Core\target\YumiNail-Core.jar") (Join-Path $backendDir "YumiNail-Core.jar") -Force
|
|
Copy-Item (Join-Path $repoRoot "YumiNail-Gateway\target\YumiNail-Gateway.jar") (Join-Path $backendDir "YumiNail-Gateway.jar") -Force
|
|
Copy-Directory (Join-Path $repoRoot "YumiNail-Frontend\dist") (Join-Path $frontendDir "dist")
|
|
Copy-Directory (Join-Path $repoRoot "WeChatProgram") (Join-Path $miniProgramDir "WeChatProgram")
|
|
Copy-Directory (Join-Path $repoRoot "YumiNail-Admin-Program") (Join-Path $miniProgramDir "YumiNail-Admin-Program")
|
|
Copy-Item (Join-Path $repoRoot "YumiNail-Core\src\main\resources\files\YumiNail.sql") (Join-Path $releaseDir "YumiNail.sql") -Force
|
|
|
|
$manifest = @(
|
|
"# YumiNail Release $timestamp",
|
|
"",
|
|
"- backend/YumiNail-Core.jar",
|
|
"- backend/YumiNail-Gateway.jar",
|
|
"- frontend/dist",
|
|
"- miniprograms/WeChatProgram",
|
|
"- miniprograms/YumiNail-Admin-Program",
|
|
"- YumiNail.sql",
|
|
"",
|
|
"Nacos namespace: YumiNail-Dev",
|
|
"Database initialized by: YumiNail.sql"
|
|
)
|
|
$manifest | Set-Content -Encoding UTF8 (Join-Path $releaseDir "README.md")
|
|
|
|
$zipPath = "$releaseDir.zip"
|
|
Compress-Archive -Path (Join-Path $releaseDir "*") -DestinationPath $zipPath -Force
|
|
|
|
Write-Host "Release folder: $releaseDir"
|
|
Write-Host "Release archive: $zipPath"
|