-
Notifications
You must be signed in to change notification settings - Fork 348
/
azure-pipelines.yml
485 lines (460 loc) · 20.1 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
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
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
trigger:
branches:
include:
- master
- refs/tags/*.*.*
- refs/tags/*.*.*.*
exclude:
- refs/tags/*-ci*
resources:
- repo: self
variables:
${{ if eq(variables['Build.SourceBranch'], 'refs/heads/master') }}:
iscibuild: ${{ true }}
isreleasebuild: ${{ false }}
${{ if startsWith(variables['Build.SourceBranch'], 'refs/tags/') }}:
iscibuild: ${{ false }}
isreleasebuild: ${{ true }}
tag: $[ replace(variables['Build.SourceBranch'], 'refs/tags/', '') ]
${{ if not(startsWith(variables['Build.SourceBranch'], 'refs/tags/')) }}:
tag: $[ format('{0}{1:yyyyMMdd}{2}', variables['CIBUILDVERSIONPREFIX'], pipeline.startTime, counter(format('{0:yyyyMMdd}', pipeline.startTime), 100)) ]
docker_repo: "rnwood/smtp4dev"
docker_registry: "dockerhub-rnwood"
netcoresdk_version: "8.0.201"
stages:
- stage: Init
displayName: Init
jobs:
- job: Init
pool:
vmImage: "ubuntu-22.04"
steps:
- checkout: none
- powershell: Write-Host "$(tag) $(Build.BuildNumber)"
displayName: Display build number
- powershell: Write-Host "##vso[build.updatebuildnumber]$(tag) $(Build.BuildNumber)"
displayName: Update build number
- stage: Build
displayName: Build
condition: succeeded()
jobs:
- job: BuildMatrix
displayName: Build and test -
pool:
vmImage: $(vmImage)
strategy:
matrix:
noruntime:
platformName: noruntime
buildArgs: ""
vmImage: "ubuntu-22.04"
runTests: ${{ false }}
win-x64:
platformName: win-x64
buildArgs: "-r win-x64 --self-contained -p:PublishSingleFile=true"
vmImage: "windows-2022"
runTests: ${{ true }}
linux-x64:
platformName: linux-x64
buildArgs: "-r linux-x64 --self-contained -p:PublishSingleFile=true"
vmImage: "ubuntu-22.04"
runTests: ${{ true }}
# osx-x64:
# platformName: osx-x64
# buildArgs: "-r osx-x64 --self-contained -p:PublishSingleFile=true"
# vmImage: "macOS-11"
# runTests: ${{ true }}
linux-musl-x64:
platformName: linux-musl-x64
buildArgs: "-r linux-musl-x64 --self-contained -p:PublishSingleFile=true"
vmImage: ubuntu-22.04
runTests: ${{ false }}
win-arm64:
platformName: win-arm64
buildArgs: "-r win-arm64 --self-contained -p:PublishSingleFile=true"
vmImage: windows-2022
runTests: ${{ false }}
linux-arm:
platformName: linux-arm
buildArgs: "-r linux-arm --self-contained -p:PublishSingleFile=true"
vmImage: ubuntu-22.04
runTests: ${{ false }}
steps:
- task: UseDotNet@2
displayName: Install .NET Core SDK v$(netcoresdk_version)
inputs:
packageType: sdk
version: $(netcoresdk_version)
- task: DotNetCoreCLI@2
displayName: Build $(platformName)
inputs:
command: build
projects: Rnwood.Smtp4dev/Rnwood.Smtp4dev.csproj
publishWebProjects: false
arguments: '-c Release $(buildArgs) -p:version=$(tag)'
- task: DotNetCoreCLI@2
displayName: Publish $(platformName)
inputs:
command: publish
projects: Rnwood.Smtp4dev/Rnwood.Smtp4dev.csproj
publishWebProjects: false
arguments: '-c Release $(buildArgs) -p:version=$(tag) -o "$(Build.ArtifactStagingDirectory)/$(platformName)"'
- task: ExtractFiles@1
displayName: Extract files for E2E tests
condition: eq(variables['runTests'], true)
inputs:
archiveFilePatterns: '$(Build.ArtifactStagingDirectory)/$(platformName)/Rnwood.Smtp4dev.zip'
destinationFolder: $(Agent.TempDirectory)/e2e
- task: DotNetCoreCLI@2
condition: eq(variables['runTests'], true)
displayName: Run SmtpServer Tests
inputs:
command: test
projects: Rnwood.SmtpServer.Tests
configuration: release
- task: DotNetCoreCLI@2
condition: eq(variables['runTests'], true)
displayName: Run Tests
env:
SMTP4DEV_E2E_WORKINGDIR: $(Agent.TempDirectory)/e2e
SMTP4DEV_E2E_BINARY: $(Agent.TempDirectory)/e2e/Rnwood.Smtp4dev
inputs:
command: test
projects: Rnwood.Smtp4dev.Tests
configuration: release
- powershell: move-item $(Build.ArtifactStagingDirectory)/$(platformName)/Rnwood.Smtp4dev.zip $(Build.ArtifactStagingDirectory)/$(platformName)/Rnwood.Smtp4dev-$(platformName)-$(tag).zip
displayName: Rename artifact
- publish: $(Build.ArtifactStagingDirectory)/$(platformName)
artifact: $(platformName)
- job: BuildGlobalTool
displayName: Build - .NET Global Tool
pool:
vmImage: "windows-2022"
steps:
- task: UseDotNet@2
displayName: Install .NET Core SDK v$(netcoresdk_version)
inputs:
packageType: sdk
version: $(netcoresdk_version)
- task: DotNetCoreCLI@2
displayName: Build .NET Core Global Tool
inputs:
command: custom
custom: pack
arguments: '-c Release -p:PackAsTool=true -p:version=$(tag) -o "$(Build.ArtifactStagingDirectory)/dotnetglobaltool" Rnwood.Smtp4dev/Rnwood.Smtp4dev.csproj'
- publish: $(Build.ArtifactStagingDirectory)/dotnetglobaltool
artifact: dotnetglobaltool
- job: BuildDesktop
displayName: Build - Desktop
pool:
vmImage: "windows-2022"
steps:
- task: UseDotNet@2
displayName: Install .NET Core SDK v$(netcoresdk_version)
inputs:
packageType: sdk
version: $(netcoresdk_version)
- task: DotNetCoreCLI@2
displayName: Build .NET Core - win-x64-desktop
inputs:
command: publish
projects: "Rnwood.Smtp4dev.Desktop/Rnwood.Smtp4dev.Desktop.csproj"
publishWebProjects: false
arguments: '-c Release -r win-x64 -p:version=$(tag) --self-contained -p:PublishSingleFile=true -o "$(Build.ArtifactStagingDirectory)/win-x64-desktop"'
- task: ExtractFiles@1
displayName: Extract files for E2E tests
inputs:
archiveFilePatterns: '$(Build.ArtifactStagingDirectory)/win-x64-desktop/Rnwood.Smtp4dev.Desktop.zip'
destinationFolder: $(Agent.TempDirectory)/e2e
- task: DotNetCoreCLI@2
displayName: Run Tests
env:
SMTP4DEV_E2E_WORKINGDIR: $(Agent.TempDirectory)/e2e
SMTP4DEV_E2E_BINARY: $(Agent.TempDirectory)/e2e/Rnwood.Smtp4dev.Desktop
inputs:
command: test
projects: Rnwood.Smtp4dev.Desktop.Tests
configuration: release
- powershell: move-item $(Build.ArtifactStagingDirectory)/win-x64-desktop/Rnwood.Smtp4dev.Desktop.zip $(Build.ArtifactStagingDirectory)/win-x64-desktop/Rnwood.Smtp4dev.Desktop-win-x64-$(tag).zip
displayName: Rename artifact
- publish: $(Build.ArtifactStagingDirectory)/win-x64-desktop
artifact: win-x64-desktop
# - task: DotNetCoreCLI@2run
# displayName: Build .NET Core - linux-x64-desktop
# inputs:
# command: publish
# projects: 'Rnwood.Smtp4dev.Desktop/Rnwood.Smtp4dev.Desktop.csproj'
# publishWebProjects: false
# arguments: '-c Release -r linux-x64 -p:version=$(tag) --self-contained -p:PublishSingleFile=true -o "$(Build.ArtifactStagingDirectory)/linux-x64-desktop"'
# - powershell: move-item $(Build.ArtifactStagingDirectory)/linux-x64-desktop/Rnwood.Smtp4dev.Desktop.zip $(Build.ArtifactStagingDirectory)/linux-x64-desktop/Rnwood.Smtp4dev.Desktop-linux-x64-$(tag).zip
# displayName: Rename artifact
# - publish: $(Build.ArtifactStagingDirectory)/linux-x64-desktop
# artifact: linux-x64-desktop
- job: DockerBuildLinux
displayName: DockerBuild - Linux
pool:
vmImage: "ubuntu-22.04"
steps:
- task: UseDotNet@2
displayName: Install .NET Core SDK v$(netcoresdk_version)
inputs:
packageType: sdk
version: $(netcoresdk_version)
- task: DotNetCoreCLI@2
displayName: Publish
inputs:
command: publish
projects: Rnwood.Smtp4dev/Rnwood.Smtp4dev.csproj
publishWebProjects: false
zipAfterPublish: false
modifyOutputPath: false
arguments: '-c Release -p:version=$(tag) -o out'
- task: Docker@2
displayName: Build image
inputs:
command: build
dockerfile: "**/Dockerfile.linux"
arguments: "--build-arg version=$(tag) -t $(docker_repo):linux-amd64-$(tag)"
# - task: DotNetCoreCLI@2
# displayName: Run Tests
# env:
# SMTP4DEV_E2E_WORKINGDIR: $(Agent.TempDirectory)
# SMTP4DEV_E2E_USEDEFAULTDBPATH: 1
# SMTP4DEV_E2E_BINARY: docker
# SMTP4DEV_E2E_ARGS: |
# run
# -i
# -p
# 25:25
# -p
# 80:80
# -p
# 110:110
# $(docker_repo):linux-amd64-$(tag)
# --urls=http://*:80
# --smtpport=25
# --imapport=110
- task: Docker@2
displayName: Push image
condition: or(variables['isreleasebuild'], variables['iscibuild'])
inputs:
containerRegistry: $(docker_registry)
repository: $(docker_repo)
command: push
tags: |
linux-amd64-$(tag)
- job: DockerBuildLinuxArm64
displayName: DockerBuild - Linux - ARM64
pool:
vmImage: "ubuntu-22.04"
steps:
- task: UseDotNet@2
displayName: Install .NET Core SDK v$(netcoresdk_version)
inputs:
packageType: sdk
version: $(netcoresdk_version)
- task: DotNetCoreCLI@2
displayName: Publish
inputs:
command: publish
projects: Rnwood.Smtp4dev/Rnwood.Smtp4dev.csproj
publishWebProjects: false
zipAfterPublish: false
modifyOutputPath: false
arguments: '-c Release -p:version=$(tag) -o out'
- task: Docker@2
displayName: Build image
inputs:
command: build
dockerfile: "**/Dockerfile.linux.arm64"
arguments: "--build-arg version=$(tag) -t $(docker_repo):linux-arm64-$(tag)"
- task: Docker@2
displayName: Push image
condition: or(variables['isreleasebuild'], variables['iscibuild'])
inputs:
containerRegistry: $(docker_registry)
repository: $(docker_repo)
command: push
tags: |
linux-arm64-$(tag)
- job: DockerBuildWindows
displayName: DockerBuild - Windows
pool:
vmImage: "windows-2022"
steps:
- task: UseDotNet@2
displayName: Install .NET Core SDK v$(netcoresdk_version)
inputs:
packageType: sdk
version: $(netcoresdk_version)
- task: DotNetCoreCLI@2
displayName: Publish
inputs:
command: publish
projects: Rnwood.Smtp4dev/Rnwood.Smtp4dev.csproj
publishWebProjects: false
zipAfterPublish: false
modifyOutputPath: false
arguments: '-c Release -p:version=$(tag) -r win-x64 --self-contained -o out'
- task: Docker@2
displayName: Build image
inputs:
command: build
dockerfile: "**/Dockerfile.windows"
arguments: "--build-arg version=$(tag) -t $(docker_repo):windows-amd64-$(tag)"
- task: Docker@2
displayName: Push image
condition: or(variables['isreleasebuild'], variables['iscibuild'])
inputs:
containerRegistry: $(docker_registry)
repository: $(docker_repo)
command: push
tags: |
windows-amd64-$(tag)
- job: DockerManifest
displayName: Docker Create Manifest
condition: or(variables['isreleasebuild'], variables['iscibuild'])
dependsOn:
- DockerBuildLinux
- DockerBuildLinuxArm64
- DockerBuildWindows
variables:
DOCKER_CLI_EXPERIMENTAL: enabled
pool:
vmImage: "windows-2022"
steps:
- task: Docker@2
displayName: Login.
inputs:
containerRegistry: $(docker_registry)
repository: $(docker_repo)
command: login
- task: PowerShell@2
displayName: Create cross platform manifest
inputs:
targetType: inline
script: |
docker manifest create $(docker_repo):$(tag) $(docker_repo):windows-amd64-$(tag) $(docker_repo):linux-amd64-$(tag) $(docker_repo):linux-arm64-$(tag)
docker manifest push $(docker_repo):$(tag)
- stage: Release
condition: and(succeeded(), or(variables['isreleasebuild'], variables['iscibuild']))
displayName: Release
jobs:
- job: Release
pool:
vmImage: "ubuntu-22.04"
steps:
- checkout: none
- task: DownloadPipelineArtifact@2
inputs:
path: $(Build.ArtifactStagingDirectory)
- task: NuGetCommand@2
inputs:
command: "push"
packagesToPush: "$(Build.ArtifactStagingDirectory)/dotnetglobaltool/*.nupkg"
nuGetFeedType: "external"
publishFeedCredentials: "nuget_rnwood"
- task: GitHubRelease@1
inputs:
gitHubConnection: github.com_rnwood
repositoryName: rnwood/smtp4dev
title: $(tag)
tag: $(tag)
tagSource: userSpecifiedTag
releaseNotesSource: inline
addChangeLog: true
releaseNotesInline: |
[See full installation instructions and options](https://github.com/rnwood/smtp4dev/wiki/Installation)
File Name | Description
-- | --
[Docker rnwood/smtp4dev:$(tag)](https://hub.docker.com/r/rnwood/smtp4dev/tags?page=&page_size=&ordering=&name=$(tag)) | Docker image (Linux and Windows)
[.NET tool Rnwood.Smtp4dev $(tag)](https://www.nuget.org/packages/Rnwood.Smtp4dev/$(tag)) | .NET tool
[Rnwood.Smtp4dev-win-x64-$(tag).zip](../../releases/download/$(tag)/Rnwood.Smtp4dev-win-x64-$(tag).zip) | Windows x64 binary standalone - Server edition
[Rnwood.Smtp4dev.Desktop-win-x64-$(tag).zip](../../releases/download/$(tag)/Rnwood.Smtp4dev.Desktop-win-x64-$(tag).zip) | Windows x64 binary standalone - Desktop app edition.
[Rnwood.Smtp4dev-win-arm64-$(tag).zip](../../releases/download/$(tag)/Rnwood.Smtp4dev-win-arm64-$(tag).zip) | Windows ARM 62-bit binary standalone
[Rnwood.Smtp4dev-linux-x64-$(tag).zip](../../releases/download/$(tag)/Rnwood.Smtp4dev-linux-x64-$(tag).zip) | Linux x64 (Intel 64 bit) binary standalone
[Rnwood.Smtp4dev-linux-musl-x64-$(tag).zip](../../releases/download/$(tag)/Rnwood.Smtp4dev-linux-musl-x64-$(tag).zip) | Linux MUSL x64 binary standalone for Linux distros using MUSL libc
[Rnwood.Smtp4dev-noruntime-$(tag).zip](../../releases/download/$(tag)/Rnwood.Smtp4dev-noruntime-$(tag).zip) | Architecture independent version. Should run on any platform where the .NET 8.0 (or greater) runtime is installed
${{ if eq(variables['isreleasebuild'], true) }}:
action: edit
isPreRelease: false
changeLogCompareToRelease: lastFullRelease
${{ if not(eq(variables['isreleasebuild'], true)) }}:
action: create
isPreRelease: true
changeLogCompareToRelease: lastNonDraftRelease
assets: $(Build.ArtifactStagingDirectory)/**/*.zip
- job: DockerReleaseTagLinux
displayName: Docker Release Tag - Linux
variables:
DOCKER_CLI_EXPERIMENTAL: enabled
pool:
vmImage: "ubuntu-22.04"
steps:
- checkout: none
- task: Docker@2
displayName: Login.
inputs:
containerRegistry: $(docker_registry)
repository: $(docker_repo)
command: login
- task: PowerShell@2
displayName: Tag release
inputs:
targetType: inline
script: |
if ([bool]::Parse("$(isreleasebuild)")) {
$version = [version] "$(tag)"
$dockertags = "latest v$($version.Major) v$($version.Major).$($version.Minor)"
} else {
$dockertags = "prerelease"
}
write-host "Docker tags: $dockertags"
docker pull $(docker_repo):linux-amd64-$(tag)
($dockertags.Split(" ", [StringSplitOptions]::RemoveEmptyEntries)) | foreach-object {
docker tag $(docker_repo):linux-amd64-$(tag) $(docker_repo):linux-amd64-$_
docker push $(docker_repo):linux-amd64-$_
}
docker pull $(docker_repo):linux-arm64-$(tag)
($dockertags.Split(" ", [StringSplitOptions]::RemoveEmptyEntries)) | foreach-object {
docker tag $(docker_repo):linux-arm64-$(tag) $(docker_repo):linux-arm64-$_
docker push $(docker_repo):linux-arm64-$_
}
- job: DockerRelease
displayName: Docker Release
dependsOn: DockerReleaseTagLinux
variables:
DOCKER_CLI_EXPERIMENTAL: enabled
pool:
vmImage: "windows-2022"
steps:
- checkout: none
- task: Docker@2
displayName: Login
inputs:
containerRegistry: $(docker_registry)
repository: $(docker_repo)
command: login
- task: PowerShell@2
displayName: Tag release
inputs:
targetType: inline
script: |
if ([bool]::Parse("$(isreleasebuild)")) {
$version = [version] "$(tag)"
$dockertags = "latest v$($version.Major) v$($version.Major).$($version.Minor)"
} else {
$dockertags = "prerelease"
}
write-host "Docker tags: $dockertags"
docker pull $(docker_repo):windows-amd64-$(tag)
($dockertags.Split(" ", [StringSplitOptions]::RemoveEmptyEntries)) | foreach-object {
docker tag $(docker_repo):windows-amd64-$(tag) $(docker_repo):windows-amd64-$_
docker push $(docker_repo):windows-amd64-$_
}
docker manifest create $(docker_repo):$(tag) $(docker_repo):windows-amd64-$(tag) $(docker_repo):linux-amd64-$(tag) $(docker_repo):linux-arm64-$(tag)
docker manifest push $(docker_repo):$(tag)
($dockertags.Split(" ", [StringSplitOptions]::RemoveEmptyEntries)) | foreach-object {
docker manifest create $(docker_repo):$_ $(docker_repo):windows-amd64-$_ $(docker_repo):linux-amd64-$_ $(docker_repo):linux-arm64-$_
docker manifest push $(docker_repo):$_
}