Skip to content

Commit 6433fba

Browse files
committed
ci(release): NSIS 安装失败时提前失败并重试
choco 社区源偶发 503 导致 NSIS 未装上,但原步骤因末尾 echo 成功而误判为通过, 失败拖到打包步骤才暴露(makensis not found in PATH)。改为:choco 重试最多 3 次 + 安装后校验 makensis.exe 存在,缺失即在安装步立即失败。
1 parent c037a28 commit 6433fba

1 file changed

Lines changed: 22 additions & 2 deletions

File tree

.github/workflows/release.yml

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,28 @@ jobs:
4949
- name: Install NSIS
5050
shell: pwsh
5151
run: |
52-
choco install nsis -y --no-progress
53-
echo "C:\Program Files (x86)\NSIS" >> $env:GITHUB_PATH
52+
$ErrorActionPreference = "Stop"
53+
# choco 社区源偶发 503,重试最多 3 次(应对瞬时故障)
54+
$installed = $false
55+
for ($i = 1; $i -le 3; $i++) {
56+
Write-Host "安装 NSIS (尝试 $i/3)..."
57+
choco install nsis -y --no-progress
58+
if ($LASTEXITCODE -eq 0) { $installed = $true; break }
59+
Write-Host "choco 退出码 $LASTEXITCODE,10s 后重试..."
60+
Start-Sleep -Seconds 10
61+
}
62+
if (-not $installed) {
63+
Write-Error "NSIS 安装失败:choco install 连续 3 次非零退出(可能是 Chocolatey 源故障)"
64+
exit 1
65+
}
66+
# 校验 makensis.exe 真实存在,缺失即提前失败(不拖到打包步骤)
67+
$nsisDir = "C:\Program Files (x86)\NSIS"
68+
if (-not (Test-Path "$nsisDir\makensis.exe")) {
69+
Write-Error "NSIS 安装后未找到 makensis.exe(路径:$nsisDir)"
70+
exit 1
71+
}
72+
echo "$nsisDir" >> $env:GITHUB_PATH
73+
Write-Host "NSIS 安装成功:$nsisDir\makensis.exe"
5474
5575
- name: Install frontend dependencies
5676
working-directory: wind_setting/frontend

0 commit comments

Comments
 (0)