forked from microsoft/azure-pipelines-agent
-
Notifications
You must be signed in to change notification settings - Fork 0
/
.vsts.release.yml
358 lines (314 loc) Β· 12.8 KB
/
.vsts.release.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
resources:
containers:
- container: dotnetcore_arm
image: huangtingluo/azure-pipelines-agent-eng:arm
- container: dotnetcore_centos6
image: huangtingluo/azure-pipelines-agent-eng:centos6
stages:
- stage: Create_Release_Branch
displayName: Create Release Branch
jobs:
################################################################################
- job: Create_Release_Branch
################################################################################
condition: eq(variables['Build.SourceBranch'], 'refs/heads/master')
displayName: Create Release Branch
pool:
vmImage: ubuntu-18.04
steps:
- checkout: self
- script: |
cd release
npm install
node createReleaseBranch.js $(version)
env:
EDITOR: cat
PAT: $(GithubToken)
displayName: Push release branch to GitHub
- stage: Build
dependsOn: Create_Release_Branch
jobs:
################################################################################
- job: build_windows_agent_x64
################################################################################
displayName: Windows Agent (x64)
pool:
vmImage: vs2017-win2016
variables:
layoutRoot: '_layout\win-x64'
steps:
# Steps template for windows platform
- template: .vsts.template.windows.yml
parameters:
testLogTitle: 'Windows-x64'
# Package .NET Core Windows dependency (VC++ Redistributable)
- template: .azure-pipelines/package-vcredist.yml
parameters:
layoutRoot: ${{ variables.layoutRoot }}
flavor: 'x64'
# Signing steps
- template: .azure-pipelines/signing.yml
parameters:
layoutRoot: ${{ variables.layoutRoot }}
# Create agent package zip
- script: dev.cmd package Release
workingDirectory: src
displayName: Package Release
# Upload agent package zip as build artifact
- task: PublishBuildArtifacts@1
displayName: Publish Artifact (Windows)
inputs:
pathToPublish: _package
artifactName: agent
artifactType: container
# Verify all binaries are signed (generate report)
- task: securedevelopmentteam.vss-secure-development-tools.build-task-codesignvalidation.CodesignValidation@0
displayName: 'Generate Codesign Report'
inputs:
path: '$(layoutRoot)'
# Verify all binaries are signed (check report)
- task: securedevelopmentteam.vss-secure-development-tools.build-task-postanalysis.PostAnalysis@1
displayName: 'Verify Codesign Report'
inputs:
CodesignValidation: true
CodesignValidationBreakOn: WarningAbove
ToolLogsNotFoundAction: Error
################################################################################
- job: build_windows_agent_x86
################################################################################
displayName: Windows Agent (x86)
pool:
name: buildDevs
demands: 'Agent.OSArchitecture -equals X86'
variables:
layoutRoot: '_layout\win-x86'
steps:
# Steps template for windows platform
- template: .vsts.template.windows.yml
parameters:
testLogTitle: 'Windows-x86'
# Package .NET Core Windows dependency (VC++ Redistributable)
- template: .azure-pipelines/package-vcredist.yml
parameters:
layoutRoot: ${{ variables.layoutRoot }}
flavor: 'x86'
# Signing steps
- template: .azure-pipelines/signing.yml
parameters:
layoutRoot: ${{ variables.layoutRoot }}
# Create agent package zip
- script: dev.cmd package Release
workingDirectory: src
displayName: Package Release
# Upload agent package zip as build artifact
- task: PublishBuildArtifacts@1
displayName: Publish Artifact (Windows)
inputs:
pathToPublish: _package
artifactName: agent
artifactType: container
################################################################################
- job: build_linux_agent_x64
################################################################################
displayName: Linux Agent (x64)
pool:
vmImage: ubuntu-16.04
steps:
# Steps template for non-windows platform
- template: .vsts.template.nonwindows.yml
parameters:
testLogTitle: 'Linux-x64'
# Create agent package zip
- script: ./dev.sh package Release
workingDirectory: src
displayName: Package Release
# Upload agent package zip as build artifact
- task: PublishBuildArtifacts@1
displayName: Publish Artifact (Linux)
inputs:
pathToPublish: _package
artifactName: agent
artifactType: container
################################################################################
- job: build_linux_agent_arm
################################################################################
displayName: Linux Agent (ARM)
pool:
name: buildDevs
demands: 'Agent.OSArchitecture -equals ARM'
container: dotnetcore_arm
timeoutInMinutes: 75
steps:
# Steps template for non-windows platform
- template: .vsts.template.nonwindows.yml
parameters:
testLogTitle: 'Linux-ARM'
# Create agent package zip
- script: ./dev.sh package Release
workingDirectory: src
displayName: Package Release
# Upload agent package zip as build artifact
- task: PublishBuildArtifacts@1
displayName: Publish Artifact (Linux)
inputs:
pathToPublish: _package
artifactName: agent
artifactType: container
################################################################################
- job: build_rhel6_agent_x64
################################################################################
displayName: RHEL6 Agent (x64)
pool:
vmImage: ubuntu-16.04
container: dotnetcore_centos6
steps:
# Steps template for non-windows platform
- template: .vsts.template.nonwindows.yml
parameters:
testLogTitle: 'RHEL-x64'
# Create agent package zip
- script: ./dev.sh package Release
workingDirectory: src
displayName: Package Release
# Upload agent package zip as build artifact
- task: PublishBuildArtifacts@1
displayName: Publish Artifact (RHEL6 x64)
inputs:
pathToPublish: _package
artifactName: agent
artifactType: container
################################################################################
- job: build_osx_agent
################################################################################
displayName: macOS Agent (x64)
pool:
vmImage: macOS-10.14
steps:
# Steps template for non-windows platform
- template: .vsts.template.nonwindows.yml
parameters:
testLogTitle: 'macOS-x64'
# Create agent package zip
- script: ./dev.sh package Release
workingDirectory: src
displayName: Package Release
# Upload agent package zip as build artifact
- task: PublishBuildArtifacts@1
displayName: Publish Artifact (OSX)
inputs:
pathToPublish: _package
artifactName: agent
artifactType: container
- stage: Release
dependsOn: Build
jobs:
################################################################################
- job: publish_agent_packages
################################################################################
displayName: Publish Agents (Windows/Linux/OSX)
pool:
name: ProductionRMAgents
steps:
# Clean
- checkout: self
clean: true
- script: |
git config user.email "[email protected]"
git config user.name "azure-pipelines-bot"
git checkout -f origin/releases/$(version)
displayName: Checkout release branch
condition: and(ne(variables['version'], ''), eq(variables['Build.SourceBranch'], 'refs/heads/master'))
# Download all agent packages from all previous phases
- task: DownloadBuildArtifacts@0
displayName: Download Agent Packages
inputs:
artifactName: agent
# Upload agent packages to Azure blob storage and refresh Azure CDN
- powershell: |
Write-Host "Preloading Azure modules." # This is for better performance, to avoid module-autoloading.
Import-Module AzureRM, AzureRM.profile, AzureRM.Storage, Azure.Storage, AzureRM.Cdn -ErrorAction Ignore -PassThru
Enable-AzureRmAlias -Scope CurrentUser
$uploadFiles = New-Object System.Collections.ArrayList
$certificateThumbprint = (Get-ItemProperty -Path "$(ServicePrincipalReg)").ServicePrincipalCertThumbprint
$clientId = (Get-ItemProperty -Path "$(ServicePrincipalReg)").ServicePrincipalClientId
Write-Host "##vso[task.setsecret]$certificateThumbprint"
Write-Host "##vso[task.setsecret]$clientId"
Login-AzureRmAccount -ServicePrincipal -CertificateThumbprint $certificateThumbprint -ApplicationId $clientId -TenantId $(TenantId)
Select-AzureRmSubscription -SubscriptionId $(SubscriptionId)
$storage = Get-AzureRmStorageAccount -ResourceGroupName vstsagentpackage -AccountName vstsagentpackage
Get-ChildItem -LiteralPath "$(System.ArtifactsDirectory)/agent" | ForEach-Object {
$executable = (Get-ChildItem "$(System.ArtifactsDirectory)/agent/$_")[0]
$versionDir = $executable.Name.Trim('.zip').Trim('.tar.gz')
$versionDir = $versionDir.SubString($versionDir.LastIndexOf('-') + 1)
Write-Host "##vso[task.setvariable variable=ReleaseAgentVersion;]$versionDir"
Write-Host "Uploading $executable to BlobStorage vstsagentpackage/agent/$versionDir"
Set-AzureStorageBlobContent -Context $storage.Context -Container agent -File "$(System.ArtifactsDirectory)/agent/$_/$executable" -Blob "$versionDir/$executable" -Force
$uploadFiles.Add("/agent/$versionDir/$executable")
}
Write-Host "Purge Azure CDN Cache"
Unpublish-AzureRmCdnEndpointContent -EndpointName vstsagentpackage -ProfileName vstsagentpackage -ResourceGroupName vstsagentpackage -PurgeContent $uploadFiles
Write-Host "Force Refresh Azure CDN Cache"
Publish-AzureRmCdnEndpointContent -EndpointName vstsagentpackage -ProfileName vstsagentpackage -ResourceGroupName vstsagentpackage -LoadContent $uploadFiles
displayName: Upload to Azure Blob
# Create agent release on Github
- powershell: |
Write-Host "Creating github release."
$releaseNotes = [System.IO.File]::ReadAllText("$(Build.SourcesDirectory)\releaseNote.md").Replace("<AGENT_VERSION>","$(ReleaseAgentVersion)")
$releaseData = @{
tag_name = "v$(ReleaseAgentVersion)";
target_commitish = "$(Build.SourceVersion)";
name = "v$(ReleaseAgentVersion)";
body = $releaseNotes;
draft = $false;
prerelease = $true;
}
$releaseParams = @{
Uri = "https://api.github.com/repos/Microsoft/azure-pipelines-agent/releases";
Method = 'POST';
Headers = @{
Authorization = 'Basic ' + [Convert]::ToBase64String([Text.Encoding]::ASCII.GetBytes("vsts:$(GithubToken)"));
}
ContentType = 'application/json';
Body = (ConvertTo-Json $releaseData -Compress)
}
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
$releaseCreated = Invoke-RestMethod @releaseParams
Write-Host $releaseCreated
$releaseId = $releaseCreated.id
$assets = [System.IO.File]::ReadAllText("$(Build.SourcesDirectory)\assets.json").Replace("<AGENT_VERSION>","$(ReleaseAgentVersion)")
$assetsParams = @{
Uri = "https://uploads.github.com/repos/Microsoft/azure-pipelines-agent/releases/$releaseId/assets?name=assets.json"
Method = 'POST';
Headers = @{
Authorization = 'Basic ' + [Convert]::ToBase64String([Text.Encoding]::ASCII.GetBytes("vsts:$(GithubToken)"));
}
ContentType = 'application/octet-stream';
Body = [system.Text.Encoding]::UTF8.GetBytes($assets)
}
Invoke-RestMethod @assetsParams
displayName: Create agent release on Github
- stage: CreatePRs
dependsOn: Release
jobs:
################################################################################
- job: create_ado_prs
################################################################################
displayName: Create PRs in AzureDevOps
pool:
vmImage: ubuntu-18.04
steps:
- checkout: self
- script: git checkout releases/$(version)
condition: eq(variables['Build.SourceBranch'], 'refs/heads/master')
displayName: Checkout release branch
- bash: |
set -x
cd release
npm install
ls
node createAdoPrs.js $(version)
displayName: Create PRs in AzureDevOps and AzureDevOps.ConfigChange
condition: ne(variables['version'], '')
env:
USER: $(User)
PAT: $(AdoPAT)