From 7f395bf5f035c8b5b4ed85925d6165b1aacafd49 Mon Sep 17 00:00:00 2001 From: lml Date: Mon, 16 Mar 2026 09:23:57 +0800 Subject: [PATCH] refactor: Package the Windows release from a fixed `Release` directory path instead of dynamically searching for the executable. --- .github/workflows/release.yml | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index f2d9d7b..838833e 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -84,24 +84,24 @@ jobs: $APP_NAME = "caption_trans" $WORKSPACE = "${{ github.workspace }}" - Write-Host "Searching for the executable in the build directory..." - # Search for the .exe file in the build\windows folder - $exeFile = Get-ChildItem -Path "$WORKSPACE\build\windows" -Filter "${APP_NAME}.exe" -Recurse | Select-Object -First 1 + # 拼接出 Release 文件夹的绝对路径 + $RELEASE_DIR = Join-Path $WORKSPACE "build\windows\x64\runner\Release" + $ZIP_NAME = Join-Path $WORKSPACE "${APP_NAME}-windows-x64.zip" - if ($exeFile) { - $releaseDir = $exeFile.DirectoryName - $ZIP_NAME = Join-Path $WORKSPACE "${APP_NAME}-windows-x64.zip" - Write-Host "Found executable at: $($exeFile.FullName)" - Write-Host "Packaging directory: $releaseDir" - - Compress-Archive -Path "$releaseDir\*" -DestinationPath "$ZIP_NAME" -Force - Write-Host "Successfully created $ZIP_NAME" - } else { - Write-Host "!!! Error: Could not find ${APP_NAME}.exe anywhere in build\windows !!!" - Write-Host "Listing build\windows structure for debugging:" - Get-ChildItem -Path "$WORKSPACE\build\windows" -Recurse -Depth 4 | Select-Object FullName + Write-Host "Looking for Release directory at: $RELEASE_DIR" + + # 验证目录是否存在 + if (!(Test-Path $RELEASE_DIR)) { + Write-Error "!!! 找不到 Release 目录 !!!" + Write-Host "打印 build\windows 目录结构用于排查:" + Get-ChildItem -Path "$WORKSPACE\build\windows" -Recurse -Depth 3 | Select-Object FullName exit 1 } + + Write-Host "Found Release directory. Packaging..." + # 将该目录下的所有文件打包到工作区根目录 + Compress-Archive -Path "$RELEASE_DIR\*" -DestinationPath "$ZIP_NAME" -Force + Write-Host "Successfully created $ZIP_NAME" - name: Upload Windows Artifact uses: actions/upload-artifact@v4 @@ -131,4 +131,4 @@ jobs: prerelease: false generate_release_notes: true env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file