|
| 1 | +# Copyright (c) Microsoft Corporation. All rights reserved. |
| 2 | +# Licensed under the MIT License. |
| 3 | + |
| 4 | +# Stages Template: CLR Instrumentation Engine Release |
| 5 | +# |
| 6 | +# Migrated from the classic release definition 901. Only the first classic environment, |
| 7 | +# "Publish NuGets to internal InstrumentationEngine Feed", is migrated for now; the |
| 8 | +# remaining environments (preinstalled zip, drop upload/retain, NuGet.org headers, VS feed, |
| 9 | +# VS insertion, symbol/source archival) will be migrated separately. |
| 10 | +# |
| 11 | +# The stage has a pre-deploy approval in the classic definition and is modeled as a |
| 12 | +# deployment job targeting an Azure DevOps Environment; configure the matching approval |
| 13 | +# check on that environment: |
| 14 | +# |
| 15 | +# Environment Classic pre-deploy approver |
| 16 | +# ---------------------------------- ---------------------------------------- |
| 17 | +# CLRIE-Release-Internal-NuGet-Feed [DevDiv]\CLR Instrumentation Engine |
| 18 | + |
| 19 | +stages: |
| 20 | + |
| 21 | +# ===================================================================================== |
| 22 | +# Publish NuGets to internal InstrumentationEngine Feed |
| 23 | +# ===================================================================================== |
| 24 | +- stage: PublishNuGetsInternalFeed |
| 25 | + displayName: Publish NuGets to internal InstrumentationEngine Feed |
| 26 | + dependsOn: [] |
| 27 | + jobs: |
| 28 | + - deployment: Publish |
| 29 | + displayName: Publish NuGets to internal InstrumentationEngine Feed |
| 30 | + environment: CLRIE-Release-Internal-NuGet-Feed |
| 31 | + strategy: |
| 32 | + runOnce: |
| 33 | + deploy: |
| 34 | + steps: |
| 35 | + - download: none |
| 36 | + - download: ClrInstrumentationEngine-Signed-Yaml |
| 37 | + artifact: packages-windows-Release |
| 38 | + patterns: '**/Microsoft.InstrumentationEngine*.nupkg' |
| 39 | + displayName: Download Windows packages |
| 40 | + - download: ClrInstrumentationEngine-Signed-Yaml |
| 41 | + artifact: packages-linux-ubuntu-Release |
| 42 | + patterns: '**/Microsoft.InstrumentationEngine*.nupkg' |
| 43 | + displayName: Download Linux (ubuntu) packages |
| 44 | + - download: ClrInstrumentationEngine-Signed-Yaml |
| 45 | + artifact: packages-linux-alpine-Release |
| 46 | + patterns: '**/Microsoft.InstrumentationEngine*.nupkg' |
| 47 | + displayName: Download Linux (alpine) packages |
| 48 | + |
| 49 | + - task: NuGetAuthenticate@1 |
| 50 | + displayName: NuGet Authenticate |
| 51 | + |
| 52 | + - task: NuGetCommand@2 |
| 53 | + displayName: Push to DevDiv InstrumentationEngine feed |
| 54 | + inputs: |
| 55 | + command: push |
| 56 | + nuGetFeedType: internal |
| 57 | + publishVstsFeed: 59c1dfae-dea5-4ea5-ac83-c9abcb4ac339 |
| 58 | + packagesToPush: $(ArtifactsDirectory)\$(WindowsInstrumentationEngineNuGetArtifactPathPattern);$(ArtifactsDirectory)\$(LinuxInstrumentationEngineNuGetArtifactPathPattern) |
| 59 | + allowPackageConflicts: true |
| 60 | + publishPackageMetadata: true |
| 61 | + verbosityPush: Detailed |
| 62 | + |
| 63 | + # Classic equivalent: "Promote package to Release View" (deprecated marketplace task, |
| 64 | + # gated on PromoteToRelease). Implemented here against the Azure Artifacts packaging |
| 65 | + # REST API; only runs when PromoteToRelease is set to 'True'. |
| 66 | + - task: PowerShell@2 |
| 67 | + displayName: Promote package to Release View |
| 68 | + condition: and(succeeded(), eq(variables['PromoteToRelease'], 'True')) |
| 69 | + env: |
| 70 | + SYSTEM_ACCESSTOKEN: $(System.AccessToken) |
| 71 | + inputs: |
| 72 | + targetType: inline |
| 73 | + script: | |
| 74 | + $feedId = '59c1dfae-dea5-4ea5-ac83-c9abcb4ac339' |
| 75 | + $headers = @{ Authorization = "Bearer $env:SYSTEM_ACCESSTOKEN" } |
| 76 | + $root = Join-Path $env:ArtifactsDirectory 'ClrInstrumentationEngine-Signed-Yaml' |
| 77 | + Get-ChildItem -Path $root -Recurse -Filter *.nupkg | ForEach-Object { |
| 78 | + if ($_.Name -match '^(?<id>.+?)\.(?<ver>\d+\..*)\.nupkg$') { |
| 79 | + $id = $Matches.id; $ver = $Matches.ver |
| 80 | + $uri = "https://pkgs.dev.azure.com/DevDiv/_apis/packaging/feeds/$feedId/nuget/packages/$id/versions/$ver?api-version=7.1-preview.1" |
| 81 | + $body = @{ views = @{ op = 'add'; path = '/views/-'; value = 'Release' } } | ConvertTo-Json -Depth 5 |
| 82 | + Write-Host "Promoting $id $ver to Release view" |
| 83 | + Invoke-RestMethod -Uri $uri -Method Patch -Headers $headers -Body $body -ContentType 'application/json' |
| 84 | + } |
| 85 | + } |
0 commit comments