/
linux.yml
352 lines (304 loc) · 11.9 KB
/
linux.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
parameters:
buildName: ''
uploadDisplayName: 'Upload'
parentJob: ''
jobs:
- job: build_${{ parameters.buildName }}
displayName: Build ${{ parameters.buildName }}
condition: succeeded()
pool:
name: PowerShell1ES
demands:
- ImageOverride -equals PSMMSUbuntu20.04-Secure
dependsOn: ${{ parameters.parentJob }}
variables:
- name: runCodesignValidationInjection
value: false
- name: build
value: ${{ parameters.buildName }}
- name: NugetSecurityAnalysisWarningLevel
value: none
- group: ESRP
steps:
- checkout: self
clean: true
- checkout: ComplianceRepo
clean: true
- template: SetVersionVariables.yml
parameters:
ReleaseTagVar: $(ReleaseTagVar)
- pwsh: |
# create folder
sudo mkdir /PowerShell
# make the current user the owner
sudo chown $env:USER /PowerShell
displayName: 'Create /PowerShell'
- template: cloneToOfficialPath.yml
- template: insert-nuget-config-azfeed.yml
parameters:
repoRoot: $(PowerShellRoot)
- powershell: |
import-module "$env:POWERSHELLROOT/build.psm1"
Sync-PSTags -AddRemoteIfMissing
displayName: SyncTags
condition: and(succeeded(), ne(variables['SkipBuild'], 'true'))
workingDirectory: $(PowerShellRoot)
- powershell: |
Import-Module "$env:POWERSHELLROOT/build.psm1"
Start-PSBootstrap -Package
displayName: 'Bootstrap'
condition: and(succeeded(), ne(variables['SkipBuild'], 'true'))
workingDirectory: $(PowerShellRoot)
- pwsh: |
try {
Import-Module "$env:POWERSHELLROOT/build.psm1"
Import-Module "$env:POWERSHELLROOT/tools/packaging"
Invoke-AzDevOpsLinuxPackageBuild -ReleaseTag '$(ReleaseTagVar)' -BuildType '$(build)'
} catch {
Get-Error
throw
}
displayName: 'Build'
condition: and(succeeded(), ne(variables['SkipBuild'], 'true'))
workingDirectory: $(PowerShellRoot)
- template: Sbom.yml@ComplianceRepo
parameters:
BuildDropPath: '$(System.ArtifactsDirectory)/pwshLinuxBuild'
Build_Repository_Uri: $(Github_Build_Repository_Uri)
displayName: ${{ parameters.buildName }} SBOM
PackageName: PowerShell Linux
PackageVersion: $(Version)
sourceScanPath: '$(PowerShellRoot)/tools'
- ${{ if eq(variables.build,'rpm') }} :
- template: Sbom.yml@ComplianceRepo
parameters:
BuildDropPath: '$(System.ArtifactsDirectory)/pwshMarinerBuildAmd64'
Build_Repository_Uri: $(Github_Build_Repository_Uri)
displayName: Mariner SBOM
PackageName: PowerShell Linux Framework Dependent
PackageVersion: $(Version)
sourceScanPath: '$(PowerShellRoot)/tools'
- ${{ if eq(variables.build,'deb') }} :
- template: Sbom.yml@ComplianceRepo
parameters:
BuildDropPath: '$(System.ArtifactsDirectory)/pwshLinuxBuildMinSize'
Build_Repository_Uri: $(Github_Build_Repository_Uri)
displayName: MinSize SBOM
PackageName: PowerShell Linux Minimum Size
PackageVersion: $(Version)
sourceScanPath: '$(PowerShellRoot)/tools'
- ${{ if eq(variables.build,'deb') }} :
- template: Sbom.yml@ComplianceRepo
parameters:
BuildDropPath: '$(System.ArtifactsDirectory)/pwshLinuxBuildArm32'
Build_Repository_Uri: $(Github_Build_Repository_Uri)
displayName: Arm32 SBOM
PackageName: PowerShell Linux Arm32
PackageVersion: $(Version)
sourceScanPath: '$(PowerShellRoot)/tools'
- ${{ if eq(variables.build,'deb') }} :
- template: Sbom.yml@ComplianceRepo
parameters:
BuildDropPath: '$(System.ArtifactsDirectory)/pwshLinuxBuildArm64'
Build_Repository_Uri: $(Github_Build_Repository_Uri)
displayName: Arm64 SBOM
PackageName: PowerShell Linux Arm64
PackageVersion: $(Version)
sourceScanPath: '$(PowerShellRoot)/tools'
- powershell: |
try {
Import-Module "$env:POWERSHELLROOT/build.psm1"
Import-Module "$env:POWERSHELLROOT/tools/packaging"
$metadata = Get-Content "$env:POWERSHELLROOT/tools/metadata.json" -Raw | ConvertFrom-Json
# LTSRelease.Package indicates that the release should be packaged as an LTS
$LTS = $metadata.LTSRelease.Package
Write-Verbose -Verbose -Message "LTS is set to: $LTS"
Invoke-AzDevOpsLinuxPackageCreation -ReleaseTag '$(ReleaseTagVar)' -BuildType '$(build)'
if ($LTS) {
Write-Verbose -Verbose "Packaging LTS"
Invoke-AzDevOpsLinuxPackageCreation -LTS -ReleaseTag '$(ReleaseTagVar)' -BuildType '$(build)'
}
} catch {
Get-Error
throw
}
displayName: 'Package'
condition: and(succeeded(), ne(variables['SkipBuild'], 'true'))
workingDirectory: $(PowerShellRoot)
- powershell: |
$linuxPackages = Get-ChildItem "$env:POWERSHELLROOT/powershell*" -Include *.deb,*.rpm,*.tar.gz
$bucket = 'release'
foreach ($linuxPackage in $linuxPackages)
{
$filePath = $linuxPackage.FullName
Write-Verbose "Publishing $filePath to $bucket" -Verbose
Write-Host "##vso[artifact.upload containerfolder=$bucket;artifactname=$bucket]$filePath"
}
displayName: Publish artifacts
condition: and(succeeded(), ne(variables['SkipBuild'], 'true'))
workingDirectory: $(PowerShellRoot)
- template: /tools/releaseBuild/azureDevOps/templates/step/finalize.yml
- job: upload_${{ parameters.buildName }}
displayName: ${{ parameters.uploadDisplayName }} ${{ parameters.buildName }}
dependsOn: build_${{ parameters.buildName }}
condition: succeeded()
pool:
name: PowerShell1ES
demands:
- ImageOverride -equals PSMMS2019-Secure
variables:
- name: buildName
value: ${{ parameters.buildName }}
- group: ESRP
- name: runCodesignValidationInjection
value: false
- name: NugetSecurityAnalysisWarningLevel
value: none
- name: skipComponentGovernanceDetection
value: true
steps:
- checkout: self
clean: true
- checkout: ComplianceRepo
clean: true
- template: SetVersionVariables.yml
parameters:
ReleaseTagVar: $(ReleaseTagVar)
- template: shouldSign.yml
- task: DownloadBuildArtifacts@0
displayName: 'Download Deb Artifacts'
inputs:
downloadType: specific
itemPattern: '**/*.deb'
downloadPath: '$(System.ArtifactsDirectory)\finished'
condition: and(eq(variables['buildName'], 'DEB'), succeeded())
- task: DownloadBuildArtifacts@0
displayName: 'Download tar.gz Artifacts copy'
inputs:
downloadType: specific
itemPattern: '**/*.tar.gz'
downloadPath: '$(System.ArtifactsDirectory)\finished'
- powershell: |
Write-Host 'We handle the min-size package only when uploading for deb build.'
Write-Host '- For deb build, the min-size package is moved to a separate folder "finished\minSize",'
Write-Host ' so that the min-size package can be uploaded to a different Az Blob container.'
Write-Host '- For other builds, the min-size package is removed after being downloaded, so that it'
Write-Host ' does not get accidentally uploaded to the wrong Az Blob container.'
$minSizePkg = '$(System.ArtifactsDirectory)\finished\release\*-gc.tar.gz'
if (Test-Path -Path $minSizePkg)
{
if ('$(buildName)' -eq 'DEB')
{
$minSizeDir = '$(System.ArtifactsDirectory)\finished\minSize'
New-Item -Path $minSizeDir -Type Directory -Force > $null
Move-Item -Path $minSizePkg -Destination $minSizeDir
Write-Host "`nCapture the min-size package moved to the target folder."
Get-ChildItem -Path $minSizeDir
}
else
{
Write-Host '$(buildName): Remove the min-size package.'
Remove-Item -Path $minSizePkg -Force
}
}
else
{
Write-Host 'min-size package not found, so skip this step.'
}
displayName: 'Move minSize package to separate folder'
- task: DownloadBuildArtifacts@0
displayName: 'Download rpm Artifacts copy'
inputs:
downloadType: specific
itemPattern: '**/*.rpm'
downloadPath: '$(System.ArtifactsDirectory)\rpm'
condition: and(eq(variables['buildName'], 'RPM'), succeeded())
- template: EsrpScan.yml@ComplianceRepo
parameters:
scanPath: $(System.ArtifactsDirectory)
pattern: |
**\*.rpm
**\*.deb
**\*.tar.gz
- ${{ if eq(variables['buildName'], 'RPM') }}:
- template: EsrpSign.yml@ComplianceRepo
parameters:
buildOutputPath: $(System.ArtifactsDirectory)\rpm
signOutputPath: $(Build.StagingDirectory)\signedPackages
certificateId: "CP-450779-Pgp"
pattern: |
**\*.rh.*.rpm
useMinimatch: true
shouldSign: $(SHOULD_SIGN)
displayName: Sign RedHat RPM
OutputMode: AlwaysCopy
- ${{ if eq(variables['buildName'], 'RPM') }}:
- template: EsrpSign.yml@ComplianceRepo
parameters:
# Sign in-place, previous task copied the files to this folder
buildOutputPath: $(Build.StagingDirectory)\signedPackages
signOutputPath: $(Build.StagingDirectory)\signedPackages
certificateId: "CP-459159-Pgp"
pattern: |
**\*.cm.*.rpm
**\*.cm?.*.rpm
useMinimatch: true
shouldSign: $(SHOULD_SIGN)
displayName: Sign Mariner RPM
OutputMode: NeverCopy
# requires windows
- ${{ if ne(variables['buildName'], 'RPM') }}:
- task: AzureFileCopy@4
displayName: 'Upload to Azure - DEB and tar.gz'
inputs:
SourcePath: '$(System.ArtifactsDirectory)\finished\release\*'
azureSubscription: '$(AzureFileCopySubscription)'
Destination: AzureBlob
storage: '$(StorageAccount)'
ContainerName: '$(AzureVersion)'
- template: upload-final-results.yml
parameters:
artifactPath: $(System.ArtifactsDirectory)\finished\release
# requires windows
- task: AzureFileCopy@4
displayName: 'Upload to Azure - min-size package for Guest Config'
inputs:
SourcePath: '$(System.ArtifactsDirectory)\finished\minSize\*'
azureSubscription: '$(AzureFileCopySubscription)'
Destination: AzureBlob
storage: '$(StorageAccount)'
ContainerName: '$(AzureVersion)-gc'
condition: and(eq(variables['buildName'], 'DEB'), succeeded())
- template: upload-final-results.yml
parameters:
artifactPath: $(System.ArtifactsDirectory)\finished\minSize
condition: and(eq(variables['buildName'], 'DEB'), succeeded())
# requires windows
- task: AzureFileCopy@4
displayName: 'Upload to Azure - RPM - Unsigned'
inputs:
SourcePath: '$(System.ArtifactsDirectory)\rpm\release\*'
azureSubscription: '$(AzureFileCopySubscription)'
Destination: AzureBlob
storage: '$(StorageAccount)'
ContainerName: '$(AzureVersion)'
condition: and(and(succeeded(), ne(variables['SHOULD_SIGN'], 'true')),eq(variables['buildName'], 'RPM'))
# requires windows
- task: AzureFileCopy@4
displayName: 'Upload to Azure - RPM - Signed'
inputs:
SourcePath: '$(Build.StagingDirectory)\signedPackages\release\*'
azureSubscription: '$(AzureFileCopySubscription)'
Destination: AzureBlob
storage: '$(StorageAccount)'
ContainerName: '$(AzureVersion)'
condition: and(and(succeeded(), eq(variables['SHOULD_SIGN'], 'true')),eq(variables['buildName'], 'RPM'))
- template: upload-final-results.yml
parameters:
artifactPath: $(System.ArtifactsDirectory)\rpm\release
condition: and(and(succeeded(), ne(variables['SHOULD_SIGN'], 'true')),eq(variables['buildName'], 'RPM'))
- template: upload-final-results.yml
parameters:
artifactPath: '$(Build.StagingDirectory)\signedPackages\release'
condition: and(and(succeeded(), eq(variables['SHOULD_SIGN'], 'true')),eq(variables['buildName'], 'RPM'))
- template: /tools/releaseBuild/azureDevOps/templates/step/finalize.yml