Skip to content

Commit 87fcf57

Browse files
authored
Move to v3 publishing (#1069)
* Switch to v3 publishing * add note * PR feedback: remove unneeded file
1 parent 036dc2b commit 87fcf57

File tree

4 files changed

+176
-31
lines changed

4 files changed

+176
-31
lines changed

azure-pipelines.yml

Lines changed: 1 addition & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -88,33 +88,4 @@ stages:
8888

8989
- template: /eng/stages/publish.yml
9090
parameters:
91-
# Publish channel configuration. The publish template wraps Arcade publishing and adds some
92-
# extras that aren't implemented in Arcade yet.
93-
#
94-
# - dependsOn: <ID of the Arcade stage that finalization should run after>
95-
# channel:
96-
# name: <Name of this channel, for logging and readability>
97-
# bar: <Name of the Arcade variable that contains the ID of this channel in BAR>
98-
# storage: <Name of the Latest channel to publish to in dotnetcli blob storage>
99-
dependsOnPublishStages:
100-
101-
- dependsOn: NetCore_Dev5_Publish
102-
channel:
103-
name: .NET 5 Dev
104-
bar: Net_5_Dev_Channel_Id
105-
storage: master
106-
public: true
107-
108-
- dependsOn: Net5_Preview8_Publish
109-
channel:
110-
name: .NET 5 Preview 5
111-
bar: Net_5_Preview8_Channel_Id
112-
storage: release/5.0-preview8
113-
public: false
114-
115-
- dependsOn: General_Testing_Publish
116-
channel:
117-
name: General Testing
118-
bar: GeneralTesting_Channel_Id
119-
storage: dev/validation
120-
public: true
91+
publishingInfraVersion: 3

eng/promote-build.yml

Lines changed: 170 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,170 @@
1+
# This file is the main entry point for the Build Promotion build definition.
2+
3+
parameters:
4+
- name: PublishingInfraVersion
5+
displayName: Which version of publishing should be used to promote the build definition?
6+
type: number
7+
default: 3
8+
values:
9+
- 2
10+
- 3
11+
12+
- name: BARBuildId
13+
displayName: "Maestro ID of the build to be promoted:"
14+
type: number
15+
16+
- name: PromoteToChannelIds
17+
displayName: Which Maestro channels' IDs should the build be promoted to? (comma separated)
18+
type: string
19+
default: ' '
20+
21+
- name: EnableSourceLinkValidation
22+
displayName: Should Sourcelink validation be performed?
23+
type: boolean
24+
default: false
25+
26+
- name: EnableNugetValidation
27+
displayName: Should NuGet metadata validation be performed?
28+
type: boolean
29+
default: false
30+
31+
- name: EnableSigningValidation
32+
displayName: Should signing validation be performed?
33+
type: boolean
34+
default: false
35+
36+
- name: PublishInstallersAndChecksums
37+
displayName: Should installers and checksums be published?
38+
type: boolean
39+
default: false
40+
41+
- name: SymbolPublishingAdditionalParameters
42+
displayName: Additional (MSBuild) properties for symbol publishing
43+
type: string
44+
default: ' '
45+
46+
- name: ArtifactsPublishingAdditionalParameters
47+
displayName: Additional (MSBuild) properties for general asset publishing
48+
type: string
49+
default: ' '
50+
51+
- name: SigningValidationAdditionalParameters
52+
displayName: Additional (MSBuild) properties for signing validation
53+
type: string
54+
default: ' '
55+
56+
trigger: none
57+
58+
variables:
59+
_DotNetArtifactsCategory: .NETCore
60+
61+
stages:
62+
- stage: prepare_promotion
63+
displayName: Prepare for Promotion
64+
jobs:
65+
- job:
66+
displayName: Validate Parameters
67+
variables:
68+
- template: common\templates\post-build\common-variables.yml
69+
steps:
70+
- checkout: none
71+
72+
- task: PowerShell@2
73+
displayName: Validate Build & Channel
74+
inputs:
75+
targetType: inline
76+
script: |
77+
# Keeping this script inline so that we don't need to checkout the whole repo to use just one file
78+
try {
79+
$buildApiEndpoint = "$(MaestroApiEndPoint)/api/builds/${Env:BARBuildId}?api-version=$(MaestroApiVersion)"
80+
81+
$apiHeaders = New-Object 'System.Collections.Generic.Dictionary[[String],[String]]'
82+
$apiHeaders.Add('Accept', 'application/json')
83+
$apiHeaders.Add('Authorization',"Bearer ${Env:MAESTRO_API_TOKEN}")
84+
85+
$buildInfo = try { Invoke-WebRequest -Method Get -Uri $buildApiEndpoint -Headers $apiHeaders | ConvertFrom-Json } catch { Write-Host "Error: $_" }
86+
87+
if (!$buildInfo) {
88+
Write-Host "Build with BAR ID ${Env:BARBuildId} was not found in BAR!"
89+
exit 1
90+
}
91+
92+
$channels = ${Env:PromoteToChannelIds} -split ","
93+
foreach ($channelId in $channels) {
94+
$channelApiEndpoint = "$(MaestroApiEndPoint)/api/channels/${channelId}?api-version=$(MaestroApiVersion)"
95+
$channelInfo = try { Invoke-WebRequest -Method Get -Uri $channelApiEndpoint -Headers $apiHeaders | ConvertFrom-Json } catch { Write-Host "Error: $_" }
96+
97+
if (!$channelInfo) {
98+
Write-Host "Channel with ID ${channelId} was not found in BAR. Aborting."
99+
exit 1
100+
}
101+
}
102+
103+
$azureDevOpsBuildNumber = $buildInfo.azureDevOpsBuildNumber
104+
$channelName = $channelInfo.name
105+
$azureDevOpsRepository = "Unknown"
106+
$lastIndexOfSlash = $buildInfo.azureDevOpsRepository.LastIndexOf('/')
107+
108+
if ($lastIndexOfSlash -ne -1) {
109+
$azureDevOpsRepository = $buildInfo.azureDevOpsRepository.Substring($lastIndexOfSlash + 1)
110+
111+
# Invalid chars in Azdo build number: '"', '/', ':', '<', '>', '\', '|', '?', '@', and '*'
112+
$azureDevOpsRepository = $azureDevOpsRepository -replace '["/:<>\\|?@*"]', '_'
113+
}
114+
115+
$buildNumberName = "Promoting $azureDevOpsRepository build $azureDevOpsBuildNumber to channel(s) ${Env:PromoteToChannelIds}#"
116+
117+
# Maximum buildnumber length is 255 chars
118+
if ($buildNumberName.Length -GT 255) {
119+
$buildNumberName = $buildNumberName.Substring(0, 255)
120+
}
121+
122+
Write-Host "##vso[build.updatebuildnumber]$buildNumberName"
123+
Write-Host "##vso[build.addbuildtag]$channelName"
124+
}
125+
catch {
126+
Write-Host $_
127+
Write-Host $_.Exception
128+
Write-Host $_.ScriptStackTrace
129+
exit 1
130+
}
131+
env:
132+
MAESTRO_API_TOKEN: $(MaestroApiAccessToken)
133+
BARBuildId: ${{ parameters.BARBuildId }}
134+
PromoteToChannelIds: ${{ parameters.PromoteToChannelIds }}
135+
136+
- ${{ if le(parameters.PublishingInfraVersion, 2) }}:
137+
- template: \eng\common\templates\post-build\post-build.yml
138+
parameters:
139+
PromoteToChannelIds: ${{ parameters.PromoteToChannelIds }}
140+
BARBuildId: ${{ parameters.BARBuildId }}
141+
142+
enableSourceLinkValidation: ${{ parameters.EnableSourceLinkValidation }}
143+
enableNugetValidation: ${{ parameters.EnableNugetValidation }}
144+
enableSigningValidation: ${{ parameters.EnableSigningValidation }}
145+
146+
validateDependsOn:
147+
- prepare_promotion
148+
149+
publishInstallersAndChecksums: ${{ parameters.PublishInstallersAndChecksums }}
150+
symbolPublishingAdditionalParameters: ${{ parameters.SymbolPublishingAdditionalParameters }}
151+
artifactsPublishingAdditionalParameters: ${{ parameters.ArtifactsPublishingAdditionalParameters }}
152+
signingValidationAdditionalParameters: ${{ parameters.SigningValidationAdditionalParameters }}
153+
154+
- ${{ if ge(parameters.PublishingInfraVersion, 3) }}:
155+
- template: \eng\publishing\v3\publish.yml
156+
parameters:
157+
PromoteToChannelIds: ${{ parameters.PromoteToChannelIds }}
158+
BARBuildId: ${{ parameters.BARBuildId }}
159+
160+
enableSourceLinkValidation: ${{ parameters.EnableSourceLinkValidation }}
161+
enableNugetValidation: ${{ parameters.EnableNugetValidation }}
162+
enableSigningValidation: ${{ parameters.EnableSigningValidation }}
163+
164+
validateDependsOn:
165+
- prepare_promotion
166+
167+
publishInstallersAndChecksums: ${{ parameters.PublishInstallersAndChecksums }}
168+
symbolPublishingAdditionalParameters: ${{ parameters.SymbolPublishingAdditionalParameters }}
169+
artifactsPublishingAdditionalParameters: ${{ parameters.ArtifactsPublishingAdditionalParameters }}
170+
signingValidationAdditionalParameters: ${{ parameters.SigningValidationAdditionalParameters }}

eng/stages/publish.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
parameters:
22
dependsOnPublishStages: []
3+
publishingInfraVersion: 3
34

45
stages:
56

67
# Stages-based publishing entry point
78
- template: /eng/common/templates/post-build/post-build.yml
89
parameters:
10+
publishingInfraVersion: ${{ parameters.publishingInfraVersion }}
911
validateDependsOn:
1012
- PrepareForPublish
1113
enableSymbolValidation: false

publish/prepare-artifacts.proj

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,7 @@
111111
</ItemGroup>
112112

113113
<!-- Push items to AzDO as build artifacts, generating the asset manifest as a side effect. -->
114+
<!-- TODO: remove "PublishingVersion" see https://github.com/dotnet/arcade/issues/6082 -->
114115
<PushToAzureDevOpsArtifacts
115116
AzureDevOpsCollectionUri="$(SYSTEM_TEAMFOUNDATIONCOLLECTIONURI)"
116117
AzureDevOpsProject="$(SYSTEM_TEAMPROJECT)"
@@ -126,7 +127,8 @@
126127
ManifestBuildId="$(BUILD_BUILDNUMBER)"
127128
ManifestCommit="$(BUILD_SOURCEVERSION)"
128129
IsStableBuild="$(IsStableBuild)"
129-
AssetManifestPath="$(AssetManifestFile)" />
130+
AssetManifestPath="$(AssetManifestFile)"
131+
PublishingVersion="3" />
130132

131133
<!-- Copy the generated manifest to the build's artifacts -->
132134
<Copy SourceFiles="$(AssetManifestFile)" DestinationFolder="$(TempWorkingDir)" />

0 commit comments

Comments
 (0)