-
Notifications
You must be signed in to change notification settings - Fork 9
381 lines (372 loc) · 14.8 KB
/
release-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
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
# This pipeline will be triggered manually.
parameters:
- name: version
type: string
- name: prerelease
displayName: Prerelease?
type: boolean
default: true
- name: buildConfigs
type: object
default:
- pool:
name: Azure-Pipelines-1ESPT-ExDShared
image: windows-latest
os: windows
runtime: win-x64
archiveExt: zip
- pool:
name: Azure Pipelines
image: macOS-latest
os: macOS
runtime: osx-x64
archiveExt: tar.gz
- pool:
name: Azure Pipelines
image: macOS-latest
os: macOS
runtime: osx-arm64
archiveExt: tar.gz
variables:
- name: tags
value: "production"
readonly: true
- name: pythonVersion
value: 3.10
readonly: true
- name: artifactsPath
value: $(Build.ArtifactStagingDirectory)/azureauth-${{ parameters.version }}
readonly: true
trigger: none
pr: none
resources:
repositories:
- repository: OfficePipelineTemplates
type: git
name: 1ESPipelineTemplates/OfficePipelineTemplates
ref: refs/tags/release
extends:
template: v1/Office.Official.PipelineTemplate.yml@OfficePipelineTemplates
parameters:
pool:
name: Azure-Pipelines-1ESPT-ExDShared
image: ubuntu-latest
os: linux
sdl:
sourceAnalysisPool:
name: Azure-Pipelines-1ESPT-ExDShared
image: windows-latest
os: windows
# This prevents auto-injected Roslyn task from running the build again.
roslyn:
copyLogsOnly: true
stages:
- stage: validate
displayName: Validate
jobs:
- job: validate
displayName: Validate
steps:
- checkout: self
- task: UsePythonVersion@0
displayName: Use Python $(pythonVersion)
inputs:
versionSpec: $(pythonVersion)
- task: Bash@3
inputs:
targetType: inline
script: |
echo ${{ parameters.version }} | python ./bin/version.py
- stage: build
displayName: Build
jobs:
- ${{ each config in parameters.buildConfigs }}:
- job: build_${{ replace(config.runtime,'-', '_') }}
displayName: Building for ${{ config.runtime }} on ${{ config.pool.name }}
pool:
name: ${{ config.pool.name }}
image: ${{ config.pool.image }}
os: ${{ config.pool.os }}
templateContext:
outputs:
- output: pipelineArtifact
targetPath: dist/${{ config.runtime }}
artifactName: azureauth-${{ parameters.version }}-${{ config.runtime }}
steps:
- checkout: self
- task: UseDotNet@2
displayName: Use .NET Core sdk 8.x
inputs:
version: 8.x
- task: NuGetToolInstaller@0
displayName: Use NuGet 6.x
inputs:
versionSpec: 6.x
- task: DotNetCoreCLI@2
displayName: Install dependencies
inputs:
command: restore
feedsToUse: select
vstsFeed: $(VSTS_FEED_ID)
includeNuGetOrg: false
arguments: --runtime ${{ config.runtime }}
# 1ES PT requires explicit build task for Roslyn analysis. Auto-injected Roslyn task will use build logs from this build.
- task: DotNetCoreCLI@2
displayName: Build projects
env:
ADO_TOKEN: $(System.AccessToken)
inputs:
command: 'build'
projects: '**/*.csproj'
- task: DotNetCoreCLI@2
displayName: Test
inputs:
command: test
arguments: --configuration release --no-restore
- task: DotNetCoreCLI@2
displayName: Build artifacts
env:
ADO_TOKEN: $(System.AccessToken)
inputs:
command: publish
projects: src/AzureAuth/AzureAuth.csproj
arguments: -p:Version=${{ parameters.version }} --configuration release --self-contained true --runtime ${{ config.runtime }} --output dist/${{ config.runtime }}
publishWebProjects: false
zipAfterPublish: false
modifyOutputPath: true
- stage: sign
displayName: Sign
dependsOn: build
jobs:
- ${{ each config in parameters.buildConfigs }}:
- job: sign_${{ replace(config.runtime,'-', '_') }}
displayName: Signing ${{ config.runtime }}
pool:
name: Azure-Pipelines-1ESPT-ExDShared
image: windows-latest
os: windows
templateContext:
sdl:
suppression:
suppressionFile: $(Build.SourcesDirectory)\.config\guardian\SDL\.gdnsuppress
inputs:
- input: pipelineArtifact
artifactName: azureauth-${{ parameters.version }}-${{ config.runtime }}
targetPath: $(artifactsPath)-${{ config.runtime }}
outputs:
- output: pipelineArtifact
artifactName: azureauth-${{ parameters.version }}-${{ config.runtime }}-signed
targetPath: $(artifactsPath)-${{ config.runtime }}-signed
steps:
- task: EsrpCodeSigning@5
displayName: Sign artifacts win-x64
condition: eq('${{ config.runtime }}', 'win-x64')
inputs:
ConnectedServiceName: $(ESRP_KV_SERVICE_CONNECTION)
AppRegistrationClientId: $(SIGNING_AAD_ID)
AppRegistrationTenantId: $(SIGNING_TENANT_ID)
AuthAKVName: $(AZURE_VAULT)
AuthCertName: $(AZURE_VAULT_ESRP_AAD_CERT_NAME)
AuthSignCertName: $(AZURE_VAULT_ESRP_REQ_CERT_NAME)
FolderPath: $(artifactsPath)-${{ config.runtime }}/AzureAuth
Pattern: '*.dll,*.exe'
signConfigType: 'inlineSignParams'
inlineOperation: |
[
{
"KeyCode": "$(SIGNING_KEY_CODE_AUTHENTICODE)",
"OperationCode": "SigntoolSign",
"ToolName": "sign",
"ToolVersion": "1.0",
"Parameters": {
"OpusName": "Microsoft",
"OpusInfo": "https://www.microsoft.com",
"FileDigest": "/fd SHA256",
"PageHash": "/NPH",
"TimeStamp": "/tr \"http://rfc3161.gtm.corp.microsoft.com/TSS/HttpTspServer\" /td sha256"
}
},
{
"KeyCode": "$(SIGNING_KEY_CODE_AUTHENTICODE)",
"OperationCode": "SigntoolVerify",
"ToolName": "sign",
"ToolVersion": "1.0",
"Parameters": {}
}
]
SessionTimeout: '60'
MaxConcurrency: '50'
MaxRetryAttempts: '5'
PendingAnalysisWaitTimeoutMinutes: '5'
# We need to zip the artifacts for osx before sending to ESRP for signing.
- task: ArchiveFiles@2
displayName: Codesigning - zip artifacts to send to ESRP
condition: startsWith('${{ config.runtime }}', 'osx')
inputs:
rootFolderOrFile: $(artifactsPath)-${{ config.runtime }}
includeRootFolder: false
archiveType: zip
archiveFile: $(artifactsPath)-${{ config.runtime }}.zip
- task: EsrpCodeSigning@5
displayName: Sign artifacts osx
condition: startsWith('${{ config.runtime }}', 'osx')
inputs:
ConnectedServiceName: $(ESRP_KV_SERVICE_CONNECTION)
AppRegistrationClientId: $(SIGNING_AAD_ID)
AppRegistrationTenantId: $(SIGNING_TENANT_ID)
AuthAKVName: $(AZURE_VAULT)
AuthCertName: $(AZURE_VAULT_ESRP_AAD_CERT_NAME)
AuthSignCertName: $(AZURE_VAULT_ESRP_REQ_CERT_NAME)
FolderPath: $(Build.ArtifactStagingDirectory)
Pattern: 'azureauth-${{ parameters.version }}-${{ config.runtime }}.zip'
signConfigType: 'inlineSignParams'
inlineOperation: |
[
{
"KeyCode": "$(SIGNING_KEY_CODE_MAC)",
"OperationCode": "MacAppDeveloperSign",
"ToolName": "sign",
"ToolVersion": "1.0",
"Parameters": {}
},
{
"KeyCode": "$(SIGNING_KEY_CODE_MAC)",
"OperationCode": "SigntoolVerify",
"ToolName": "sign",
"ToolVersion": "1.0",
"Parameters": {}
}
]
SessionTimeout: '60'
MaxConcurrency: '50'
MaxRetryAttempts: '5'
PendingAnalysisWaitTimeoutMinutes: '5'
- task: ExtractFiles@1
displayName: Extract signed artifacts osx
condition: startsWith('${{ config.runtime }}', 'osx')
inputs:
archiveFilePatterns: $(artifactsPath)-${{ config.runtime }}.zip
destinationFolder: $(artifactsPath)-${{ config.runtime }}
cleanDestinationFolder: true
overwriteExistingFiles: true
# We rename the signed artifacts to avoid conflicts with the unsigned pipeline artifacts from the previous stage.
- task: PowerShell@2
displayName: Rename signed artifacts
inputs:
workingDirectory: $(Build.ArtifactStagingDirectory)
targetType: 'inline'
script: |
mv "azureauth-${{ parameters.version }}-${{ config.runtime }}" "azureauth-${{ parameters.version }}-${{ config.runtime }}-signed"
# Currently we package artifacts into the most commonly accessible archive format for their respective platforms.
- stage: package
displayName: Package
dependsOn: sign
jobs:
- job: package
displayName: Package
pool:
name: Azure-Pipelines-1ESPT-ExDShared
image: ubuntu-latest
os: linux
templateContext:
inputs:
- ${{ each config in parameters.buildConfigs }}:
- input: pipelineArtifact
artifactName: azureauth-${{ parameters.version }}-${{ config.runtime }}-signed
targetPath: $(artifactsPath)-${{ config.runtime }}-signed
outputs:
- output: pipelineArtifact
artifactName: azureauth-${{ parameters.version }}-packaged
targetPath: $(artifactsPath)-packaged
steps:
- task: PowerShell@2
displayName: Create directory to place packaged artifacts
inputs:
workingDirectory: $(Build.ArtifactStagingDirectory)
targetType: 'inline'
script: |
mkdir azureauth-${{ parameters.version }}-packaged
- task: ArchiveFiles@2
displayName: Create win-x64 archive
inputs:
rootFolderOrFile: $(artifactsPath)-win-x64-signed/AzureAuth
includeRootFolder: false
archiveType: zip
archiveFile: $(artifactsPath)-packaged/azureauth-${{ parameters.version }}-win-x64.zip
- task: Bash@3
displayName: Prepare osx-x64 executables
inputs:
targetType: inline
workingDirectory: $(Build.ArtifactStagingDirectory)
script: |
cd azureauth-${{ parameters.version }}-osx-x64-signed/AzureAuth
chmod +x azureauth createdump *.dylib
- task: ArchiveFiles@2
displayName: Create osx-x64 archive
inputs:
rootFolderOrFile: $(artifactsPath)-osx-x64-signed/AzureAuth
includeRootFolder: false
archiveType: tar
tarCompression: gz
archiveFile: $(artifactsPath)-packaged/azureauth-${{ parameters.version }}-osx-x64.tar.gz
- task: Bash@3
displayName: Prepare osx-arm64 executables
inputs:
workingDirectory: $(Build.ArtifactStagingDirectory)
targetType: inline
script: |
cd azureauth-${{ parameters.version }}-osx-arm64-signed/AzureAuth
chmod +x azureauth createdump *.dylib
- task: ArchiveFiles@2
displayName: Create osx-arm64 archive
inputs:
rootFolderOrFile: $(artifactsPath)-osx-arm64-signed/AzureAuth
includeRootFolder: false
archiveType: tar
tarCompression: gz
archiveFile: $(artifactsPath)-packaged/azureauth-${{ parameters.version }}-osx-arm64.tar.gz
- stage: release
displayName: Release
dependsOn: package
jobs:
- job: approval
displayName: Manual Approval
pool: server
timeoutInMinutes: 5760 # job times out in 4 days
steps:
- task: ManualValidation@0
timeoutInMinutes: 4320 # task times out in 3 days
inputs:
notifyUsers: $(REVIEWER)
instructions: 'Review the AzureAuth GitHub Release.'
- job: release
displayName: Release
dependsOn: approval
pool:
name: Azure-Pipelines-1ESPT-ExDShared
image: ubuntu-latest
os: linux
templateContext:
inputs:
- input: pipelineArtifact
artifactName: azureauth-${{ parameters.version }}-packaged
targetPath: $(artifactsPath)-packaged
steps:
- task: GitHubRelease@1
displayName: Create AzureAuth GitHub Release
inputs:
gitHubConnection: $(GITHUB_RELEASE_SERVICE_CONNECTION)
repositoryName: 'AzureAD/microsoft-authentication-cli'
action: 'create'
target: $(Build.SourceVersion)
tagSource: 'userSpecifiedTag'
tag: ${{ parameters.version }}
isPrerelease: ${{ parameters.prerelease }}
isDraft: false
addChangeLog: false
releaseNotesSource: 'inline'
releaseNotesInline: "Release ${{ parameters.version }}. See [`CHANGELOG.md`](https://github.com/AzureAD/microsoft-authentication-cli/blob/${{ parameters.version }}/CHANGELOG.md) for updates."
assets: |
$(artifactsPath)-packaged/azureauth-${{ parameters.version }}-win-x64.zip
$(artifactsPath)-packaged/azureauth-${{ parameters.version }}-osx-x64.tar.gz
$(artifactsPath)-packaged/azureauth-${{ parameters.version }}-osx-arm64.tar.gz