Skip to content

Promote NuGet.Client builds during official CI #48311

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Apr 24, 2025
Merged
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: 4 additions & 0 deletions .vsts-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -345,3 +345,7 @@ extends:
name: $(DncEngInternalBuildPool)
image: 1es-windows-2022
os: windows

- template: /eng/pipelines/templates/jobs/promote-nuget-client.yml@self
parameters:
assetName: NuGet.Protocol
62 changes: 62 additions & 0 deletions eng/pipelines/templates/jobs/promote-nuget-client.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
# NuGet.Client does not flow to the VMR directly but only to dotnet/sdk where it is validated
# Upon the version bump happens in dotnet/sdk, this job promotes that build of NuGet.Client to
# another channel from where it flows into the VMR.
# The sdk and nuget.client subscriptions are batched and go into the VMR in a single PR.
# More information: https://github.com/dotnet/arcade-services/issues/4618

parameters:
- name: assetName
type: string
displayName: Name of the asset to promote

jobs:
- job: PromoteNuGetClient
displayName: Promote NuGet Client
pool:
name: NetCore1ESPool-Publishing-Internal
image: windows.vs2019.amd64
os: windows

steps:
- template: ../steps/install-darc.yml@self

- template: ../steps/get-asset-info.yml@self
parameters:
assetName: ${{ parameters.assetName }}

- task: AzureCLI@2
displayName: 🟣 Assign build to channel
inputs:
azureSubscription: "Darc: Maestro Production"
scriptType: ps
scriptLocation: inlineScript
inlineScript: |
$version = '$(AssetVersion)'

Write-Host "Promoting build of asset ${{ parameters.assetName }} / $version..."

$assets = .\.dotnet\dotnet darc get-asset --name '${{ parameters.assetName }}' --version "$version" --max-age 60 --output-format json --ci
$parsedAssets = $assets | ConvertFrom-Json

if (-not $parsedAssets -or -not $parsedAssets[0]) {
Write-Error "No build found to promote version $version"
exit 1
}

$buildId = $parsedAssets[0].build.id
try {
$defaultChannels = .\.dotnet\dotnet darc get-default-channels --source-repo https://github.com/dotnet/sdk --branch "$(Build.SourceBranchName)" --output-format json --ci | ConvertFrom-Json
} catch {
Write-Host "No default channels found for branch $(Build.SourceBranchName) - no promotion will take place"
exit 0
}

if ($defaultChannels.Count -eq 0) {
Write-Host "Default channels list is empty for branch $(Build.SourceBranchName) - no promotion will take place"
exit 0
}
$targetChannel = $defaultChannels[0].channel.name

Write-Host "Promoting build $buildId to channel $targetChannel"

.\.dotnet\dotnet darc add-build-to-channel --id $buildId --channel "$targetChannel" --skip-assets-publishing --ci
42 changes: 42 additions & 0 deletions eng/pipelines/templates/steps/get-asset-info.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
### Looks up asset information from Version.Details.xml and stores it in variables

parameters:
- name: assetName
type: string
displayName: Name of the asset to look up

steps:
- task: AzureCLI@2
displayName: 🟣 Get version information
inputs:
azureSubscription: "Darc: Maestro Production"
scriptType: ps
scriptLocation: inlineScript
inlineScript: |
$ErrorActionPreference = 'Stop'
Write-Host "Searching for details of asset ${{ parameters.assetName }}..."

$dependencies = .\.dotnet\dotnet darc get-dependencies --name '${{ parameters.assetName }}' --ci
$version = $dependencies | Select-String -Pattern 'Version:\s+([^\s]+)' | Select-Object -First 1

if ($version -eq $null) {
Write-Error "Asset ${{ parameters.assetName }} not found in the dependency list"
exit 1
}

$version -match 'Version:\s+([^\s]+)' | Out-Null
$version = $matches[1]

$repository = $dependencies | Select-String -Pattern 'Repo:\s+([^\s]+)' | Select-Object -First 1
$repository -match 'Repo:\s+([^\s]+)' | Out-Null
$repository = $matches[1]

$commit = $dependencies | Select-String -Pattern 'Commit:\s+([^\s]+)' | Select-Object -First 1
$commit -match 'Commit:\s+([^\s]+)' | Out-Null
$commit = $matches[1]

Write-Host "##vso[task.setvariable variable=AssetRepository]$repository"
Write-Host "##vso[task.setvariable variable=AssetCommit]$commit"
Write-Host "##vso[task.setvariable variable=AssetVersion]$version"

Write-Host "Asset ${{ parameters.assetName }} found with version $version, commit $commit, repository $repository"
18 changes: 18 additions & 0 deletions eng/pipelines/templates/steps/install-darc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
steps:
- powershell: |
$ErrorActionPreference = 'Stop'
. .\eng\common\tools.ps1
$dotnetRoot = InitializeDotNetCli -install:$true
$dotnet = "$dotnetRoot\dotnet.exe"
& "$dotnet" tool restore
displayName: 🟣 Install darc (Windows)
condition: eq(variables['Agent.OS'], 'Windows_NT')

- script: |
set -e
. .\eng\common\tools.sh
dotnetRoot=$(InitializeDotNetCli --install)
dotnet="$dotnetRoot/dotnet"
$dotnet tool restore
displayName: 🟣 Install darc (Unix)
condition: ne(variables['Agent.OS'], 'Windows_NT')
Loading