update pack
This commit is contained in:
@@ -4,28 +4,20 @@
|
|||||||
$ScriptDir = Split-Path -Parent $MyInvocation.MyCommand.Path
|
$ScriptDir = Split-Path -Parent $MyInvocation.MyCommand.Path
|
||||||
$RepoRoot = (Resolve-Path (Join-Path $ScriptDir "..\..")).Path
|
$RepoRoot = (Resolve-Path (Join-Path $ScriptDir "..\..")).Path
|
||||||
|
|
||||||
# Get Git TAG
|
# Get Git TAG (only the tag name, without commit hash or dirty flag)
|
||||||
$tag = ""
|
$tag = ""
|
||||||
Push-Location $RepoRoot
|
Push-Location $RepoRoot
|
||||||
|
|
||||||
# Get exact tag
|
# Get the most recent tag name
|
||||||
$exact = & git describe --tags --abbrev=0 --exact-match
|
$tagDesc = & git describe --tags --abbrev=0 2>$null
|
||||||
if ($LASTEXITCODE -eq 0 -and $exact) {
|
if ($LASTEXITCODE -eq 0 -and $tagDesc) {
|
||||||
$tag = $exact.Trim()
|
$tag = $tagDesc.Trim()
|
||||||
}
|
|
||||||
|
|
||||||
# Fallback: any readable description
|
|
||||||
if (-not $tag) {
|
|
||||||
$desc = & git describe --tags --dirty --always
|
|
||||||
if ($LASTEXITCODE -eq 0 -and $desc) {
|
|
||||||
$tag = $desc.Trim()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Pop-Location
|
Pop-Location
|
||||||
|
|
||||||
if (-not $tag) {
|
if (-not $tag) {
|
||||||
Write-Error "Cannot get git tag. Please run in a Git repository."
|
Write-Error "Cannot get git tag. Please run in a Git repository with at least one tag."
|
||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -87,16 +79,65 @@ if (Test-Path $RuntimeHookPath) {
|
|||||||
# Call PyInstaller
|
# Call PyInstaller
|
||||||
Push-Location $RepoRoot
|
Push-Location $RepoRoot
|
||||||
try {
|
try {
|
||||||
|
$ErrorActionPreference = "Continue" # 允许继续执行即使有错误
|
||||||
& pyinstaller @argsList
|
& pyinstaller @argsList
|
||||||
|
$ErrorActionPreference = "Stop" # 恢复错误停止设置
|
||||||
} finally {
|
} finally {
|
||||||
Pop-Location
|
Pop-Location
|
||||||
}
|
|
||||||
|
# 在 finally 块中执行后续操作,确保一定会执行
|
||||||
# Copy cmd files
|
Write-Host "`n=== Post-build processing ===" -ForegroundColor Green
|
||||||
$CmdSrc = Join-Path $ScriptDir "set_env.cmd"
|
|
||||||
if (Test-Path $CmdSrc) {
|
# Copy cmd files to exe directory
|
||||||
Copy-Item -Path $CmdSrc -Destination $DistDir -Force
|
$CmdSrc = Join-Path $ScriptDir "set_env.cmd"
|
||||||
}
|
$ExeDir = Join-Path $DistDir $AppName
|
||||||
|
if ((Test-Path $CmdSrc) -and (Test-Path $ExeDir)) {
|
||||||
Write-Host "Package completed: " (Resolve-Path $DistDir).Path
|
Copy-Item -Path $CmdSrc -Destination $ExeDir -Force
|
||||||
Write-Host "Executable directory: " (Join-Path $DistDir $AppName)
|
# Rename cmd file
|
||||||
|
$OldCmdPath = Join-Path $ExeDir "set_env.cmd"
|
||||||
|
$NewCmdPath = Join-Path $ExeDir "点击输入大模型密钥.cmd"
|
||||||
|
if (Test-Path $OldCmdPath) {
|
||||||
|
Move-Item -Path $OldCmdPath -Destination $NewCmdPath -Force
|
||||||
|
Write-Host "✓ Copied and renamed to 点击输入大模型密钥.cmd in exe directory" -ForegroundColor Green
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
# Copy static and assets to exe directory
|
||||||
|
if (Test-Path $ExeDir) {
|
||||||
|
if (Test-Path $AssetsPath) {
|
||||||
|
Copy-Item -Path $AssetsPath -Destination $ExeDir -Recurse -Force
|
||||||
|
Write-Host "✓ Copied assets to exe directory" -ForegroundColor Green
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Test-Path $StaticPath) {
|
||||||
|
Copy-Item -Path $StaticPath -Destination $ExeDir -Recurse -Force
|
||||||
|
# 删除 local_config.yml
|
||||||
|
$LocalConfigPath = Join-Path $ExeDir "static\local_config.yml"
|
||||||
|
if (Test-Path $LocalConfigPath) {
|
||||||
|
Remove-Item -Path $LocalConfigPath -Force
|
||||||
|
Write-Host "✓ Copied static to exe directory (excluded local_config.yml)" -ForegroundColor Green
|
||||||
|
} else {
|
||||||
|
Write-Host "✓ Copied static to exe directory" -ForegroundColor Green
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
# Clean up build and spec directories (delete entire directories)
|
||||||
|
$BuildDirRoot = Join-Path $RepoRoot "tmp\build"
|
||||||
|
if (Test-Path $BuildDirRoot) {
|
||||||
|
Remove-Item -Path $BuildDirRoot -Recurse -Force
|
||||||
|
Write-Host "✓ Deleted entire build directory: $BuildDirRoot" -ForegroundColor Green
|
||||||
|
}
|
||||||
|
|
||||||
|
# $SpecDirRoot = Join-Path $RepoRoot "tmp\spec"
|
||||||
|
# if (Test-Path $SpecDirRoot) {
|
||||||
|
# Remove-Item -Path $SpecDirRoot -Recurse -Force
|
||||||
|
# Write-Host "✓ Deleted entire spec directory: $SpecDirRoot" -ForegroundColor Green
|
||||||
|
# }
|
||||||
|
|
||||||
|
Write-Host "`n=== Package completed ===" -ForegroundColor Cyan
|
||||||
|
Write-Host "Distribution directory: " (Resolve-Path $DistDir).Path
|
||||||
|
if (Test-Path $ExeDir) {
|
||||||
|
Write-Host "Executable directory: " (Resolve-Path $ExeDir).Path
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user