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 }}