Skip to content

Commit 7732682

Browse files
committed
swith to pwsh
1 parent 3fa9fce commit 7732682

File tree

1 file changed

+22
-18
lines changed

1 file changed

+22
-18
lines changed
Lines changed: 22 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,24 @@
11
steps:
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-
echo "=== Extracted contents ==="
16-
find /tmp/kiota_extract -type f
17-
KIOTA_BIN=$(find /tmp/kiota_extract -name kiota -type f | head -1)
18-
echo "Found Kiota binary at: $KIOTA_BIN"
19-
cp "$KIOTA_BIN" $(Build.ArtifactStagingDirectory)/kiota
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+
$kiotaBin = Get-ChildItem -Path $extractPath -Filter "kiota" -Recurse -File | Select-Object -First 1
20+
Write-Host "Found Kiota binary at: $($kiotaBin.FullName)"
21+
$stagingDir = "$(Build.ArtifactStagingDirectory)"
22+
New-Item -ItemType Directory -Force -Path $stagingDir | Out-Null
23+
Copy-Item -Path $kiotaBin.FullName -Destination (Join-Path $stagingDir "kiota")
2024
displayName: 'Download latest Kiota from GitHub'

0 commit comments

Comments
 (0)