diff --git a/.vsts-ci.yml b/.vsts-ci.yml index 2db92fc2813c..d6421f73acc2 100644 --- a/.vsts-ci.yml +++ b/.vsts-ci.yml @@ -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 diff --git a/eng/pipelines/templates/jobs/promote-nuget-client.yml b/eng/pipelines/templates/jobs/promote-nuget-client.yml new file mode 100644 index 000000000000..9dec7eea82af --- /dev/null +++ b/eng/pipelines/templates/jobs/promote-nuget-client.yml @@ -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