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

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
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: 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
64 changes: 64 additions & 0 deletions eng/pipelines/templates/jobs/promote-nuget-client.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
# 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.
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:
- task: AzureCLI@2
displayName: 🟣 Assign build to channel
inputs:
azureSubscription: "Darc: Maestro Production"
scriptType: ps
scriptLocation: inlineScript
inlineScript: |
$ErrorActionPreference = 'Stop'
. .\eng\common\tools.ps1
$dotnetRoot = InitializeDotNetCli -install:$true
$dotnet = "$dotnetRoot\dotnet.exe"
& "$dotnet" tool restore

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

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

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

Write-Host "Looking up build for version $version"

$assets = .\.dotnet\dotnet darc get-asset --name "$assetName" --version "$version" --max-age 60 --output-format json --ci
$buildId = ($assets | ConvertFrom-Json)[0].build.id

if ($buildId -eq $null) {
Write-Error "No build found to promote version $version"
exit 1
}

$defaultChannels = .\.dotnet\dotnet darc get-default-channels --source-repo https://github.com/dotnet/sdk --branch "$(Build.SourceBranchName)" --output-format json --ci | ConvertFrom-Json
if ($defaultChannels -eq $null) {
Write-Error "No default channels found 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
Loading