-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathazure-pipelines.yml
More file actions
227 lines (198 loc) · 7.59 KB
/
azure-pipelines.yml
File metadata and controls
227 lines (198 loc) · 7.59 KB
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
trigger:
- main
- refs/tags/v*
stages:
- stage: Build
displayName: Build
jobs:
- job: windows
pool:
vmImage: windows-2022
variables:
- group: signing
steps:
- checkout: self
fetchDepth: "0"
# Can be removed once the runner images are updated
- task: UseDotNet@2
inputs:
version: 10.x
- task: DotNetCoreCLI@2
displayName: Install AzureSignTool
condition: and(succeeded(), ne(variables['Build.Reason'], 'PullRequest'))
inputs:
command: 'custom'
custom: 'tool'
arguments: 'install --global azuresigntool'
workingDirectory: '..'
- task: AzureCLI@2
condition: and(succeeded(), ne(variables['Build.Reason'], 'PullRequest'))
displayName: Set signing credentials
inputs:
azureSubscription: 1cefafa0-f4dd-4fbf-bd2e-6abbfe4b0a9b
addSpnToEnvironment: true
scriptType: pscore
scriptLocation: inlineScript
inlineScript: |
Write-Host "##vso[task.setvariable variable=ARM_CLIENT_ID]$env:servicePrincipalId"
Write-Host "##vso[task.setvariable variable=ARM_ID_TOKEN]$env:idToken"
Write-Host "##vso[task.setvariable variable=ARM_TENANT_ID]$env:tenantId"
- task: PowerShell@2
condition: and(succeeded(), ne(variables['Build.Reason'], 'PullRequest'))
displayName: Login to Azure
inputs:
targetType: inline
pwsh: true
script: |
az login --service-principal -u $env:ARM_CLIENT_ID --tenant $env:ARM_TENANT_ID --allow-no-subscriptions --federated-token $env:ARM_ID_TOKEN
# Fetch the access token for Azure Key Vault as the federated ID token expires after 10 minutes.
# See https://github.com/Azure/azure-cli/issues/28708#issuecomment-2047256166
az account get-access-token --scope https://vault.azure.net/.default --output none
- task: DotNetCoreCLI@2
displayName: dotnet restore
inputs:
command: 'restore'
projects: '**/*.csproj'
- task: DotNetCoreCLI@2
displayName: dotnet build
inputs:
command: build
projects: '**/*.csproj'
arguments: '--configuration Release --no-restore'
- task: PowerShell@2
displayName: Set build number from MinVer
inputs:
targetType: inline
pwsh: true
script: |
$version = dotnet msbuild src/SncVerify/SncVerify.csproj -t:MinVer -getProperty:MinVerVersion -nologo
Write-Host "##vso[build.updatebuildnumber]$version"
- task: DotNetCoreCLI@2
displayName: dotnet test
inputs:
command: test
projects: '**/test/**/*.csproj'
arguments: '--configuration Release --no-restore --no-build'
- task: DotNetCoreCLI@2
displayName: dotnet publish (win-x64)
inputs:
command: 'publish'
publishWebProjects: false
projects: 'src/SncVerify/SncVerify.csproj'
arguments: '--configuration Release --runtime win-x64 --output $(Build.ArtifactStagingDirectory)/win-x64'
zipAfterPublish: false
modifyOutputPath: false
- task: PowerShell@2
displayName: Sign executable
condition: and(succeeded(), ne(variables['Build.Reason'], 'PullRequest'))
inputs:
targetType: inline
pwsh: true
script: |
$token = az account get-access-token --scope https://vault.azure.net/.default --query accessToken -o tsv
AzureSignTool sign -kvu "$(azureVault)" -kva $token -kvc "$(certName)" -tr http://rfc3161timestamp.globalsign.com/advanced -v $(Build.ArtifactStagingDirectory)/win-x64/SncVerify.exe
- task: ArchiveFiles@2
displayName: Pack (win-x64)
inputs:
rootFolderOrFile: '$(Build.ArtifactStagingDirectory)/win-x64'
includeRootFolder: false
archiveType: 'zip'
archiveFile: '$(Build.ArtifactStagingDirectory)/release/sncverify_$(Build.BuildNumber)_windows_amd64.zip'
- task: PublishPipelineArtifact@1
displayName: Upload release artifact
inputs:
targetPath: '$(Build.ArtifactStagingDirectory)/release'
artifactName: 'release-windows'
- job: linux
pool:
vmImage: ubuntu-22.04
steps:
- checkout: self
fetchDepth: "0"
- task: UseDotNet@2
inputs:
version: 10.x
- task: DotNetCoreCLI@2
displayName: dotnet restore
inputs:
command: 'restore'
projects: '**/*.csproj'
restoreArguments: '--runtime linux-x64'
- task: DotNetCoreCLI@2
displayName: dotnet build
inputs:
command: build
projects: '**/*.csproj'
arguments: '--configuration Release --runtime linux-x64 --no-restore'
- task: PowerShell@2
displayName: Set build number from MinVer
inputs:
targetType: inline
pwsh: true
script: |
$version = dotnet msbuild src/SncVerify/SncVerify.csproj -t:MinVer -getProperty:MinVerVersion -nologo
Write-Host "##vso[build.updatebuildnumber]$version"
- task: DotNetCoreCLI@2
displayName: dotnet test
inputs:
command: test
projects: '**/test/**/*.csproj'
arguments: '--configuration Release --runtime linux-x64 --no-restore --no-build'
- task: DotNetCoreCLI@2
displayName: dotnet publish (linux-x64)
inputs:
command: 'publish'
publishWebProjects: false
projects: 'src/SncVerify/SncVerify.csproj'
arguments: '--configuration Release --runtime linux-x64 --no-build --output $(Build.ArtifactStagingDirectory)/linux-x64'
zipAfterPublish: false
modifyOutputPath: false
- task: ArchiveFiles@2
displayName: Pack (linux-x64)
inputs:
rootFolderOrFile: '$(Build.ArtifactStagingDirectory)/linux-x64'
includeRootFolder: false
archiveType: 'tar'
tarCompression: 'gz'
archiveFile: '$(Build.ArtifactStagingDirectory)/release/sncverify_$(Build.BuildNumber)_linux_amd64.tar.gz'
- task: PublishPipelineArtifact@1
displayName: Upload release artifact
inputs:
targetPath: '$(Build.ArtifactStagingDirectory)/release'
artifactName: 'release-linux'
- stage: Release
displayName: Release
dependsOn: Build
condition: and(succeeded(), startsWith(variables['Build.SourceBranch'], 'refs/tags/v'))
jobs:
- deployment: UploadToReleases
displayName: Upload to releases.dbosoft.eu
environment: sncverify-release
pool:
vmImage: windows-2022
strategy:
runOnce:
deploy:
steps:
- download: current
artifact: release-windows
- download: current
artifact: release-linux
- task: AzureFileCopy@6
displayName: Upload Windows release
inputs:
SourcePath: '$(Pipeline.Workspace)/release-windows/*.zip'
azureSubscription: '4475ee01-aa54-4e20-b52c-9c1fea831a3f'
Destination: 'AzureBlob'
storage: 'dbosoftreleaseseuwest'
ContainerName: 'staging'
AdditionalArgumentsForBlobCopy: '--recursive --metadata="product=sncverify;version=$(Build.BuildNumber);os=windows;arch=amd64"'
- task: AzureFileCopy@6
displayName: Upload Linux release
inputs:
SourcePath: '$(Pipeline.Workspace)/release-linux/*.tar.gz'
azureSubscription: '4475ee01-aa54-4e20-b52c-9c1fea831a3f'
Destination: 'AzureBlob'
storage: 'dbosoftreleaseseuwest'
ContainerName: 'staging'
AdditionalArgumentsForBlobCopy: '--recursive --metadata="product=sncverify;version=$(Build.BuildNumber);os=linux;arch=amd64"'