-
-
Notifications
You must be signed in to change notification settings - Fork 10
/
azure-pipelines.yml
233 lines (210 loc) · 7.42 KB
/
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
parameters:
- name: timestamper
type: string
displayName: Time Stamper URL
default: 'http://timestamp.acs.microsoft.com'
values:
- 'http://timestamp.acs.microsoft.com'
- 'http://timestamp.sectigo.com'
- 'http://timestamp.digicert.com'
- 'http://aatl-timestamp.globalsign.com/tsa/aohfewat2389535fnasgnlg5m23'
- 'http://timestamp.entrust.net/TSS/RFC3161sha2TS'
- 'http://kstamp.keynectis.com/KSign/'
- 'http://tsa.quovadisglobal.com/TSS/HttpTspServer'
- 'http://kstamp.keynectis.com/KSign/'
- 'http://tss.accv.es:8318/tsa'
- 'http://tsa.izenpe.com'
- 'http://timestamp.sectigo.com/qualified'
- 'http://timestamp.comodoca.com'
- name: packagesigninginterval
type: number
displayName: Package Signing Interval
default: 1
- name: git_commit_ids
type: string
displayName: Build Commit IDs
default: ' '
- name: project_to_build
type: string
displayName: Project(s) to Build
default: ' '
- name: build_sdk
type: boolean
displayName: Force build MSBuild.SDK.SystemWeb
default: false
- name: build_razor_sdk
type: boolean
displayName: Force build MSBuild.SDK.SystemWeb.RazorLibrary
default: false
- name: build_templates
type: boolean
displayName: Force build MSBuild.SDK.SystemWeb.Templates
default: false
trigger:
batch: true
branches:
include:
- main
paths:
exclude:
- docs/*
pr: none
pool:
vmImage: windows-latest
variables:
- group: Github-Packages
- group: 'c3d-devops'
- name: solution
value: 'MSBuild.SDK.SystemWeb.sln'
- name: buildPlatform
value: 'Any CPU'
- name: buildConfiguration
value: 'Release'
- name: buildMachine
value: '$(Agent.MachineName)'
- name: buildUser
value: '$(Build.QueuedBy)'
- name: 'timestamper'
value: ${{ parameters.timestamper }}
steps:
- checkout: self
clean: true
submodules: true
persistCredentials: true
fetchDepth: 0
fetchTags: true
- powershell: 'Write-Host ("##vso[task.setvariable variable=MSBuildEmitSolution;]0")'
displayName: 'Ensure MSBuildEmitSolution is not set'
- task: DownloadSecureFile@1
displayName: 'Download secure file SNK'
name: snk
inputs:
secureFile: '61ad38e7-05ff-4421-aea8-e3241b75c7a1'
- task: NuGetToolInstaller@1
displayName: 'Use NuGet >=6.6.1'
inputs:
versionSpec: '>=6.6.1'
checkLatest: true
# Install the code signing tool
- task: DotNetCoreCLI@2
inputs:
command: custom
custom: tool
arguments: update sign --global --version 0.9.1-beta.23530.1
displayName: Install SignTool tool
- task: NuGetCommand@2
inputs:
command: 'restore'
restoreSolution: '$(solution)'
feedsToUse: 'config'
includeNugetOrg: 'true'
externalFeedCredentials: 'github-czemacleod-packages'
- task: VSBuild@1
inputs:
solution: '$(solution)'
platform: '$(buildPlatform)'
configuration: '$(buildConfiguration)'
clean: true
msbuildArgs: '/p:PackageOutputPath="$(Build.ArtifactStagingDirectory)" /p:BuildUser="$(buildUser)" /p:BuildMachine="$(buildMachine)" /p:AssemblyOriginatorKeyFile="$(snk.secureFilePath)"'
- task: PublishBuildArtifacts@1
inputs:
PathtoPublish: '$(build.artifactstagingdirectory)'
- task: PowerShell@2
displayName: 'Detect packages'
inputs:
targetType: inline
script: |
$dir = $env:BUILD_ARTIFACTSTAGINGDIRECTORY + "\*.nupkg"
Write-Host "Package Directory: $dir"
$packages = Get-ChildItem -Path $dir -Recurse
$ids = $packages | Select-Object -ExpandProperty name
Write-Host "Packages: $ids"
Write-Host "Package Count: $($packages.Count)"
Write-Host ("##vso[task.setvariable variable=package_count;]$($packages.Count)")
# Run the signing command
- task: PowerShell@2
displayName: Sign packages
condition: and(succeeded(), ne(variables['package_count'],0))
inputs:
targetType: inline
script: |
sign code azure-key-vault `
"**/*.nupkg" `
--base-directory "$(Build.ArtifactStagingDirectory)" `
-d "Cynthia Z E MacLeod" `
-u "https://github.com/CZEMacLeod" `
-kvu "https://c3d-devops.vault.azure.net/" `
-kvc "c3d-codesign" `
-v information `
-t "$(timestamper)" `
--azure-key-vault-tenant-id "$(SignTenantId)" `
--azure-key-vault-client-id "$(SignClientId)" `
--azure-key-vault-client-secret '$(SignClientSecret)'
- task: CopyFiles@2
condition: and(succeeded(), ne(variables['package_count'],0))
displayName: Create nuget publish config
inputs:
sourceFolder: '$(Build.SourcesDirectory)\build'
contents: 'nuget.publish.config'
targetFolder: $(Build.ArtifactStagingDirectory)
- task: PowerShell@2
condition: and(succeeded(), ne(variables['package_count'],0))
displayName: Build Nuget Source URL
inputs:
targetType: 'inline'
script: |
$owner = "$env:GITHUB_OWNER"
$source = "https://nuget.pkg.github.com/" + $owner.ToLower() + "/index.json"
Write-Host ("Nuget Source URL = $source")
Write-Host ("##vso[task.setvariable variable=NUGET_SOURCE]$source")
env:
GITHUB_OWNER: $(GITHUB_OWNER)
- script: nuget.exe sources Add -NonInteractive -Name GitHub -Source "%NUGET_SOURCE%" -Username "%GITHUB_USERNAME%" -Password "%GITHUB_TOKEN%" -ConfigFile %NUGET_CONFIG%
condition: and(succeeded(), ne(variables['package_count'],0))
displayName: Add github package source
env:
GITHUB_OWNER: $(GITHUB_OWNER)
GITHUB_USERNAME: $(GITHUB_USERNAME)
GITHUB_TOKEN: $(GITHUB_TOKEN)
NUGET_SOURCE: $(NUGET_SOURCE)
NUGET_CONFIG: $(Build.ArtifactStagingDirectory)\nuget.publish.config
- script: nuget push -Source GitHub -ConfigFile %NUGET_CONFIG% -SkipDuplicate "%PACKAGES_DIR%\*.nupkg"
displayName: Push Nuget Packages to $(GITHUB_PACKAGES)
condition: and(succeeded(), ne(variables['package_count'],0))
env:
PACKAGES_DIR: $(Build.ArtifactStagingDirectory)
NUGET_CONFIG: $(Build.ArtifactStagingDirectory)\nuget.publish.config
- script: nuget.exe sources Add -NonInteractive -Name NuGet -Source "https://api.nuget.org/v3/index.json" -ConfigFile %NUGET_CONFIG%
condition: and(succeeded(), ne(variables['package_count'],0))
displayName: Add nuget.org package source
env:
NUGET_CONFIG: $(Build.ArtifactStagingDirectory)\nuget.publish.config
- script: nuget.exe setapikey %NUGET_API_KEY% -Source "https://api.nuget.org/v3/index.json" -ConfigFile %NUGET_CONFIG%
condition: and(succeeded(), ne(variables['package_count'],0))
displayName: Set nuget.org apikey
env:
NUGET_API_KEY: $(NUGET_API_KEY)
NUGET_CONFIG: $(Build.ArtifactStagingDirectory)\nuget.publish.config
- script: nuget push -Source NuGet -ConfigFile %NUGET_CONFIG% -SkipDuplicate "%PACKAGES_DIR%\*.nupkg"
displayName: Push Nuget Packages to nuget.org
condition: and(succeeded(), ne(variables['package_count'],0))
env:
PACKAGES_DIR: $(Build.ArtifactStagingDirectory)
NUGET_CONFIG: $(Build.ArtifactStagingDirectory)\nuget.publish.config
- powershell: |
Write-Host "Tagging Build: $env:BuildNumber"
$tag = "v" + $env:BuildNumber
git tag $tag
git push origin $tag
displayName: Tag build
env:
BuildNumber: $(Build.BuildNumber)
condition: and(succeeded(), eq(variables['Build.SourceBranch'], 'refs/heads/main'))
- task: GithubRelease@0
displayName: 'Create GitHub Release'
condition: and(succeeded(), ne(variables['package_count'],0))
inputs:
gitHubConnection: github-czemacleod
repositoryName: CZEMacLeod/MSBuild.SDK.SystemWeb
assets: $(Build.ArtifactStagingDirectory)/*.nupkg
addChangeLog: true