fix(release): dynamically locate Git and provide API zip archive fallback on Windows runner
Release Binaries & Installers / Build & Release Linux Binaries (push) Canceled after 0s
CI Test Suite / Run Component Tests & Pipeline Verification (push) Canceled after 1m34s
Release Binaries & Installers / Build & Release Windows Binaries & Installers (push) Canceled after 9m33s

This commit is contained in:
2026-09-25 23:16:36 +02:00
parent 14b3586b10
commit 19c60616b1
+43 -7
View File
@@ -61,17 +61,53 @@ jobs:
$server = "${{ github.server_url }}" $server = "${{ github.server_url }}"
$token = "${{ secrets.TAG_TOKEN || github.token }}" $token = "${{ secrets.TAG_TOKEN || github.token }}"
$repo = "${{ github.repository }}" $repo = "${{ github.repository }}"
$sha = "${{ github.sha }}"
$cleanUrl = $server -replace "^https?://", "" $cleanUrl = $server -replace "^https?://", ""
$authUrl = "https://${token}@${cleanUrl}/${repo}.git" $authUrl = "https://${token}@${cleanUrl}/${repo}.git"
if (-not (Test-Path ".git")) { # Discover and append Git install paths to PATH if missing
git init $gitCandidatePaths = @(
git remote add origin $authUrl "C:\Program Files\Git\cmd",
} else { "C:\Program Files\Git\bin",
git remote set-url origin $authUrl "C:\Program Files (x86)\Git\cmd",
"C:\Program Files (x86)\Git\bin",
"C:\ProgramData\chocolatey\bin",
"$env:LOCALAPPDATA\Programs\Git\cmd"
)
foreach ($p in $gitCandidatePaths) {
if ((Test-Path $p) -and ($env:PATH -notlike "*$p*")) {
$env:PATH = "$p;$env:PATH"
}
}
$gitCmd = Get-Command "git" -ErrorAction SilentlyContinue
if ($gitCmd) {
Write-Host "[+] Found Git at $($gitCmd.Source)"
if (-not (Test-Path ".git")) {
& git init
& git remote add origin $authUrl
} else {
& git remote set-url origin $authUrl
}
& git fetch --depth 1 origin $sha
& git checkout -f FETCH_HEAD
} else {
Write-Host "[!] Git binary not found in PATH. Downloading repository archive via Gitea API..."
$zipUrl = "$server/api/v1/repos/$repo/archive/$sha.zip"
$headers = @{ "Authorization" = "token $token" }
$zipPath = "$env:TEMP\repo_$sha.zip"
$extractPath = "$env:TEMP\repo_extract_$sha"
Invoke-RestMethod -Uri $zipUrl -Headers $headers -OutFile $zipPath -ErrorAction Stop
Expand-Archive -Path $zipPath -DestinationPath $extractPath -Force
$inner = Get-ChildItem -Path $extractPath | Where-Object { $_.PSIsContainer } | Select-Object -First 1
if ($inner) {
Copy-Item -Path "$($inner.FullName)\*" -Destination "." -Recurse -Force
} else {
Copy-Item -Path "$extractPath\*" -Destination "." -Recurse -Force
}
Remove-Item -Path $zipPath, $extractPath -Recurse -Force -ErrorAction SilentlyContinue
Write-Host "[+] Repository successfully extracted from ZIP archive."
} }
git fetch --depth 1 origin "${{ github.sha }}"
git checkout -f FETCH_HEAD
- name: Install Dependencies - name: Install Dependencies
shell: powershell shell: powershell