-
Notifications
You must be signed in to change notification settings - Fork 55
/
azure-pipelines.yml
253 lines (223 loc) · 10.1 KB
/
azure-pipelines.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
pr:
branches:
include:
- dev
- v*.x
schedules:
- cron: '0 12 * * 0'
displayName: Weekly Sunday build
branches:
include:
- dev
always: true
trigger:
branches:
include:
- dev
- v*.x
tags:
include:
- v*.*.*
variables:
# It is a release build if it is triggered by pushing a tag.
isReleaseBuild: ${{ startsWith(variables['Build.SourceBranch'], 'refs/tags/') }}
${{ if eq(variables.isReleaseBuild, 'True') }}:
agentOSes: Windows
${{ else }}:
agentOSes: Windows,Linux
prefix: $[format('0.{0:yyyy}.{0:MMdd}', pipeline.startTime)]
version: $[format('{0}.{1}', variables.prefix, counter(variables.prefix, 1))] # e.g. 0.2001.0203.4
fileVersion: $[variables.version]
Codeql.Enabled: true
jobs:
- ${{ each agentOS in split(variables.agentOSes, ',') }}:
- job: buildExtension${{ agentOS }}
displayName: WebJobs Extension (${{ agentOS }})
pool:
${{ if eq(variables.isReleaseBuild, 'True') }}:
name: 1ES-Hosted-AzFunc
demands:
- ImageOverride -equals MMS2022TLS
${{ elseif eq(agentOS, 'Windows') }}:
vmImage: windows-latest
${{ elseif eq(agentOS, 'Linux') }}:
vmImage: ubuntu-latest
steps:
- ${{ if eq(variables.isReleaseBuild, 'True') }}:
- powershell: | # Allow tags matching v1.2.3 and v1.2.3-xyz1
$found = '$(Build.SourceBranchName)' | Select-String -Pattern '^v(((?:0|[1-9]\d*)\.(?:0|[1-9]\d*)\.(?:0|[1-9]\d*))(?:-\w+)?)$'
if (-not $found) {
Write-Error "Found unexpected tag name: $(Build.SourceBranchName)."
exit 1
}
Write-Host "##vso[task.setvariable variable=version]$($found.Matches.Groups[1].Value)"
Write-Host "##vso[task.setvariable variable=fileVersion]$($found.Matches.Groups[2].Value)"
displayName: Extract version # e.g. 1.2.3
- ${{ if eq(variables.isReleaseBuild, 'True') }}:
# .NET Core 2.1 SDK is required by ESRP Code Signing tasks.
- task: UseDotNet@2
displayName: Acquire .NET Core 2.1 SDK
inputs:
packageType: sdk
version: 2.1.x
performMultiLevelLookup: true
- task: UseDotNet@2
displayName: Acquire .NET 7.0 SDK
inputs:
packageType: sdk
version: 7.0.x
performMultiLevelLookup: true
- task: DotNetCoreCLI@2
displayName: Build solution
inputs:
command: build
workingDirectory: extension
arguments: --configuration Release -property:Version=$(fileVersion) -property:CommitHash=$(Build.SourceVersion)
- task: DotNetCoreCLI@2
displayName: Test extension
inputs:
command: test
workingDirectory: extension
arguments: --configuration Debug
- ${{ if eq(variables.isReleaseBuild, 'True') }}:
- task: EsrpCodeSigning@1
displayName: Sign extension assembly
inputs:
connectedServiceName: ESRP Service
folderPath: extension/WebJobs.Extensions.RabbitMQ/bin/Release/netstandard2.0
pattern: Microsoft.Azure.WebJobs.Extensions.RabbitMQ.dll
signConfigType: inlineSignParams
inlineOperation: |
[
{
"KeyCode": "CP-230012",
"OperationCode": "SigntoolSign",
"Parameters": {
"OpusName": "Microsoft",
"OpusInfo": "http://www.microsoft.com",
"FileDigest": "/fd \"SHA256\"",
"PageHash": "/NPH",
"TimeStamp": "/tr \"http://rfc3161.gtm.corp.microsoft.com/TSS/HttpTspServer\" /td sha256"
},
"ToolName": "sign",
"ToolVersion": "1.0"
},
{
"KeyCode": "CP-230012",
"OperationCode": "SigntoolVerify",
"Parameters": {},
"ToolName": "sign",
"ToolVersion": "1.0"
}
]
- ${{ if eq(variables.isReleaseBuild, 'True') }}:
- task: DotNetCoreCLI@2
displayName: Pack extension
inputs:
command: pack
searchPatternPack: extension/WebJobs.Extensions.RabbitMQ/WebJobs.Extensions.RabbitMQ.csproj
configurationToPack: Release
buildProperties: Version=$(version);CommitHash=$(Build.SourceVersion)
outputDir: $(Build.ArtifactStagingDirectory)/$(version)
nobuild: true
includesymbols: true
verbosityPack: minimal
- ${{ if eq(variables.isReleaseBuild, 'True') }}:
- task: EsrpCodeSigning@1
displayName: Sign extension package
inputs:
connectedServiceName: ESRP Service
folderPath: $(Build.ArtifactStagingDirectory)/$(version)
pattern: Microsoft.Azure.WebJobs.Extensions.RabbitMQ.*.nupkg
signConfigType: inlineSignParams
inlineOperation: |
[
{
"KeyCode": "CP-401405",
"OperationCode": "NuGetSign",
"Parameters": {},
"ToolName": "sign",
"ToolVersion": "1.0"
},
{
"KeyCode": "CP-401405",
"OperationCode": "NuGetVerify",
"Parameters": {},
"ToolName": "sign",
"ToolVersion": "1.0"
}
]
- ${{ if eq(variables.isReleaseBuild, 'True') }}:
- task: DeleteFiles@1
displayName: Cleanup staging directory
inputs:
sourceFolder: $(Build.ArtifactStagingDirectory)/$(version)
# contents: '!(Microsoft.Azure.WebJobs.Extensions.RabbitMQ.*.nupkg)'
contents: CodeSignSummary-*.md
- ${{ if eq(variables.isReleaseBuild, 'True') }}:
- task: ManifestGeneratorTask@0
displayName: Generate SBOM manifest
inputs:
buildDropPath: $(Build.ArtifactStagingDirectory)/$(version)
packageName: Azure Functions RabbitMQ Extension
packageVersion: $(version)
- ${{ if eq(variables.isReleaseBuild, 'True') }}:
- publish: $(Build.ArtifactStagingDirectory)
displayName: Publish extension package
artifact: drop-extension
- job: buildJavaLibrary${{ agentOS }}
displayName: Java Library (${{ agentOS }})
pool:
${{ if eq(variables.isReleaseBuild, 'True') }}:
name: 1ES-Hosted-AzFunc
demands:
- ImageOverride -equals MMS2022TLS
${{ elseif eq(agentOS, 'Windows') }}:
vmImage: windows-latest
${{ elseif eq(agentOS, 'Linux') }}:
vmImage: ubuntu-latest
steps:
- ${{ if eq(variables.isReleaseBuild, 'True') }}:
- powershell: | # Allow tags matching v1.2.3 and v1.2.3-xyz1
$found = '$(Build.SourceBranchName)' | Select-String -Pattern '^v((?:0|[1-9]\d*)\.(?:0|[1-9]\d*)\.(?:0|[1-9]\d*)(?:-\w+)?)$'
if (-not $found) {
Write-Error "Found unexpected tag name: $(Build.SourceBranchName)."
exit 1
}
Write-Host "##vso[task.setvariable variable=version]$($found.Matches.Groups[1].Value)"
displayName: Extract version # e.g. 1.2.3
# A combination of --batch-mode and --define=org.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn
# options prevents spurious logging about downloading of Maven packages.
- task: Maven@3
displayName: Set library version
inputs:
mavenPomFile: java-library/pom.xml
goals: versions:set
options: --batch-mode --define=newVersion=$(version) --define=org.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn --update-snapshots
- task: Maven@3
displayName: Build library
inputs:
mavenPomFile: java-library/pom.xml
options: --batch-mode --define=org.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn --update-snapshots
- ${{ if eq(variables.isReleaseBuild, 'True') }}:
- powershell: |
$prefix = 'azure-functions-java-library-rabbitmq-$(version)'
$source = 'java-library'
$destination = '$(Build.ArtifactStagingDirectory)/$(version)'
New-Item $destination -ItemType Directory
Copy-Item "$source/pom.xml" "$destination/$prefix.pom"
Copy-Item "$source/target/$prefix.jar" "$destination/$prefix.jar"
Copy-Item "$source/target/$prefix-javadoc.jar" "$destination/$prefix-javadoc.jar"
Copy-Item "$source/target/$prefix-sources.jar" "$destination/$prefix-sources.jar"
displayName: Copy output files
- ${{ if eq(variables.isReleaseBuild, 'True') }}:
- task: ManifestGeneratorTask@0
displayName: Generate SBOM manifest
inputs:
buildDropPath: $(Build.ArtifactStagingDirectory)/$(version)
packageName: Azure Functions RabbitMQ Java Bindings
packageVersion: $(version)
- ${{ if eq(variables.isReleaseBuild, 'True') }}:
- publish: $(Build.ArtifactStagingDirectory)
displayName: Publish library package
artifact: drop-java-library