Skip to content
Open
Show file tree
Hide file tree
Changes from all 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
4 changes: 2 additions & 2 deletions eng/ci/consolidate-artifacts-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -78,14 +78,14 @@ extends:
jobs:
- template: /eng/ci/templates/official/jobs/download-cli-nuget-package.yml@self
parameters:
isNightlyBuild: ${{ eq(variables['Build.Reason'], 'Schedule') }}
isNightlyBuild: true

- ${{ each runtime in split(variables.supportedRuntimes,',') }}:
- template: /eng/ci/templates/official/jobs/consolidate-cli-artifacts.yml@self
parameters:
arch: ${{ runtime }}
displayName: ${{ replace(replace(runtime, '-', ''), '.', '') }}
isNightlyBuild: ${{ eq(variables['Build.Reason'], 'Schedule') }}
isNightlyBuild: true

- stage: TestArtifacts
dependsOn: 'ConsolidateArticacts'
Expand Down
24 changes: 15 additions & 9 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,22 @@ steps:
inputs:
targetType: 'inline'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we move this to a script file in eng/scripts?

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"
# Import the function from the script
$scriptPath = "$(Build.SourcesDirectory)/eng/scripts/get-latest-package-version.ps1"
Write-Host "Loading script from: $scriptPath"
. $scriptPath

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

$funcCliInprocVersion = Get-LatestPackageVersion -packageName "func-cli-inproc" -headers $headers
Write-Host "##vso[task.setvariable variable=FUNC_CLI_INPROC_VERSION]$funcCliInprocVersion"
Write-Host "func-cli-inproc version: $funcCliInprocVersion"
env:
SYSTEM_ACCESSTOKEN: $(System.AccessToken)

Expand All @@ -41,7 +47,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 Down
29 changes: 29 additions & 0 deletions eng/scripts/get-latest-package-version.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
function Get-LatestPackageVersion {
param(
[Parameter(Mandatory = $true)]
[string]$packageName,

[Parameter(Mandatory = $true)]
[hashtable]$headers
)

Write-Host "Fetching package: $packageName"

$feedUrl = "https://feeds.dev.azure.com/azfunc/internal/_apis/packaging/feeds/core-tools-nightly-build/packages"
$apiVersion = "7.1"

$searchUrl = "$feedUrl?packageNameQuery=$packageName&api-version=$apiVersion"
Write-Host "Search URL: $searchUrl"

$searchResponse = Invoke-RestMethod -Uri $searchUrl -Headers $headers -Method Get
$package = $searchResponse.value | Where-Object { $_.name -eq $packageName } | Select-Object -First 1

if (!$package) {
Write-Warning "Package '$packageName' not found in the feed."
return $null
}

$packageUrl = "$feedUrl/$($package.id)?api-version=$apiVersion"
$packageDetails = Invoke-RestMethod -Uri $packageUrl -Headers $headers -Method Get
return $packageDetails.versions[0].version
}
Loading