From 76f65cb96c188a024a705c338e72ce4b7b2a58c8 Mon Sep 17 00:00:00 2001 From: Syngnat Date: Wed, 18 Mar 2026 17:29:24 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20fix(ci):=20=E4=BF=AE=E5=A4=8D=20?= =?UTF-8?q?Chocolatey=20UPX=20=E5=8C=85=E4=B8=8D=E5=8F=AF=E7=94=A8?= =?UTF-8?q?=E5=AF=BC=E8=87=B4=20Windows=20=E6=9E=84=E5=BB=BA=E5=A4=B1?= =?UTF-8?q?=E8=B4=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Chocolatey NuGet 仓库无法解析 upx 包,触发 NuGetResolverInputException - 改为 Invoke-WebRequest 从 GitHub Releases 下载 upx-4.2.4-win64.zip - 使用 GITHUB_PATH 环境文件注入 UPX 路径,后续步骤可直接调用 - 消除对 Chocolatey 包注册表的外部依赖,提高 CI 稳定性 --- .github/workflows/release.yml | 16 ++++++++++++---- .github/workflows/test-build-all-platforms.yml | 18 +++++++++++++----- 2 files changed, 25 insertions(+), 9 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 08171df..5c041b1 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -95,13 +95,21 @@ jobs: if: contains(matrix.platform, 'windows') shell: pwsh run: | - choco install upx --no-progress -y - $upxCmd = Get-Command upx -ErrorAction SilentlyContinue - if ($null -eq $upxCmd) { + $UPX_VERSION = "4.2.4" + $url = "https://github.com/upx/upx/releases/download/v${UPX_VERSION}/upx-${UPX_VERSION}-win64.zip" + $zipPath = "$env:RUNNER_TEMP\upx.zip" + $extractPath = "$env:RUNNER_TEMP\upx" + Write-Host "📥 从 GitHub Releases 下载 UPX v${UPX_VERSION} ..." + Invoke-WebRequest -Uri $url -OutFile $zipPath -UseBasicParsing + Expand-Archive -Path $zipPath -DestinationPath $extractPath -Force + $upxDir = Get-ChildItem -Path $extractPath -Directory | Select-Object -First 1 + "$($upxDir.FullName)" | Out-File -FilePath $env:GITHUB_PATH -Append -Encoding utf8 + $upxCmd = Join-Path $upxDir.FullName "upx.exe" + if (!(Test-Path $upxCmd)) { Write-Error "❌ 未检测到 upx,无法保证 Windows 产物经过压缩" exit 1 } - & upx --version + & $upxCmd --version # Linux Dependencies (GTK3, WebKit2GTK required by Wails) - name: Install Linux Dependencies diff --git a/.github/workflows/test-build-all-platforms.yml b/.github/workflows/test-build-all-platforms.yml index 17ba77c..d1df7e5 100644 --- a/.github/workflows/test-build-all-platforms.yml +++ b/.github/workflows/test-build-all-platforms.yml @@ -1,4 +1,4 @@ -name: Test Build All Platforms (Manual) +name: Test Build All Platforms (Manual) on: workflow_dispatch: @@ -100,13 +100,21 @@ jobs: if: contains(matrix.platform, 'windows') shell: pwsh run: | - choco install upx --no-progress -y - $upxCmd = Get-Command upx -ErrorAction SilentlyContinue - if ($null -eq $upxCmd) { + $UPX_VERSION = "4.2.4" + $url = "https://github.com/upx/upx/releases/download/v${UPX_VERSION}/upx-${UPX_VERSION}-win64.zip" + $zipPath = "$env:RUNNER_TEMP\upx.zip" + $extractPath = "$env:RUNNER_TEMP\upx" + Write-Host "📥 从 GitHub Releases 下载 UPX v${UPX_VERSION} ..." + Invoke-WebRequest -Uri $url -OutFile $zipPath -UseBasicParsing + Expand-Archive -Path $zipPath -DestinationPath $extractPath -Force + $upxDir = Get-ChildItem -Path $extractPath -Directory | Select-Object -First 1 + "$($upxDir.FullName)" | Out-File -FilePath $env:GITHUB_PATH -Append -Encoding utf8 + $upxCmd = Join-Path $upxDir.FullName "upx.exe" + if (!(Test-Path $upxCmd)) { Write-Error "❌ 未检测到 upx,无法保证 Windows 测试产物经过压缩" exit 1 } - & upx --version + & $upxCmd --version - name: Install Linux Dependencies if: contains(matrix.platform, 'linux')