Skip to content

Commit c549152

Browse files
committed
adding fixed for release workflow
1 parent 354b052 commit c549152

File tree

1 file changed

+83
-0
lines changed

1 file changed

+83
-0
lines changed

.github/workflows/release.yml

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,11 +154,88 @@ jobs:
154154
uses: dtolnay/rust-toolchain@stable
155155
with:
156156
targets: ${{ matrix.target }}
157+
continue-on-error: true
158+
id: toolchain
159+
160+
- name: Retry Rust toolchain installation (Windows)
161+
if: steps.toolchain.outcome == 'failure' && matrix.os == 'windows-latest'
162+
shell: powershell
163+
run: |
164+
Write-Host "First attempt failed, retrying Rust toolchain installation..."
165+
$ErrorActionPreference = 'Stop'
166+
$maxRetries = 3
167+
$retryCount = 0
168+
$success = $false
169+
170+
while (-not $success -and $retryCount -lt $maxRetries) {
171+
$retryCount++
172+
Write-Host "Attempt $retryCount of $maxRetries..."
173+
174+
try {
175+
# Clear any partial downloads
176+
if (Test-Path "$env:USERPROFILE\.rustup\tmp") {
177+
Remove-Item -Path "$env:USERPROFILE\.rustup\tmp" -Recurse -Force
178+
}
179+
180+
# Download and install rustup
181+
Invoke-WebRequest -Uri "https://win.rustup.rs/x86_64" -OutFile "$env:TEMP\rustup-init.exe" -UseBasicParsing
182+
& "$env:TEMP\rustup-init.exe" -y --default-toolchain stable --target ${{ matrix.target }}
183+
184+
# Add to PATH for current session
185+
$env:PATH = "$env:USERPROFILE\.cargo\bin;$env:PATH"
186+
187+
# Verify installation
188+
rustc --version
189+
cargo --version
190+
191+
$success = $true
192+
Write-Host "Rust toolchain installed successfully!"
193+
}
194+
catch {
195+
Write-Host "Attempt $retryCount failed: $_"
196+
if ($retryCount -eq $maxRetries) {
197+
throw "Failed to install Rust after $maxRetries attempts"
198+
}
199+
Start-Sleep -Seconds 10
200+
}
201+
}
202+
203+
- name: Retry Rust toolchain installation (Unix)
204+
if: steps.toolchain.outcome == 'failure' && matrix.os != 'windows-latest'
205+
run: |
206+
echo "First attempt failed, retrying Rust toolchain installation..."
207+
max_retries=3
208+
retry_count=0
209+
210+
while [ $retry_count -lt $max_retries ]; do
211+
retry_count=$((retry_count + 1))
212+
echo "Attempt $retry_count of $max_retries..."
213+
214+
# Clean up any partial downloads
215+
rm -rf ~/.rustup/tmp
216+
217+
# Try to install rustup
218+
if curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --default-toolchain stable --target ${{ matrix.target }}; then
219+
export PATH="$HOME/.cargo/bin:$PATH"
220+
rustc --version
221+
cargo --version
222+
echo "Rust toolchain installed successfully!"
223+
break
224+
else
225+
echo "Attempt $retry_count failed"
226+
if [ $retry_count -eq $max_retries ]; then
227+
echo "Failed to install Rust after $max_retries attempts"
228+
exit 1
229+
fi
230+
sleep 10
231+
fi
232+
done
157233
158234
- name: Setup Rust cache
159235
uses: Swatinem/rust-cache@v2
160236
with:
161237
key: ${{ matrix.os }}-${{ matrix.target }}
238+
continue-on-error: true
162239

163240
- name: Install cross-compilation dependencies (Linux)
164241
if: matrix.cross && matrix.os == 'ubuntu-latest'
@@ -182,11 +259,17 @@ jobs:
182259
if: "!matrix.cross"
183260
run: |
184261
cargo build --release --target ${{ matrix.target }} --all-features
262+
env:
263+
CARGO_NET_RETRY: 3
264+
CARGO_HTTP_TIMEOUT: 60
185265

186266
- name: Build binary (cross-compiled)
187267
if: matrix.cross
188268
run: |
189269
cross build --release --target ${{ matrix.target }} --all-features
270+
env:
271+
CARGO_NET_RETRY: 3
272+
CARGO_HTTP_TIMEOUT: 60
190273

191274
- name: Strip binary (Unix)
192275
if: matrix.os != 'windows-latest'

0 commit comments

Comments
 (0)