This repository was archived by the owner on May 22, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathazure-pipelines.yml
163 lines (156 loc) · 5.78 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
# Azure Pipelines Template for NuGet Packages
# Copyright © Solid Token (https://www.solidtoken.nl)
variables:
- name: ProjectName
value: 'SpecFlow.DependencyInjection'
- name: TestProjectName
value: 'SpecFlow.DependencyInjection.Tests'
- name: NuGetPackageName
value: 'SolidToken.SpecFlow.DependencyInjection'
- name: NuGetDescription
value: 'SpecFlow plugin that enables to use Microsoft.Extensions.DependencyInjection for resolving test dependencies.'
- name: BuildConfiguration
value: 'Release'
- name: GitHubConnection
value: 'Solid Token GitHub'
- name: NuGetConnection
value: 'Solid Token NuGet'
- group: CodeSigning
trigger:
- main
- refs/tags/v*
pool:
# Prefer `ubuntu-latest`, but `NuGetKeyVaultSignTool` won't work anymore on Linux (because of dotnet issue https://github.com/dotnet/runtime/issues/48794)
# Also make sure that the proper / or \ is used (according to OS) in the 'Sign' task below
vmImage: 'windows-latest'
stages:
- stage: CI
jobs:
- job: Build
steps:
- task: UseDotNet@2
displayName: '.NET SDK 6.0 (until November 8, 2024)'
inputs:
version: 6.0.x
- task: gitversion/setup@0
displayName: 'Prepare'
inputs:
versionSpec: '5.11.1'
- task: gitversion/execute@0
name: 'Version'
- task: DotNetCoreCLI@2
displayName: 'Build'
inputs:
command: 'build'
projects: '$(ProjectName)'
arguments: '--configuration $(BuildConfiguration)'
- task: DotNetCoreCLI@2
displayName: 'Test'
inputs:
command: 'test'
projects: '$(TestProjectName)'
arguments: '--configuration $(BuildConfiguration) --collect "XPlat Code Coverage"'
- task: DotNetCoreCLI@2
displayName: 'Pack'
inputs:
command: 'pack'
packagesToPack: '$(ProjectName)'
configuration: '$(BuildConfiguration)'
nobuild: true
includesymbols: true
- task: PublishPipelineArtifact@1
displayName: 'Publish'
inputs:
targetPath: '$(Build.ArtifactStagingDirectory)'
artifactName: '$(ProjectName)'
- task: PublishCodeCoverageResults@1
displayName: 'Report'
inputs:
codeCoverageTool: 'Cobertura'
summaryFileLocation: '$(Agent.TempDirectory)/*/coverage.cobertura.xml'
- stage: CD
condition: and(succeeded(), or(eq(variables['Build.SourceBranch'], 'refs/heads/main'), startsWith(variables['Build.SourceBranch'], 'refs/tags/v')))
jobs:
- job: Release
variables:
SemVer: $[stageDependencies.CI.Build.outputs['Version.GitVersion.SemVer']]
FullSemVer: $[stageDependencies.CI.Build.outputs['Version.GitVersion.FullSemVer']]
NuGetVersion: $[stageDependencies.CI.Build.outputs['Version.GitVersion.NuGetVersion']]
InformationalVersion: $[stageDependencies.CI.Build.outputs['Version.GitVersion.InformationalVersion']]
IsPreRelease: $[contains(variables.SemVer, '-')]
steps:
- task: DownloadPipelineArtifact@2
displayName: 'Download'
inputs:
artifactName: '$(ProjectName)'
- task: DotNetCoreCLI@2
displayName: 'Prepare'
inputs:
command: 'custom'
custom: 'tool'
arguments: 'install --tool-path . NuGetKeyVaultSignTool'
- task: PowerShell@2
displayName: 'Sign'
inputs:
targetType: 'inline'
script: |
.\NuGetKeyVaultSignTool sign $(Pipeline.Workspace)\*.nupkg `
--file-digest "sha256" `
--timestamp-rfc3161 "http://timestamp.sectigo.com" `
--timestamp-digest "sha256" `
--azure-key-vault-url "$(azure-key-vault-url)" `
--azure-key-vault-tenant-id "$(azure-key-vault-tenant-id)" `
--azure-key-vault-client-id "$(azure-key-vault-client-id)" `
--azure-key-vault-client-secret "$(azure-key-vault-client-secret)" `
--azure-key-vault-certificate "$(azure-key-vault-certificate)"
- task: GitHubRelease@1
condition: eq(variables['Build.SourceBranch'], 'refs/heads/main')
displayName: 'Draft'
inputs:
gitHubConnection: '$(GitHubConnection)'
repositoryName: '$(Build.Repository.Name)'
action: 'edit'
target: '$(Build.SourceVersion)'
tagSource: 'userSpecifiedTag'
tag: 'v$(SemVer)'
title: 'v$(FullSemVer)'
assets: '$(Pipeline.Workspace)/*'
releaseNotesSource: 'inline'
releaseNotesInline: |
$(NuGetDescription)
*(Publish release to push to NuGet)*
`$(InformationalVersion)`
changeLogCompareToRelease: 'lastFullRelease'
changeLogType: 'commitBased'
isDraft: true
isPreRelease: $(IsPreRelease) # ignore vscode warning
- task: NuGetCommand@2
condition: startsWith(variables['Build.SourceBranch'], 'refs/tags/v')
displayName: 'Push'
inputs:
command: 'push'
packagesToPush: '$(Pipeline.Workspace)/*.nupkg'
nuGetFeedType: 'external'
publishFeedCredentials: '$(NuGetConnection)'
includeSymbols: true
- task: GitHubRelease@1
condition: startsWith(variables['Build.SourceBranch'], 'refs/tags/v')
displayName: 'Release'
inputs:
gitHubConnection: '$(GitHubConnection)'
repositoryName: '$(Build.Repository.Name)'
action: 'edit'
target: '$(Build.SourceVersion)'
tagSource: 'userSpecifiedTag'
tag: 'v$(SemVer)'
title: 'v$(FullSemVer)'
assets: '$(Pipeline.Workspace)/*'
releaseNotesSource: 'inline'
releaseNotesInline: |
$(NuGetDescription)
https://www.nuget.org/packages/$(NuGetPackageName)/$(SemVer)
`$(InformationalVersion)`
changeLogCompareToRelease: 'lastFullRelease'
changeLogType: 'commitBased'
isDraft: false
isPreRelease: $(IsPreRelease) # ignore vscode warning