Skip to content

Commit 4458375

Browse files
authored
Add NuGet publishing (#40)
Introduces the ability to publish NuGet package releases from Project Mu repos. Also includes changes to publish artifacts by type to more cleanly control how they are produced & consumed - binaries, logs, and other. **Integration Notes** This commit updates the major version of mu_devops. This means it might require integration work that will result in a repo build breaking unless performed. - Artifacts are now published under three separate categories of "binaries", - "logs", and "other" - Previously all artifacts were published under `"Build Logs $(System.JobName)"` - Any flows dependent on artifact names will need to be updated - Three new templates are provided for reusable publishing of content in these categories: 1. `Steps/BinaryCopyAndPublish.yml` 2. `Steps/CommonLogCopyAndPublish.yml` 3. `Steps/OtherCopyAndPublish.yml` - `Steps/PrGate.yml` has a new template parameter - `artifacts_identifier` - This can be used to adjust the name assigned to artifacts so it makes the most sense for a given platform - The default value is an empty string - For most platforms, it is recommended to pass the package name and build target - `Steps/PrGate.yml` has new template parameters to control the binary and other content published. - The default value for both is an empty string **Non-Breaking Change Notes** - There is a new step template to easily publish content from the three artifact categories of a given pipeline to NuGet (`Steps/NuGet.yml`). - It is a step template so it can easily access file content already on the job build agent. - It provides the ability to select which categories of artifacts are published. - There is a new job template to generate a build matrix. This is tailored toward firmware build scenarios that involve groups of packages that are built together on a single agent and others that are individually built on a dedicated agent. Signed-off-by: Michael Kubacki <michael.kubacki@microsoft.com>
1 parent 6e00a3d commit 4458375

10 files changed

Lines changed: 439 additions & 83 deletions

Jobs/CreateBuildMatrix.yml

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
## @file
2+
# Mu DevOps template file to produce a build matrix according to the given
3+
# package and build target parameters.
4+
#
5+
# Copyright (c) Microsoft Corporation. All rights reserved.
6+
# SPDX-License-Identifier: BSD-2-Clause-Patent
7+
##
8+
9+
parameters:
10+
# An optional job dependency for this job to start.
11+
- name: dependency
12+
displayName: Job Dependency
13+
type: string
14+
default: ''
15+
# A group package list is not split to a separate package per job in the matrix.
16+
- name: group_package_list
17+
displayName: Group Package List (Optional - Will be Built Together)
18+
type: string
19+
default: ''
20+
# Each package in an individual package list is split to a separate job per package in the matrix.
21+
- name: individual_package_list
22+
displayName: Individual Package List (Required - Will be Built Individually)
23+
type: string
24+
default: ''
25+
# The targets that need be supported. These are kept as a list in the output of the matrix.
26+
- name: target_list
27+
displayName: Targets (e.g. DEBUG, RELEASE)
28+
type: string
29+
default: ''
30+
31+
jobs:
32+
33+
- job: CreateBuildMatrix
34+
displayName: Create Build Matrix
35+
dependsOn: ${{ parameters.dependency }}
36+
37+
steps:
38+
- checkout: none
39+
40+
- task: PowerShell@2
41+
name: CalculateMatrix
42+
displayName: Calculate Matrix
43+
inputs:
44+
targetType: 'inline'
45+
script: |
46+
$configs = @{}
47+
'${{ parameters.target_list }}'.split(',').Trim() | % {
48+
$t = $_
49+
if (![string]::IsNullOrEmpty('${{ parameters.individual_package_list }}')) {
50+
'${{ parameters.individual_package_list }}'.split(',').Trim() | % {
51+
$p = $_
52+
$configs["${p} ${t}"] = @{
53+
'package' = $p
54+
'target' = $t
55+
}
56+
}
57+
}
58+
if (![string]::IsNullOrEmpty('${{ parameters.group_package_list }}')) {
59+
$configs["Non-Platform Package(s) ${t}"] = @{
60+
'package' = '${{ parameters.group_package_list }}'.Trim()
61+
'target' = $t
62+
}
63+
}
64+
}
65+
$c = $configs | ConvertTo-Json -Depth 10 -Compress
66+
Write-Host "##vso[task.setvariable variable=Matrix;isOutput=true;]$c"
67+

Jobs/PrGate.yml

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -67,14 +67,19 @@ parameters:
6767
# Build step
6868
jobs:
6969

70+
- template: ../Jobs/CreateBuildMatrix.yml
71+
parameters:
72+
group_package_list: ${{ parameters.packages }}
73+
target_list: ${{ parameters.target_list }}
74+
7075
- job: Build
76+
dependsOn: CreateBuildMatrix
77+
condition: Succeeded('CreateBuildMatrix')
7178

7279
# Use matrix to speed up the build process
7380
strategy:
74-
matrix:
75-
TARGET_BUILD:
76-
Build.Pkgs: ${{ parameters.packages }}
77-
Build.Targets: ${{ parameters.target_list }}
81+
matrix: $[ dependencies.CreateBuildMatrix.outputs['CalculateMatrix.Matrix'] ]
82+
7883
workspace:
7984
clean: all
8085

@@ -93,9 +98,10 @@ jobs:
9398
- ${{ parameters.extra_steps }}
9499
- template: ../Steps/PrGate.yml
95100
parameters:
101+
artifacts_identifier: '$(package) $(target)'
96102
build_file: ${{ parameters.build_file }}
97-
build_pkgs: $(Build.Pkgs)
98-
build_targets: $(Build.Targets)
103+
build_pkgs: $(package)
104+
build_targets: $(target)
99105
build_archs: ${{ parameters.arch_list }}
100106
do_ci_build: ${{ parameters.do_ci_build }}
101107
do_ci_setup: ${{ parameters.do_ci_setup }}

Steps/BinaryCopyAndPublish.yml

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
## @file
2+
# Azure Pipelines step template to publish binary files specified in the template
3+
# parameters as build artifacts.
4+
#
5+
# Copyright (c) Microsoft Corporation. All rights reserved.
6+
# SPDX-License-Identifier: BSD-2-Clause-Patent
7+
##
8+
9+
parameters:
10+
- name: artifacts_binary
11+
displayName: Binary Artifacts to Publish
12+
type: string
13+
default: ''
14+
- name: artifacts_identifier
15+
displayName: Artifacts Identifier
16+
type: string
17+
default: 'Artifacts'
18+
19+
steps:
20+
# Copy binaries to the artifact staging directory
21+
- task: CopyFiles@2
22+
displayName: Copy Build Binaries
23+
inputs:
24+
targetFolder: "$(Build.ArtifactStagingDirectory)/Binaries"
25+
SourceFolder: "Build"
26+
contents: |
27+
${{ parameters.artifacts_binary }}
28+
flattenFolders: true
29+
condition: and(succeededOrFailed(), ne('${{ parameters.artifacts_binary }}', ''))
30+
31+
# Publish build artifacts to Azure Artifacts/TFS or a file share
32+
- task: PublishBuildArtifacts@1
33+
continueOnError: true
34+
displayName: Publish Build Binaries
35+
inputs:
36+
pathtoPublish: "$(Build.ArtifactStagingDirectory)/Binaries"
37+
artifactName: "Binaries ${{ parameters.artifacts_identifier }}"
38+
condition: and(succeededOrFailed(), ne('${{ parameters.artifacts_binary }}', ''))

Steps/BuildBaseTools.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ steps:
3535
- task: CopyFiles@2
3636
displayName: "Copy base tools build log"
3737
inputs:
38-
targetFolder: '$(Build.ArtifactStagingDirectory)'
38+
targetFolder: '$(Build.ArtifactStagingDirectory)/Logs'
3939
SourceFolder: 'BaseTools/BaseToolsBuild'
4040
contents: |
4141
BASETOOLS_BUILD*.*

Steps/BuildPlatform.yml

Lines changed: 27 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,18 @@
66
##
77

88
parameters:
9+
- name: artifacts_binary
10+
displayName: Binary Artifacts to Publish
11+
type: string
12+
default: ''
13+
- name: artifacts_identifier
14+
displayName: Artifacts Identifier
15+
type: string
16+
default: 'Artifacts'
17+
- name: artifacts_other
18+
displayName: Other Artifacts to Publish
19+
type: string
20+
default: ''
921
- name: build_arch
1022
displayName: Architectures (e.g. IA32, X64)
1123
type: string
@@ -50,10 +62,6 @@ parameters:
5062
displayName: Tool Chain (e.g. VS2022)
5163
type: string
5264
default: ''
53-
- name: extra_artifacts
54-
displayName: Additional Artifacts to Publish
55-
type: string
56-
default: ''
5765

5866
steps:
5967

@@ -121,35 +129,19 @@ steps:
121129
condition: and(and(gt(variables.pkg_count, 0), succeeded()), eq(variables['Run'], true))
122130
timeoutInMinutes: ${{ parameters.run_timeout }}
123131

124-
# Copy the build logs to the artifact staging directory
125-
- task: CopyFiles@2
126-
displayName: Copy Build Logs
127-
inputs:
128-
targetFolder: "$(Build.ArtifactStagingDirectory)"
129-
SourceFolder: "Build"
130-
contents: |
131-
BUILDLOG_*.txt
132-
BUILDLOG_*.md
133-
CI_*.txt
134-
CI_*.md
135-
CISETUP.txt
136-
SETUPLOG.txt
137-
UPDATE_LOG.txt
138-
PREVALLOG.txt
139-
TestSuites.xml
140-
**/BUILD_TOOLS_REPORT.html
141-
**/OVERRIDELOG.TXT
142-
BASETOOLS_BUILD*.*
143-
**/FD_REPORT.HTML
144-
${{ parameters.extra_artifacts }}
145-
flattenFolders: true
146-
condition: succeededOrFailed()
132+
# Copy build logs to the artifact staging directory
133+
- template: CommonLogCopyAndPublish.yml
134+
parameters:
135+
artifacts_identifier: ${{ parameters.artifacts_identifier }}
147136

148-
# Publish build artifacts to Azure Artifacts/TFS or a file share
149-
- task: PublishBuildArtifacts@1
150-
continueOnError: true
151-
displayName: Publish Build Logs
152-
inputs:
153-
pathtoPublish: "$(Build.ArtifactStagingDirectory)"
154-
artifactName: "Build Logs $(System.JobName)"
155-
condition: succeededOrFailed()
137+
# Copy build binaries to the artifact staging directory
138+
- template: BinaryCopyAndPublish.yml
139+
parameters:
140+
artifacts_binary: ${{ parameters.artifacts_binary }}
141+
artifacts_identifier: ${{ parameters.artifacts_identifier }}
142+
143+
# Copy other files to the artifact staging directory
144+
- template: OtherCopyAndPublish.yml
145+
parameters:
146+
artifacts_other: ${{ parameters.artifacts_other }}
147+
artifacts_identifier: ${{ parameters.artifacts_identifier }}

Steps/CommonLogCopyAndPublish.yml

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
## @file
2+
# Azure Pipelines step template to copy the common log files produced
3+
# by an edk2 firmware build.
4+
#
5+
# Copyright (c) Microsoft Corporation. All rights reserved.
6+
# SPDX-License-Identifier: BSD-2-Clause-Patent
7+
##
8+
9+
parameters:
10+
- name: artifacts_identifier
11+
displayName: Artifacts Identifier
12+
type: string
13+
default: 'Artifacts'
14+
15+
steps:
16+
- task: CopyFiles@2
17+
displayName: Copy Build Logs
18+
inputs:
19+
targetFolder: "$(Build.ArtifactStagingDirectory)/Logs"
20+
SourceFolder: "Build"
21+
contents: |
22+
**/BUILD_REPORT.TXT
23+
**/BUILD_TOOLS_REPORT.html
24+
**/BUILD_TOOLS_REPORT.json
25+
**/FD_REPORT.HTML
26+
**/OVERRIDELOG.TXT
27+
BASETOOLS_BUILD*.*
28+
BUILDLOG_*.md
29+
BUILDLOG_*.txt
30+
CI_*.md
31+
CI_*.txt
32+
CISETUP.txt
33+
coverage.html
34+
coverage.xml
35+
PREVALLOG.txt
36+
SETUPLOG.txt
37+
TestSuites.xml
38+
UPDATE_LOG.txt
39+
flattenFolders: true
40+
condition: succeededOrFailed()
41+
42+
- task: PublishBuildArtifacts@1
43+
continueOnError: true
44+
displayName: Publish Build Logs
45+
inputs:
46+
pathtoPublish: '$(Build.ArtifactStagingDirectory)/Logs'
47+
artifactName: 'Logs ${{ parameters.artifacts_identifier }}'
48+
condition: succeededOrFailed()

0 commit comments

Comments
 (0)