ci: build Windows release package
Some checks failed
Build Windows Release / build-windows (push) Has been cancelled

This commit is contained in:
luochen570
2026-05-29 22:59:55 +08:00
parent 8c9a92f2cb
commit 2a70d6245e
9 changed files with 183 additions and 224 deletions

View File

@@ -0,0 +1,59 @@
param(
[ValidateSet("msvc")]
[string]$Toolchain = "msvc",
[string]$BuildDir = "$PSScriptRoot\..\build-windows",
[string]$DistDir = "$PSScriptRoot\..\dist-windows"
)
$ErrorActionPreference = "Stop"
$ProjectRoot = Resolve-Path "$PSScriptRoot\.."
$BuildDir = [System.IO.Path]::GetFullPath($BuildDir)
$DistDir = [System.IO.Path]::GetFullPath($DistDir)
$PackageName = "chengnan-windows-x86_64"
$PackageDir = Join-Path $DistDir $PackageName
$ZipPath = Join-Path $DistDir "$PackageName.zip"
$HashPath = "$ZipPath.sha256"
Write-Host "[package] ProjectRoot: $ProjectRoot"
Write-Host "[package] BuildDir: $BuildDir"
Write-Host "[package] DistDir: $DistDir"
& "$ProjectRoot\docs\windows\build-windows.ps1" -Toolchain $Toolchain -BuildDir $BuildDir -Deploy
$DeployDir = Join-Path $BuildDir "deploy"
$Exe = Join-Path $DeployDir "chengnan.exe"
if (!(Test-Path $Exe)) {
throw "未找到部署后的 Windows 可执行文件:$Exe"
}
if (Test-Path $PackageDir) { Remove-Item -Recurse -Force $PackageDir }
if (Test-Path $ZipPath) { Remove-Item -Force $ZipPath }
if (Test-Path $HashPath) { Remove-Item -Force $HashPath }
New-Item -ItemType Directory -Force -Path $DistDir | Out-Null
Copy-Item -Recurse -Force $DeployDir $PackageDir
$ReadmePath = Join-Path $PackageDir "README.txt"
@"
chengnan Windows x86_64
1.
2. chengnan.exe
- Qt OpenCV DLL
- chengnan.exe DLL Qt plugins
"@ | Set-Content -Encoding UTF8 $ReadmePath
Compress-Archive -Path (Join-Path $PackageDir "*") -DestinationPath $ZipPath -Force
$Hash = Get-FileHash -Algorithm SHA256 $ZipPath
"$($Hash.Hash.ToLower()) $(Split-Path -Leaf $ZipPath)" | Set-Content -Encoding ASCII $HashPath
if (!(Test-Path $ZipPath) -or ((Get-Item $ZipPath).Length -le 0)) {
throw "发布包生成失败:$ZipPath"
}
Write-Host "[package] 发布包:$ZipPath"
Write-Host "[package] 校验文件:$HashPath"