From 893eb1050ffa83746468693932b5449f1125a3dd Mon Sep 17 00:00:00 2001 From: PuqiAR Date: Sat, 3 Jan 2026 22:59:36 +0800 Subject: [PATCH] =?UTF-8?q?[CI]=20=E5=B0=9D=E8=AF=95=E4=BF=AE=E5=A4=8Dwin?= =?UTF-8?q?=E6=89=93=E5=8C=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitea/workflows/build.yml | 30 ++++++++++++++++++++++-------- 1 file changed, 22 insertions(+), 8 deletions(-) diff --git a/.gitea/workflows/build.yml b/.gitea/workflows/build.yml index b05c095..592c71e 100644 --- a/.gitea/workflows/build.yml +++ b/.gitea/workflows/build.yml @@ -146,29 +146,43 @@ jobs: - name: 打包Windows发布文件 run: | [Console]::OutputEncoding = [System.Text.Encoding]::UTF8 + + # 确保版本号不为空 $VERSION = $env:VERSION - $PACKAGE_NAME = "Fig-$VERSION-windows-x86_64" + if ([string]::IsNullOrEmpty($VERSION)) { + Write-Host "警告:版本号为空,使用默认值 dev-build" + $VERSION = "dev-build" + } + + $PACKAGE_NAME = "Fig-${VERSION}-windows-x86_64" + Write-Host "打包名称: $PACKAGE_NAME" + New-Item -ItemType Directory -Force -Path $PACKAGE_NAME - # 尝试查找可执行文件 + # 查找可执行文件 if (Test-Path 'build\windows\x86_64\release\Fig.exe') { Copy-Item 'build\windows\x86_64\release\Fig.exe' $PACKAGE_NAME\ } elseif (Test-Path 'build\windows\x86_64\release\Fig') { Copy-Item 'build\windows\x86_64\release\Fig' $PACKAGE_NAME\Fig.exe } else { Write-Host '错误:未找到构建输出文件' - Get-ChildItem -Recurse -Path build -Include 'Fig*' | Select-Object -First 5 exit 1 } if (Test-Path 'src\Module\Library') { Copy-Item -Recurse 'src\Module\Library' $PACKAGE_NAME\ } - Compress-Archive -Path $PACKAGE_NAME -DestinationPath "$PACKAGE_NAME.zip" - $Hash = Get-FileHash "$PACKAGE_NAME.zip" -Algorithm SHA256 - "$($Hash.Hash) $PACKAGE_NAME.zip" | Out-File "$PACKAGE_NAME.sha256" -Encoding UTF8 - Write-Host "Windows打包完成: $PACKAGE_NAME.zip" - + + # 压缩文件 + $ZIP_NAME = "$PACKAGE_NAME.zip" + Compress-Archive -Path $PACKAGE_NAME -DestinationPath $ZIP_NAME + + # 生成校验文件 + $Hash = Get-FileHash $ZIP_NAME -Algorithm SHA256 + "$($Hash.Hash) $ZIP_NAME" | Out-File "$PACKAGE_NAME.sha256" -Encoding UTF8 + + Write-Host "Windows打包完成: $ZIP_NAME" + - name: 发布Windows版本到Gitea env: GITEA_TOKEN: ${{ secrets.CI_TOKEN }}