Skip to content

Commit f24428a

Browse files
authored
Add automated RPM signing to release build (PowerShell#10013)
1 parent dd7e45f commit f24428a

File tree

3 files changed

+53
-6
lines changed

3 files changed

+53
-6
lines changed

tools/releaseBuild/azureDevOps/releaseBuild.yml

+1
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ jobs:
2727
- template: templates/linux.yml
2828
parameters:
2929
buildName: rpm
30+
uploadDisplayName: Upload and Sign
3031

3132
- template: templates/linux.yml
3233
parameters:

tools/releaseBuild/azureDevOps/templates/linux.yml

+44-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
parameters:
22
buildName: ''
3+
uploadDisplayName: 'Upload'
34

45
jobs:
56
- job: build_${{ parameters.buildName }}
@@ -42,7 +43,7 @@ jobs:
4243
condition: and(succeeded(), ne(variables['SkipBuild'], 'true'))
4344
4445
- job: upload_${{ parameters.buildName }}
45-
displayName: Upload ${{ parameters.buildName }}
46+
displayName: ${{ parameters.uploadDisplayName }} ${{ parameters.buildName }}
4647
dependsOn: build_${{ parameters.buildName }}
4748
condition: succeeded()
4849
pool: Package ES CodeHub Lab E
@@ -80,6 +81,29 @@ jobs:
8081
- task: securedevelopmentteam.vss-secure-development-tools.build-task-antimalware.AntiMalware@3
8182
displayName: 'Run Defender Scan'
8283

84+
- powershell: |
85+
$authenticodefiles = @()
86+
Get-ChildItem -Path '$(System.ArtifactsDirectory)\rpm\*.rpm' -recurse | ForEach-Object { $authenticodefiles += $_.FullName}
87+
tools/releaseBuild/generatePackgeSigning.ps1 -LinuxFiles $authenticodeFiles -path "$(System.ArtifactsDirectory)\package.xml"
88+
displayName: 'Generate RPM Signing Xml'
89+
condition: and(and(succeeded(), eq(variables['Build.Reason'], 'Manual')),eq(variables['buildName'], 'RPM'))
90+
91+
- powershell: |
92+
Get-Content "$(System.ArtifactsDirectory)\package.xml"
93+
displayName: 'Capture RPM signing xml'
94+
condition: and(and(succeeded(), eq(variables['Build.Reason'], 'Manual')),eq(variables['buildName'], 'RPM'))
95+
96+
- task: PkgESCodeSign@10
97+
displayName: 'CodeSign RPM $(System.ArtifactsDirectory)\package.xml'
98+
env:
99+
SYSTEM_ACCESSTOKEN: $(System.AccessToken)
100+
inputs:
101+
signConfigXml: '$(System.ArtifactsDirectory)\package.xml'
102+
outPathRoot: '$(Build.StagingDirectory)\signedPackages'
103+
binVersion: $(SigingVersion)
104+
binVersionOverride: $(SigningVersionOverride)
105+
condition: and(and(succeeded(), eq(variables['Build.Reason'], 'Manual')),eq(variables['buildName'], 'RPM'))
106+
83107
- task: AzureFileCopy@1
84108
displayName: 'Upload to Azure - DEB and tar.gz'
85109
inputs:
@@ -94,18 +118,34 @@ jobs:
94118
artifactPath: $(System.ArtifactsDirectory)\finished\release
95119

96120
- task: AzureFileCopy@1
97-
displayName: 'Upload to Azure - RPM'
121+
displayName: 'Upload to Azure - RPM - Unsigned'
98122
inputs:
99123
SourcePath: '$(System.ArtifactsDirectory)\rpm\release'
100124
azureSubscription: '$(AzureFileCopySubscription)'
101125
Destination: AzureBlob
102126
storage: '$(StorageAccount)'
103-
ContainerName: '$(AzureVersion)-unsigned'
104-
condition: and(eq(variables['buildName'], 'RPM'),succeeded())
127+
ContainerName: '$(AzureVersion)'
128+
condition: and(and(succeeded(), ne(variables['Build.Reason'], 'Manual')),eq(variables['buildName'], 'RPM'))
129+
130+
- task: AzureFileCopy@1
131+
displayName: 'Upload to Azure - RPM - Signed'
132+
inputs:
133+
SourcePath: '$(Build.StagingDirectory)\signedPackages'
134+
azureSubscription: '$(AzureFileCopySubscription)'
135+
Destination: AzureBlob
136+
storage: '$(StorageAccount)'
137+
ContainerName: '$(AzureVersion)'
138+
condition: and(and(succeeded(), eq(variables['Build.Reason'], 'Manual')),eq(variables['buildName'], 'RPM'))
105139

106140
- template: upload-final-results.yml
107141
parameters:
108142
artifactPath: $(System.ArtifactsDirectory)\rpm\release
143+
condition: and(and(succeeded(), ne(variables['Build.Reason'], 'Manual')),eq(variables['buildName'], 'RPM'))
144+
145+
- template: upload-final-results.yml
146+
parameters:
147+
artifactPath: '$(Build.StagingDirectory)\signedPackages'
148+
condition: and(and(succeeded(), eq(variables['Build.Reason'], 'Manual')),eq(variables['buildName'], 'RPM'))
109149

110150
- task: ms.vss-governance-buildtask.governance-build-task-component-detection.ComponentGovernanceComponentDetection@0
111151
displayName: 'Component Detection'

tools/releaseBuild/generatePackgeSigning.ps1

+8-2
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,15 @@ param(
66
[string[]] $AuthenticodeDualFiles,
77
[string[]] $AuthenticodeFiles,
88
[string[]] $NuPkgFiles,
9-
[string[]] $MacDeveloperFiles
9+
[string[]] $MacDeveloperFiles,
10+
[string[]] $LinuxFiles
1011
)
1112

1213
if ((!$AuthenticodeDualFiles -or $AuthenticodeDualFiles.Count -eq 0) -and
1314
(!$AuthenticodeFiles -or $AuthenticodeFiles.Count -eq 0) -and
1415
(!$NuPkgFiles -or $NuPkgFiles.Count -eq 0) -and
15-
(!$MacDeveloperFiles -or $MacDeveloperFiles.Count -eq 0))
16+
(!$MacDeveloperFiles -or $MacDeveloperFiles.Count -eq 0) -and
17+
(!$LinuxFiles -or $LinuxFiles.Count -eq 0))
1618
{
1719
throw "At least one file must be specified"
1820
}
@@ -83,6 +85,10 @@ foreach ($file in $MacDeveloperFiles) {
8385
New-FileElement -File $file -SignType 'MacDeveloper' -XmlDoc $signingXml -Job $job
8486
}
8587

88+
foreach ($file in $LinuxFiles) {
89+
New-FileElement -File $file -SignType 'LinuxPack' -XmlDoc $signingXml -Job $job
90+
}
91+
8692
$signingXml.Save($path)
8793
$updateScriptPath = Join-Path -Path $PSScriptRoot -ChildPath 'updateSigning.ps1'
8894
& $updateScriptPath -SigningXmlPath $path

0 commit comments

Comments
 (0)