@@ -112,8 +112,75 @@ jobs:
112112 with :
113113 arch : x86
114114
115- - name : Setup vcpkg
116- uses : lukka/run-vcpkg@v11
115+ - name : Cache vcpkg executable
116+ if : startsWith(inputs.preset, 'win32')
117+ id : cache-vcpkg-exe
118+ uses : actions/cache@v4
119+ with :
120+ path : ${{ github.workspace }}\vcpkg\vcpkg.exe
121+ key : vcpkg-exe-${{ runner.os }}-2025-12-05
122+ restore-keys : |
123+ vcpkg-exe-${{ runner.os }}-
124+
125+ - name : Bootstrap vcpkg with retry
126+ if : startsWith(inputs.preset, 'win32')
127+ shell : pwsh
128+ run : |
129+ $vcpkgDir = "${{ github.workspace }}\vcpkg"
130+ $vcpkgExe = "$vcpkgDir\vcpkg.exe"
131+
132+ if (-not (Test-Path $vcpkgDir)) {
133+ New-Item -ItemType Directory -Path $vcpkgDir -Force | Out-Null
134+ }
135+
136+ if (Test-Path $vcpkgExe) {
137+ Write-Host "Using cached vcpkg.exe" -ForegroundColor Green
138+ & $vcpkgExe version --disable-metrics
139+ if ($LASTEXITCODE -eq 0) {
140+ Write-Host "Cached vcpkg.exe is valid" -ForegroundColor Green
141+ exit 0
142+ } else {
143+ Write-Host "Cached vcpkg.exe is invalid, will re-download" -ForegroundColor Yellow
144+ Remove-Item $vcpkgExe -Force
145+ }
146+ }
147+
148+ $maxRetries = 5
149+ $retryDelay = 10
150+ $versionDate = "2025-12-05"
151+ $downloadUrl = "https://github.com/microsoft/vcpkg-tool/releases/download/$versionDate/vcpkg.exe"
152+
153+ for ($attempt = 1; $attempt -le $maxRetries; $attempt++) {
154+ Write-Host "Downloading vcpkg.exe (attempt $attempt/$maxRetries)..." -ForegroundColor Cyan
155+ try {
156+ $ProgressPreference = 'SilentlyContinue'
157+ Invoke-WebRequest -Uri $downloadUrl -OutFile $vcpkgExe -TimeoutSec 60 -ErrorAction Stop
158+
159+ if (Test-Path $vcpkgExe) {
160+ & $vcpkgExe version --disable-metrics
161+ if ($LASTEXITCODE -eq 0) {
162+ Write-Host "Successfully downloaded and verified vcpkg.exe" -ForegroundColor Green
163+ exit 0
164+ } else {
165+ Write-Host "Downloaded file is invalid, will retry..." -ForegroundColor Yellow
166+ Remove-Item $vcpkgExe -Force -ErrorAction SilentlyContinue
167+ }
168+ }
169+ } catch {
170+ Write-Host "Download attempt $attempt failed: $($_.Exception.Message)" -ForegroundColor Yellow
171+ if ($attempt -lt $maxRetries) {
172+ Write-Host "Waiting $retryDelay seconds before retry..." -ForegroundColor Yellow
173+ Start-Sleep -Seconds $retryDelay
174+ $retryDelay = [math]::Min($retryDelay * 2, 60)
175+ } else {
176+ Write-Error "Failed to download vcpkg.exe after $maxRetries attempts"
177+ throw
178+ }
179+ }
180+ }
181+
182+ Write-Error "Failed to download vcpkg.exe"
183+ exit 1
117184
118185 - name : Configure ${{ inputs.game }} with CMake Using ${{ inputs.preset }}${{ inputs.tools && '+t' || '' }}${{ inputs.extras && '+e' || '' }} Preset
119186 shell : pwsh
0 commit comments