Skip to content
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 30 additions & 10 deletions eng/ci/templates/official/steps/download-latest-from-feed.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,36 @@ steps:
inputs:
targetType: 'inline'
script: |
# Fetch the latest version of the func-cli package from the feed. All packages should have the
# same package version as it is based on the CLI version + build number (which is date based)
$packageUrl = "https://feeds.dev.azure.com/azfunc/internal/_apis/packaging/feeds/core-tools-nightly-build/packages/a998de77-f16c-4c10-af8c-cfa5a430eae7?api-version=7.1"
# Fetch the latest version of the func-cli package from the feed for each package
$headers = @{ Authorization = "Bearer $env:SYSTEM_ACCESSTOKEN" }

$response = Invoke-RestMethod -Uri $packageUrl -Headers $headers -Method Get
$latestVersion = $response.versions[0].version

Write-Host "##vso[task.setvariable variable=FUNC_CLI_VERSION]$latestVersion"
Write-Host "Using func-cli version: $latestVersion"
function Get-LatestPackageVersion {
param($packageName)

$searchUrl = "https://feeds.dev.azure.com/azfunc/internal/_apis/packaging/feeds/core-tools-nightly-build/packages?packageNameQuery=$packageName&api-version=7.1"
$searchResponse = Invoke-RestMethod -Uri $searchUrl -Headers $headers -Method Get
$package = $searchResponse.value | Where-Object { $_.name -eq $packageName } | Select-Object -First 1

if ($package) {
$packageUrl = "https://feeds.dev.azure.com/azfunc/internal/_apis/packaging/feeds/core-tools-nightly-build/packages/$($package.id)?api-version=7.1"
$packageDetails = Invoke-RestMethod -Uri $packageUrl -Headers $headers -Method Get
return $packageDetails.versions[0].version
}
return $null
}

# Get version for each package
$funcCliVersion = Get-LatestPackageVersion -packageName "func-cli"
Write-Host "##vso[task.setvariable variable=FUNC_CLI_VERSION]$funcCliVersion"
Write-Host "func-cli version: $funcCliVersion"

$funcCliInprocVersion = Get-LatestPackageVersion -packageName "func-cli-inproc"
Write-Host "##vso[task.setvariable variable=FUNC_CLI_INPROC_VERSION]$funcCliInprocVersion"
Write-Host "func-cli-inproc version: $funcCliInprocVersion"

$funcCliHostVersion = Get-LatestPackageVersion -packageName "func-cli-host"
Write-Host "##vso[task.setvariable variable=FUNC_CLI_HOST_VERSION]$funcCliHostVersion"
Write-Host "func-cli-host version: $funcCliHostVersion"
env:
SYSTEM_ACCESSTOKEN: $(System.AccessToken)

Expand All @@ -41,7 +61,7 @@ steps:
packageType: 'upack'
feed: 'internal/core-tools-nightly-build'
definition: 'func-cli-inproc'
version: '$(FUNC_CLI_VERSION)'
version: '$(FUNC_CLI_INPROC_VERSION)'
downloadPath: '$(Pipeline.Workspace)/func-cli-inproc'

- task: DownloadPackage@1
Expand All @@ -50,5 +70,5 @@ steps:
packageType: 'upack'
feed: 'internal/core-tools-nightly-build'
definition: 'func-cli-host'
version: '$(FUNC_CLI_VERSION)'
version: '$(FUNC_CLI_HOST_VERSION)'
downloadPath: '$(Pipeline.Workspace)/func-cli-host'
Loading