Skip to content

Commit a976a5c

Browse files
authored
Fix intermittent smctl not found in signing workflow (#14190)
The Install SMCTL step had no error handling: a failed S3 download (0 bytes) led to a silent msiexec failure, but the script unconditionally declared success and added the path to GITHUB_PATH. Add download retry with file size validation, synchronous msiexec via Start-Process -Wait, and post-install binary verification.
1 parent 2ccec61 commit a976a5c

1 file changed

Lines changed: 37 additions & 3 deletions

File tree

.github/workflows/actions/sign-files/action.yml

Lines changed: 37 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,43 @@ runs:
4444
run: |
4545
Write-Output "::group::Install smctl if needed"
4646
if (!(Get-Command smctl -ErrorAction SilentlyContinue)) {
47-
curl -o smtools-windows-x64.msi "https://rstudio-buildtools.s3.amazonaws.com/posit-dev/smtools-windows-x64.msi"
48-
msiexec /i smtools-windows-x64.msi /quiet /qn /log smtools-windows-x64.log
49-
"C:/Program Files/DigiCert/DigiCert One Signing Manager Tools" | Out-File -FilePath $env:GITHUB_PATH -Append
47+
# Download with retry (transient S3 failures cause silent install failures)
48+
$maxRetries = 3
49+
$downloaded = $false
50+
for ($i = 1; $i -le $maxRetries; $i++) {
51+
Write-Output "Downloading smtools MSI (attempt $i/$maxRetries)..."
52+
curl -o smtools-windows-x64.msi "https://rstudio-buildtools.s3.amazonaws.com/posit-dev/smtools-windows-x64.msi"
53+
if ($LASTEXITCODE -ne 0) {
54+
Write-Output "::warning::curl failed with exit code $LASTEXITCODE"
55+
continue
56+
}
57+
$fileSize = (Get-Item smtools-windows-x64.msi).Length
58+
if ($fileSize -lt 1MB) {
59+
Write-Output "::warning::Downloaded file is only $fileSize bytes, expected ~90MB"
60+
continue
61+
}
62+
$downloaded = $true
63+
Write-Output "Download successful ($fileSize bytes)"
64+
break
65+
}
66+
if (-not $downloaded) {
67+
Write-Output "::error title=Download Error::Failed to download smtools MSI after $maxRetries attempts"
68+
exit 1
69+
}
70+
# Install synchronously (msiexec can return before install completes without -Wait)
71+
$process = Start-Process msiexec -ArgumentList '/i', 'smtools-windows-x64.msi', '/quiet', '/qn', '/log', 'smtools-windows-x64.log' -Wait -PassThru
72+
if ($process.ExitCode -ne 0) {
73+
Write-Output "::error title=Install Error::msiexec failed with exit code $($process.ExitCode)"
74+
Get-Content smtools-windows-x64.log -Tail 50
75+
exit 1
76+
}
77+
# Verify smctl is actually on disk before declaring success
78+
$smctlPath = "C:/Program Files/DigiCert/DigiCert One Signing Manager Tools"
79+
if (!(Test-Path "$smctlPath/smctl.exe")) {
80+
Write-Output "::error title=Install Error::smctl.exe not found at $smctlPath after install"
81+
exit 1
82+
}
83+
$smctlPath | Out-File -FilePath $env:GITHUB_PATH -Append
5084
Write-Output "SMCTL installed and added on PATH"
5185
} else {
5286
Write-Output "SMCTL already installed and on PATH"

0 commit comments

Comments
 (0)