forked from PowerShell/Compliance
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathEsrpSign.yml
126 lines (114 loc) · 5.17 KB
/
EsrpSign.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
parameters:
- name: "buildOutputPath"
default: "$(Build.ArtifactStagingDirectory)\\build"
- name: "signOutputPath"
default: "$(Build.ArtifactStagingDirectory)\\signed"
- name: "certificateId"
default: "CP-230012"
- name: "pattern"
default: "*.dll,*.exe"
- name: "useMinimatch"
default: "false"
- name: "signingService"
default: "pwshSigning"
- name: "shouldSign"
default: "auto"
- name: "alwaysCopy"
default: "False"
steps:
- task: UseDotNet@2
displayName: 'Install .NET Core sdk 2.x for ESRP'
inputs:
version: 2.x
- pwsh: |
Write-Verbose -Verbose "buildOutputPath = '${{ parameters.buildOutputPath }}'"
Write-Verbose -Verbose "signOutputPath = '${{ parameters.signOutputPath }}'"
Write-Verbose -Verbose "certificateId = '${{ parameters.certificateId }}'"
Write-Verbose -Verbose "pattern = '${{ parameters.pattern }}'"
Write-Verbose -Verbose "useMinimatch = '${{ parameters.useMinimatch }}'"
Write-Verbose -Verbose "signingService = '${{ parameters.signingService }}'"
Write-Verbose -Verbose "shouldSign = '${{ parameters.shouldSign }}'"
Write-Verbose -Verbose "alwaysCopy = '${{ parameters.alwaysCopy }}'"
displayName: Log parameters
- pwsh: |
if ('${{ parameters.shouldSign }}' -eq 'auto') {
Write-Verbose -Verbose -Message 'calculating shouldsign'
$shouldSign = $env:BUILD_REASON -eq 'Manual' -and $env:SKIPSIGNING -ne 'True' -and $env:SIGNINGSERVER -ne ''
}
elseif ('${{ parameters.shouldSign }}' -eq 'false') {
$shouldSign = $false
}
else {
$shouldSign = $true
}
$vstsCommandString = "vso[task.setvariable variable=ESRP_TEMPLATE_SHOULD_SIGN]$shouldSign"
Write-Verbose -Message ("sending " + $vstsCommandString) -Verbose
Write-Host "##$vstsCommandString"
displayName: Set ESRP_TEMPLATE_SHOULD_SIGN
- ${{ if eq(parameters.certificateId , 'CP-230012') }}:
- template: template-compliance/authenticode-sign.yml
parameters:
buildOutputPath: ${{ parameters.buildOutputPath }}
signOutputPath: ${{ parameters.signOutputPath }}
pattern: ${{ parameters.pattern }}
certificateId: ${{ parameters.certificateId }}
- ${{ if eq(parameters.certificateId , 'CP-231522') }}:
- template: template-compliance/authenticode-sign.yml
parameters:
buildOutputPath: ${{ parameters.buildOutputPath }}
signOutputPath: ${{ parameters.signOutputPath }}
pattern: ${{ parameters.pattern }}
certificateId: ${{ parameters.certificateId }}
- ${{ if eq(parameters.certificateId, 'CP-401405') }}:
- template: template-compliance/nuget-sign.yml
parameters:
buildOutputPath: ${{ parameters.buildOutputPath }}
signOutputPath: ${{ parameters.signOutputPath }}
pattern: ${{ parameters.pattern }}
certificateId: ${{ parameters.certificateId }}
- ${{ if or(eq(parameters.certificateId, 'CP-450779-Pgp'),eq(parameters.certificateId, 'CP-450778-Pgp')) }}:
- template: template-compliance/pgp-sign.yml
parameters:
signOutputPath: ${{ parameters.signOutputPath }}
pattern: ${{ parameters.pattern }}
certificateId: ${{ parameters.certificateId }}
- ${{ if eq(parameters.certificateId, 'CP-401337-Apple') }}:
- template: template-compliance/macOS-sign.yml
parameters:
signOutputPath: ${{ parameters.signOutputPath }}
pattern: ${{ parameters.pattern }}
certificateId: ${{ parameters.certificateId }}
- pwsh: |
Write-Verbose -Verbose "EsrpJson = '${env:EsrpJson}'"
displayName: Log Json
- pwsh: |
Write-Verbose "BUILD_OUTPUT_PATH- ${{ parameters.buildOutputPath }}" -Verbose
Write-Verbose "SIGNED_OUTPUT_PATH- ${{ parameters.signOutputPath }}" -Verbose
if(!(Test-Path '${{ parameters.signOutputPath }}'))
{
Write-Verbose "Creating SIGNED_OUTPUT_PATH- ${{ parameters.signOutputPath }}" -Verbose
$null = New-Item -Path '${{ parameters.signOutputPath }}' -ItemType Directory -force
}
Copy-Item -Path ${{ parameters.buildOutputPath }}\* -Dest ${{ parameters.signOutputPath }}\ -Recurse -Force -Verbose
displayName: Copy unsigned files to signed output directory
condition: and(succeeded(), or(eq(variables['ESRP_TEMPLATE_SHOULD_SIGN'], 'True'),ne('${{ parameters.alwaysCopy }}', 'False')))
timeoutInMinutes: 10
- task: SFP.build-tasks.custom-build-task-1.EsrpCodeSigning@1
displayName: Sign files
inputs:
ConnectedServiceName: ${{ parameters.signingService }}
FolderPath: '${{ parameters.signOutputPath }}'
signConfigType: inlineSignParams
inlineOperation: $(EsrpJson)
Pattern: ${{ parameters.pattern }}
UseMinimatch: ${{ parameters.useMinimatch }}
condition: and(succeeded(), eq(variables['ESRP_TEMPLATE_SHOULD_SIGN'], 'True'))
timeoutInMinutes: 30
- pwsh: |
$file = Get-ChildItem -Path "${{ parameters.signOutputPath }}\codesignsummary-*.md" -File
$fileName = $file.Name
Move-Item -Path "${{ parameters.signOutputPath }}\$fileName" -Dest "$(Agent.TempDirectory)\$fileName"
Write-Host "##vso[artifact.upload containerfolder=signingReport;artifactname=signingReport]$(Agent.TempDirectory)\$fileName"
displayName: Upload codesign summary
condition: and(succeeded(), eq(variables['ESRP_TEMPLATE_SHOULD_SIGN'], 'True'))
timeoutInMinutes: 10