|
1 | 1 | steps: |
2 | | -- pwsh: | |
3 | | - $releaseJson = Invoke-RestMethod "https://api.github.com/repos/microsoft/kiota/releases/latest" |
4 | | - $latestTag = $releaseJson.tag_name |
5 | | - $platform = if ($IsLinux) { "linux-x64" } elseif ($IsMacOS) { "osx-x64" } else { "win-x64" } |
6 | | - $asset = $releaseJson.assets | Where-Object { $_.name -match $platform } | Select-Object -First 1 |
7 | | - Write-Host "Downloading Kiota $latestTag" |
8 | | - Write-Host "Asset URL: $($asset.browser_download_url)" |
9 | | - $tmpDir = [System.IO.Path]::GetTempPath() |
10 | | - $downloadPath = Join-Path $tmpDir "kiota_download" |
11 | | - $extractPath = Join-Path $tmpDir "kiota_extract" |
12 | | - New-Item -ItemType Directory -Force -Path $extractPath | Out-Null |
13 | | - Invoke-WebRequest -Uri $asset.browser_download_url -OutFile $downloadPath |
14 | | - if ($asset.name -match "\.zip$") { |
15 | | - Expand-Archive -Path $downloadPath -DestinationPath $extractPath -Force |
16 | | - } else { |
17 | | - tar -xzf $downloadPath -C $extractPath |
18 | | - } |
19 | | - # Match 'kiota' or 'kiota.exe' via BaseName |
20 | | - $kiotaBin = Get-ChildItem -Path $extractPath -Recurse -File | Where-Object { $_.BaseName -eq "kiota" } | Select-Object -First 1 |
21 | | - Write-Host "Found Kiota binary at: $($kiotaBin.FullName)" |
22 | | - $stagingDir = "$(Build.ArtifactStagingDirectory)" |
23 | | - New-Item -ItemType Directory -Force -Path $stagingDir | Out-Null |
24 | | - # Always copy as 'kiota' (no extension) so downstream steps are platform-agnostic |
25 | | - Copy-Item -Path $kiotaBin.FullName -Destination (Join-Path $stagingDir "kiota") |
| 2 | +- bash: | |
| 3 | + RELEASE_JSON=$(curl -s "https://api.github.com/repos/microsoft/kiota/releases/latest") |
| 4 | + LATEST_TAG=$(echo "$RELEASE_JSON" | jq -r '.tag_name') |
| 5 | + ASSET_URL=$(echo "$RELEASE_JSON" | jq -r '.assets[] | select(.name | test("linux-x64")) | .browser_download_url') |
| 6 | + echo "Downloading Kiota $LATEST_TAG" |
| 7 | + echo "Asset URL: $ASSET_URL" |
| 8 | + curl -L "$ASSET_URL" -o kiota_download |
| 9 | + mkdir -p /tmp/kiota_extract |
| 10 | + if [[ "$ASSET_URL" == *.zip ]]; then |
| 11 | + unzip kiota_download -d /tmp/kiota_extract |
| 12 | + else |
| 13 | + tar -xzf kiota_download -C /tmp/kiota_extract |
| 14 | + fi |
| 15 | + KIOTA_BIN=$(find /tmp/kiota_extract -name kiota -type f | head -1) |
| 16 | + echo "Found Kiota binary at: $KIOTA_BIN" |
| 17 | + mkdir -p "$(Build.ArtifactStagingDirectory)" |
| 18 | + cp "$KIOTA_BIN" "$(Build.ArtifactStagingDirectory)/kiota" |
26 | 19 | displayName: 'Download latest Kiota from GitHub' |
0 commit comments