Skip to content

Commit 2abbaf9

Browse files
pjcollinsdalexsoto
andauthored
[ci] Improve maestro artifact publishing (#20665)
The steps used to publish build asset information to maestro have been updated. The post build stage has been disabled for main and .NET 9, as maestro manifest generation and channel promotion will now run as part of the "Prepare .NET Release" stage. With the new `PushToAzureDevOpsArtifacts` task the build pipeline should now create all of the artifacts required for maestro artifact publishing. The `add-build-to-channel` darc command will now trigger a [Build Promotion Pipeline][0] that pushes build assets to the feed that corresponds to the maestro channel that is being updated. We should no longer need to push assets to various NuGet feeds in a separate step. [0]: https://dev.azure.com/devdiv/DevDiv/_build/results?buildId=9654802&view=logs&j=ba23343f-f710-5af9-782d-5bd26b102304&t=aec38b44-8611-5dd5-3900-5feff4e06d1b --------- Co-authored-by: Alex Soto <alex@alexsoto.me>
1 parent 9657179 commit 2abbaf9

File tree

9 files changed

+111
-105
lines changed

9 files changed

+111
-105
lines changed

dotnet/package/common.csproj

Lines changed: 25 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,6 @@
5353
<!-- it overwrites packageType -->
5454
<Import Project="Sdk.props" Sdk="Microsoft.DotNet.SharedFramework.Sdk" Version="$(MicrosoftDotNetBuildTasksFeedPackageVersion)" Condition="'$(PackageType)' != 'Template'" />
5555
<UsingTask TaskName="CreateFrameworkListFile" AssemblyFile="$(DotNetSharedFrameworkTaskFile)" Condition="'$(PackageType)' != 'Template'" />
56-
<UsingTask TaskName="GenerateBuildManifest" AssemblyFile="$(_MicrosoftDotNetBuildTasksFeedTaskDir)Microsoft.DotNet.Build.Tasks.Feed.dll" />
5756

5857
<Target Name="_GenerateFrameworkListFile" Condition=" '$(_CreateFrameworkList)' == 'true' Or '$(_CreateRuntimeList)' == 'true' ">
5958
<!-- https://github.com/dotnet/runtime/blob/0647ec314948904319da5eb15e9931f7c85ed1e2/src/installer/pkg/projects/Directory.Build.targets#L281 -->
@@ -113,15 +112,26 @@
113112
</Content>
114113
</ItemGroup>
115114

116-
<Target Name="GenerateBuildAssetRegistryManifest" >
115+
<!-- https://github.com/dotnet/arcade/blob/efc3da96e5ac110513e92ebd9ef87c73f44d8540/Documentation/DependencyFlowOnboardingWithoutArcade.md -->
116+
<Target Name="PushManifestToBuildAssetRegistry" >
117+
<PropertyGroup>
118+
<ArtifactsLogDir>$(BarManifestOutputPath)</ArtifactsLogDir>
119+
<AssetManifestFileName>Assets.xml</AssetManifestFileName>
120+
<AssetManifestPath>$(ArtifactsLogDir)AssetManifest\$(AssetManifestFileName)</AssetManifestPath>
121+
</PropertyGroup>
122+
123+
<Error Condition="Exists($(AssetManifestPath))" Text="The manifest file '$(AssetManifestPath)' already exists." />
124+
117125
<ItemGroup>
118-
<BuildArtifacts Include="$(NupkgPath)\Microsoft*.$(_PlatformName).*.nupkg" />
126+
<ItemsToPush Include="$(NupkgPath)\*.nupkg" />
119127
</ItemGroup>
120128

121-
<Error Condition="'@(BuildArtifacts)' == ''" Text="No packages to create manifest from." />
129+
<Error Condition="'@(ItemsToPush)' == ''" Text="No packages to push." />
130+
131+
<Message Text="Publishing %(ItemsToPush.Identity)" Importance="normal" />
122132

123133
<ItemGroup>
124-
<ManifestBuildData Include="InitialAssetsLocation=https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet6/nuget/v3/index.json" />
134+
<ManifestBuildData Include="InitialAssetsLocation=" />
125135
<ManifestBuildData Include="AzureDevOpsBuildId=$(BUILD_BUILDID)" />
126136
<ManifestBuildData Include="AzureDevOpsBuildDefinitionId=$(SYSTEM_DEFINITIONID)" />
127137
<ManifestBuildData Include="AzureDevOpsProject=$(SYSTEM_TEAMPROJECT)" />
@@ -130,31 +140,25 @@
130140
<ManifestBuildData Include="AzureDevOpsBranch=$(BUILD_SOURCEBRANCH)" />
131141
</ItemGroup>
132142

133-
<GenerateBuildManifest
134-
Artifacts="@(BuildArtifacts)"
135-
OutputPath="$(BarManifestOutputPath)\AssetManifest.xml"
136-
BuildId="$(BUILD_BUILDNUMBER)"
137-
BuildData="@(ManifestBuildData)"
138-
RepoUri="$(BUILD_REPOSITORY_URI)"
139-
RepoBranch="$(BUILD_SOURCEBRANCH)"
140-
RepoCommit="$(BUILD_SOURCEVERSION)"
143+
<PushToAzureDevOpsArtifacts
144+
ItemsToPush="@(ItemsToPush)"
145+
ManifestBuildData="@(ManifestBuildData)"
146+
ManifestRepoUri="$(BUILD_REPOSITORY_NAME)"
147+
ManifestBranch="$(BUILD_SOURCEBRANCH)"
148+
ManifestBuildId="$(BUILD_BUILDNUMBER)"
149+
ManifestCommit="$(BUILD_SOURCEVERSION)"
150+
AssetManifestPath="$(AssetManifestPath)"
141151
PublishingVersion="3" />
142-
</Target>
143-
144-
<Target Name="PushManifestToBuildAssetRegistry" >
145-
<PropertyGroup>
146-
<VersionPrefix>1.0.0</VersionPrefix>
147-
</PropertyGroup>
148152

149153
<MSBuild
150154
Targets="Restore"
151155
Projects="$(PkgMicrosoft_DotNet_Arcade_Sdk)\tools\SdkTasks\PublishBuildAssets.proj"
152-
Properties="Configuration=$(Configuration);RepoRoot=$(_RepositoryPath);VersionPrefix=$(VersionPrefix);NuGetPackageRoot=$(_RepositoryPath)\packages\"
156+
Properties="Configuration=$(Configuration);RepoRoot=$(_RepositoryPath);VersionPrefix=$(_PackageVersion);NuGetPackageRoot=$(_RepositoryPath)\packages\"
153157
/>
154158

155159
<MSBuild
156160
Projects="$(PkgMicrosoft_DotNet_Arcade_Sdk)\tools\SdkTasks\PublishBuildAssets.proj"
157-
Properties="Configuration=$(Configuration);RepoRoot=$(_RepositoryPath);VersionPrefix=$(VersionPrefix);ManifestsPath=$(BarManifestOutputPath);MaestroApiEndpoint=https://maestro-prod.westus2.cloudapp.azure.com;NuGetPackageRoot=$(_RepositoryPath)\packages\"
161+
Properties="Configuration=$(Configuration);RepoRoot=$(_RepositoryPath);VersionPrefix=$(_PackageVersion);ManifestsPath=$(ArtifactsLogDir)AssetManifest;MaestroApiEndpoint=https://maestro.dot.net;NuGetPackageRoot=$(_RepositoryPath)\packages\"
158162
/>
159163
</Target>
160164

eng/Version.Details.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,9 +70,9 @@
7070
</Dependency>
7171
</ProductDependencies>
7272
<ToolsetDependencies>
73-
<Dependency Name="Microsoft.DotNet.Build.Tasks.Feed" Version="6.0.0-beta.21212.6">
73+
<Dependency Name="Microsoft.DotNet.Build.Tasks.Feed" Version="8.0.0-beta.24225.1">
7474
<Uri>https://github.com/dotnet/arcade</Uri>
75-
<Sha>db49d790a4bfa977a9ed7436bf2aa242cefae45e</Sha>
75+
<Sha>67d23f4ba1813b315e7e33c71d18b63475f5c5f8</Sha>
7676
</Dependency>
7777
<Dependency Name="Microsoft.TemplateEngine.Tasks" Version="7.0.100-alpha.1.21601.1">
7878
<Uri>https://github.com/dotnet/templating</Uri>

eng/Versions.props

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<MicrosoftDotnetSdkInternalPackageVersion>8.0.107-servicing.24281.6</MicrosoftDotnetSdkInternalPackageVersion>
66
<MicrosoftNETILLinkTasksPackageVersion>8.0.5</MicrosoftNETILLinkTasksPackageVersion>
77
<MicrosoftNETILLinkPackageVersion>8.0.0-rtm.23524.7</MicrosoftNETILLinkPackageVersion>
8-
<MicrosoftDotNetBuildTasksFeedPackageVersion>6.0.0-beta.21212.6</MicrosoftDotNetBuildTasksFeedPackageVersion>
8+
<MicrosoftDotNetBuildTasksFeedPackageVersion>8.0.0-beta.24225.1</MicrosoftDotNetBuildTasksFeedPackageVersion>
99
<MicrosoftNETCoreAppRefPackageVersion>8.0.5</MicrosoftNETCoreAppRefPackageVersion>
1010
<MicrosoftNETWorkloadEmscriptenCurrentManifest80100TransportVersion>8.0.0-rtm.23511.3</MicrosoftNETWorkloadEmscriptenCurrentManifest80100TransportVersion>
1111
<MicrosoftNETRuntimeMonoTargetsSdkPackageVersion>8.0.0</MicrosoftNETRuntimeMonoTargetsSdkPackageVersion>

tools/devops/automation/post-build-pipeline.yml

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# YAML pipeline for post build operations.
22
# This pipeline will trigger automatically after successful completion of the `prepare_release` stage against the specified branches.
3+
# NOTE: This pipeline is now deprecated, maestro publishing has been moved to the "Prepare .NET Release" stage
34

45
trigger: none
56
pr: none
@@ -33,11 +34,9 @@ resources:
3334
source: xamarin-macios-ci
3435
trigger:
3536
branches:
36-
- main
3737
- release/*
3838
- net7.0
3939
- net8.0
40-
- net9.0
4140
- release-test/* # this is for testing the release pipeline on branches without GitHub's branch protection (so we can automate tests without requiring commits to go through pull requests, etc.).
4241
stages:
4342
- prepare_release
@@ -111,15 +110,15 @@ jobs:
111110
# Iterate over each build we pushed and add it to the default channel.
112111
- powershell: |
113112
Write-Host "Processing platforms: '$Env:CONFIGURATION_DOTNET_PLATFORMS'"
114-
$versionEndpoint = 'https://maestro-prod.westus2.cloudapp.azure.com/api/assets/darc-version?api-version=2019-01-16'
113+
$versionEndpoint = 'https://maestro.dot.net/api/assets/darc-version?api-version=2019-01-16'
115114
$darcVersion = $(Invoke-WebRequest -Uri $versionEndpoint -UseBasicParsing).Content
116115
$arcadeServicesSource = 'https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-eng/nuget/v3/index.json'
117116
$dotnetPlatforms = "$Env:CONFIGURATION_DOTNET_PLATFORMS".Split(' ', [StringSplitOptions]::RemoveEmptyEntries)
118117
& dotnet tool update microsoft.dotnet.darc --version "$darcVersion" --add-source "$arcadeServicesSource" --tool-path $(Agent.ToolsDirectory)\darc -v n
119118
foreach ($platform in $dotnetPlatforms) {
120119
$envVar = "ENVIRONMENT_REDIRECT_$($platform.ToUpper())_BARBUILDID"
121120
$barBuildId = [Environment]::GetEnvironmentVariable($envVar)
122-
& $(Agent.ToolsDirectory)\darc\darc add-build-to-channel --default-channels --id $barBuildId --publishing-infra-version 3 --skip-assets-publishing --password $(MaestroAccessToken) --azdev-pat $(publishing-dnceng-devdiv-code-r-build-re)
121+
& $(Agent.ToolsDirectory)\darc\darc add-build-to-channel --default-channels --id $barBuildId --publishing-infra-version 3 --password $(MaestroAccessToken) --azdev-pat $(publishing-dnceng-devdiv-code-r-build-re)
123122
Write-Host "Added $($platform) bar build id: $($barBuildId)"
124123
}
125124
displayName: Add builds to default darc channel

tools/devops/automation/templates/build/build-nugets.yml

Lines changed: 0 additions & 59 deletions
This file was deleted.

tools/devops/automation/templates/build/build-pkgs.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,10 @@ steps:
7171
timeoutInMinutes: 180
7272
7373
# build nugets
74-
- template: build-nugets.yml
74+
- bash: $(Build.SourcesDirectory)/xamarin-macios/tools/devops/automation/scripts/bash/build-nugets.sh
75+
displayName: 'Build Nugets'
76+
condition: and(succeeded(), contains(variables['configuration.BuildNugets'], 'True'), ne(variables['ENABLE_DOTNET'], ''))
77+
timeoutInMinutes: 180
7578

7679
- bash: $(System.DefaultWorkingDirectory)/xamarin-macios/tools/devops/automation/scripts/bash/generate-workload-rollback.sh
7780
name: workload_file

tools/devops/automation/templates/main-stage.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,10 @@ parameters:
5656
type: boolean
5757
default: true # default to true until otherwhise
5858

59+
- name: pushNugetsToMaestro
60+
type: boolean
61+
default: true
62+
5963
- name: isPR
6064
type: boolean
6165

@@ -438,6 +442,7 @@ stages:
438442
repositoryAlias: ${{ parameters.repositoryAlias }}
439443
commit: ${{ parameters.commit }}
440444
pushNugets: ${{ parameters.pushNugets }}
445+
pushNugetsToMaestro: ${{ parameters.pushNugetsToMaestro }}
441446

442447
- stage: funnel
443448
displayName: '${{ parameters.stageDisplayNamePrefix }}Collect signed artifacts'

tools/devops/automation/templates/pipelines/build-pipeline.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,14 @@ parameters:
6767
type: boolean
6868
default: false # only to be used when testing the CI and we do not need a signed pkg
6969

70+
- name: pushNugets
71+
type: boolean
72+
default: true
73+
74+
- name: pushNugetsToMaestro
75+
type: boolean
76+
default: true
77+
7078
- name: isPR
7179
displayName: Is PR build
7280
type: boolean
@@ -241,6 +249,8 @@ stages:
241249
enableAPIDiff: ${{ parameters.enableAPIDiff }}
242250
forceInsertion: ${{ parameters.forceInsertion }}
243251
skipESRP: ${{ parameters.skipESRP }}
252+
pushNugets: ${{ parameters.pushNugets }}
253+
pushNugetsToMaestro: ${{ parameters.pushNugetsToMaestro }}
244254
${{ if ne(length(parameters.testConfigurations), 0)}}:
245255
testConfigurations: ${{ parameters.testConfigurations }}
246256
deviceTestsConfigurations: ${{ parameters.deviceTestsConfigurations }}

tools/devops/automation/templates/release/vs-insertion-prep.yml

Lines changed: 61 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,10 @@ parameters:
2121
type: boolean
2222
default: true
2323

24+
- name: pushNugetsToMaestro
25+
type: boolean
26+
default: true
27+
2428
- name: stageDisplayNamePrefix
2529
type: string
2630
default: ''
@@ -92,7 +96,18 @@ stages:
9296
dependsOn: nuget_convert
9397
condition: "ne(stageDependencies.configure_build.configure.outputs['configure_platforms.ENABLE_DOTNET'],'')"
9498
variables:
95-
skipNugetSecurityAnalysis: true
99+
- name: skipNugetSecurityAnalysis
100+
value: true
101+
- name: INCLUDE_DOTNET_IOS
102+
value: $[ stageDependencies.configure_build.configure.outputs['configure_platforms.INCLUDE_DOTNET_IOS'] ]
103+
- name: INCLUDE_DOTNET_MACCATALYST
104+
value: $[ stageDependencies.configure_build.configure.outputs['configure_platforms.INCLUDE_DOTNET_MACCATALYST'] ]
105+
- name: INCLUDE_DOTNET_MACOS
106+
value: $[ stageDependencies.configure_build.configure.outputs['configure_platforms.INCLUDE_DOTNET_MACOS'] ]
107+
- name: INCLUDE_DOTNET_TVOS
108+
value: $[ stageDependencies.configure_build.configure.outputs['configure_platforms.INCLUDE_DOTNET_TVOS'] ]
109+
- ${{ if eq(parameters.isPR, false) }}:
110+
- group: Publish-Build-Assets
96111
pool:
97112
vmImage: windows-latest
98113
steps:
@@ -103,29 +118,13 @@ stages:
103118
patterns: |
104119
*.nupkg
105120
106-
- task: NuGetCommand@2
107-
displayName: Publish Nugets to dotnet8
108-
inputs:
109-
command: push
110-
packagesToPush: '$(Build.SourcesDirectory)/package/*.nupkg'
111-
nuGetFeedType: external
112-
publishFeedCredentials: dnceng-dotnet8
113-
114121
- task: DownloadPipelineArtifact@2
115122
inputs:
116123
artifactName: '${{ parameters.uploadPrefix }}vs-msi-nugets'
117124
downloadPath: '$(Build.SourcesDirectory)/${{ parameters.uploadPrefix}}vs-msi-nugets'
118125
patterns: |
119126
*.nupkg
120127
121-
- task: NuGetCommand@2
122-
displayName: Publish VS MSI Nugets to dotnet8
123-
inputs:
124-
command: push
125-
packagesToPush: '$(Build.SourcesDirectory)/${{ parameters.uploadPrefix }}vs-msi-nugets/*.nupkg'
126-
nuGetFeedType: external
127-
publishFeedCredentials: dnceng-dotnet8
128-
129128
- pwsh: |
130129
mkdir $(Build.SourcesDirectory)/nugets-blob
131130
cp $(Build.SourcesDirectory)/package/* $(Build.SourcesDirectory)/nugets-blob
@@ -168,3 +167,48 @@ stages:
168167
inputs:
169168
artifactName: ${{ parameters.uploadPrefix }}vsdrop-multitarget-signed
170169
downloadPath: $(Build.StagingDirectory)\$(MultiTargetVSDropCommitStatusName)
170+
171+
- script: make -C $(Build.SourcesDirectory)/dotnet version-props
172+
displayName: make version props
173+
174+
- powershell: |
175+
$varMap = @{ "INCLUDE_DOTNET_IOS" = "iOS"; "INCLUDE_DOTNET_MACCATALYST" = "MacCatalyst"; "INCLUDE_DOTNET_MACOS" = "macOS"; "INCLUDE_DOTNET_TVOS" = "tvOS" }
176+
foreach ($varName in $varMap.Keys) {
177+
if ([Environment]::GetEnvironmentVariable($varName)) {
178+
Write-Host "##vso[task.setvariable variable=MaestroProjectPlatformName]$($varMap[$varName])"
179+
exit 0;
180+
}
181+
}
182+
displayName: Set maestro project variable
183+
184+
- task: DotNetCoreCLI@2
185+
displayName: generate and publish BAR manifest
186+
inputs:
187+
projects: $(Build.SourcesDirectory)/dotnet/package/Microsoft.$(MaestroProjectPlatformName).Ref/package.csproj
188+
arguments: >-
189+
-t:PushManifestToBuildAssetRegistry
190+
-p:BuildAssetRegistryToken=$(MaestroAccessToken)
191+
-p:NupkgPath=$(Build.SourcesDirectory)/nugets-blob
192+
-bl:$(Build.ArtifactStagingDirectory)/maestro-binlogs/generate-bar-manifest.binlog
193+
workingDirectory: $(Build.SourcesDirectory)\..
194+
condition: and(succeeded(), eq('${{ parameters.pushNugetsToMaestro }}', 'true'))
195+
196+
- powershell: |
197+
$versionEndpoint = 'https://maestro.dot.net/api/assets/darc-version?api-version=2019-01-16'
198+
$darcVersion = $(Invoke-WebRequest -Uri $versionEndpoint -UseBasicParsing).Content
199+
$arcadeServicesSource = 'https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-eng/nuget/v3/index.json'
200+
& dotnet tool update microsoft.dotnet.darc --version "$darcVersion" --add-source "$arcadeServicesSource" --tool-path $(Agent.ToolsDirectory)\darc -v n
201+
& $(Agent.ToolsDirectory)\darc\darc add-build-to-channel --default-channels --id $(BARBuildId) --publishing-infra-version 3 --password $(MaestroAccessToken) --azdev-pat $(publishing-dnceng-devdiv-code-r-build-re)
202+
displayName: Add builds to default darc channel
203+
# We can't use the global.json located in the root of our repo, because makes it required to use the exact .NET version we're referencing in our eng/Versions.Details.xml file.
204+
# So in order to not use it, we set the working directory to the parent directory of xamarin-macios.
205+
workingDirectory: $(Build.SourcesDirectory)\..
206+
condition: and(succeeded(), eq('${{ parameters.pushNugetsToMaestro }}', 'true'))
207+
208+
- task: PublishPipelineArtifact@1
209+
displayName: 'Publish Artifact: maestro-binlogs'
210+
inputs:
211+
targetPath: $(Build.ArtifactStagingDirectory)/maestro-binlogs
212+
artifactName: ${{ parameters.uploadPrefix }}maestro-binlogs-$(System.JobAttempt)
213+
condition: and(succeededOrFailed(), eq('${{ parameters.pushNugetsToMaestro }}', 'true'))
214+
continueOnError: true

0 commit comments

Comments
 (0)