From 76e0168d1ee33e0a2bd238aaf505658c04423c61 Mon Sep 17 00:00:00 2001 From: SoftFever <103989404+SoftFever@users.noreply.github.com> Date: Wed, 14 Oct 2026 23:39:11 +0800 Subject: [PATCH] Stop Windows builds failing when the Chocolatey feed is down (#16482) --- .github/workflows/build_orca.yml | 45 +++++++++++++++++++++++--------- 1 file changed, 32 insertions(+), 13 deletions(-) diff --git a/.github/workflows/build_orca.yml b/.github/workflows/build_orca.yml index 4d85542c71..60456ad171 100644 --- a/.github/workflows/build_orca.yml +++ b/.github/workflows/build_orca.yml @@ -33,6 +33,8 @@ jobs: ubuntu-ver: '2404' ubuntu-ver-str: '_Ubuntu2404' ORCA_UPDATER_SIG_KEY: ${{ secrets.ORCA_UPDATER_SIG_KEY }} + NSIS_VERSION: '3.13' + NSIS_SHA256: BA63DFFC4410EE89193E1CB5A41989991BD77C61068DA17E3156D136B7B0B3D8 steps: - name: Checkout @@ -427,29 +429,46 @@ jobs: if: runner.os == 'Windows' uses: microsoft/setup-msbuild@v3 - - name: Install nsis + # NSIS builds the installer. A pinned portable copy is kept in the Actions + # cache, so most runs never download it, and a cache miss fetches the + # release archive from SourceForge instead of going through the Chocolatey + # community feed, which hosted runners often cannot reach. Prepending it to + # PATH also makes cpack use it over the NSIS preinstalled on some images. + - name: Restore NSIS + id: nsis-cache + if: runner.os == 'Windows' && !vars.SELF_HOSTED + uses: actions/cache/restore@v6 + with: + path: ${{ runner.temp }}/nsis + key: nsis-${{ env.NSIS_VERSION }} + + - name: Install NSIS if: runner.os == 'Windows' && !vars.SELF_HOSTED shell: pwsh - # The Chocolatey community feed intermittently 504s, and `choco install` - # exits 0 when package resolution fails that way. Unchecked, the job then - # builds for ~25 minutes before `cpack -G NSIS` reports a missing makensis. - # Retry the install and verify makensis itself, so a real failure stops here. run: | dir "C:/Program Files (x86)/Windows Kits/10/Include" - $nsisDir = Join-Path ${env:ProgramFiles(x86)} 'NSIS' + $nsisDir = Join-Path $env:RUNNER_TEMP 'nsis' $makensis = Join-Path $nsisDir 'makensis.exe' - for ($attempt = 1; $attempt -le 3 -and -not (Test-Path $makensis); $attempt++) { - if ($attempt -gt 1) { Start-Sleep -Seconds (15 * $attempt) } - Write-Host "::group::choco install nsis (attempt $attempt)" - choco install nsis --yes --no-progress - Write-Host "::endgroup::" - } if (-not (Test-Path $makensis)) { - throw "NSIS install failed: $makensis not found after 3 attempts." + $zip = Join-Path $env:RUNNER_TEMP "nsis-$env:NSIS_VERSION.zip" + curl.exe -fsSL --retry 5 --retry-all-errors --retry-delay 15 -o $zip "https://downloads.sourceforge.net/project/nsis/NSIS%203/$env:NSIS_VERSION/nsis-$env:NSIS_VERSION.zip" + if ($LASTEXITCODE -ne 0) { throw "NSIS $env:NSIS_VERSION download failed." } + if ((Get-FileHash $zip -Algorithm SHA256).Hash -ne $env:NSIS_SHA256) { + throw "NSIS $env:NSIS_VERSION archive does not match its pinned SHA256." + } + Expand-Archive $zip $env:RUNNER_TEMP + Move-Item (Join-Path $env:RUNNER_TEMP "nsis-$env:NSIS_VERSION") $nsisDir } & $makensis /VERSION $nsisDir | Out-File -Append -FilePath $env:GITHUB_PATH -Encoding utf8 + - name: Save NSIS + if: runner.os == 'Windows' && !vars.SELF_HOSTED && steps.nsis-cache.outputs.cache-hit != 'true' + uses: actions/cache/save@v6 + with: + path: ${{ runner.temp }}/nsis + key: nsis-${{ env.NSIS_VERSION }} + - name: Build slicer Win if: runner.os == 'Windows' working-directory: ${{ github.workspace }}