-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathazure-pipelines.yml
More file actions
254 lines (231 loc) · 7.82 KB
/
azure-pipelines.yml
File metadata and controls
254 lines (231 loc) · 7.82 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
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
trigger:
branches:
include:
- '*'
tags:
include:
- release-*
parameters:
- name: cache_nuget
displayName: Cache NuGet packages
type: boolean
default: true
- name: release_myget
displayName: Release to MyGet
type: string
default: auto
values:
- auto # Only release to MyGet on public releases, otherwise skip
- prerelease # Release to MyGet pre-release feed, regardless of release type
- nightly # Release to MyGet nightly feed, regardless of release type
- skip # Skip releasing to MyGet, regardless of release type
- name: release
displayName: Release
type: string
default: auto
values:
- auto # Only release to NuGet on public releases, otherwise skip
- public # Release to NuGet, regardless of release type
- skip # Skip releasing to NuGet, regardless of release type
- name: sbom
displayName: SBOM
type: string
default: auto
values:
- auto # Only generate SBOM for the develop branch, otherwise skip
- force # Generate SBOM, regardless of branch
- skip # Skip generating SBOM, regardless of branch
variables:
solution: Umbraco.JsonSchema.Extensions.sln
vmImage: 'ubuntu-latest'
buildConfiguration: Release
DOTNET_NOLOGO: true
DOTNET_GENERATE_ASPNET_CERTIFICATE: false
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true
DOTNET_CLI_TELEMETRY_OPTOUT: true
stages:
- stage: Build
variables:
NUGET_PACKAGES: $(Pipeline.Workspace)/.nuget/packages
jobs:
- job: Build
pool:
vmImage: $(vmImage)
steps:
# Checkout source (avoid shallow clone to calculate version height)
- checkout: self
fetchDepth: 0
# Setup build environment
- task: UseDotNet@2
displayName: Use .NET SDK from global.json
inputs:
useGlobalJson: true
# Cache and restore NuGet packages
- task: Cache@2
condition: ${{ parameters.cache_nuget }}
displayName: Cache NuGet packages
inputs:
key: 'nuget | "$(Agent.OS)" | **/packages.lock.json, !**/bin/**, !**/obj/**'
restoreKeys: |
nuget | "$(Agent.OS)"
nuget
path: $(NUGET_PACKAGES)
- script: dotnet restore $(solution) --locked-mode
displayName: Restore NuGet packages
# Build
- script: dotnet build $(solution) --configuration $(buildConfiguration) --no-restore -p:ContinuousIntegrationBuild=true
displayName: Run dotnet build
name: build
# Pack
- script: dotnet pack $(solution) --configuration $(buildConfiguration) --no-build --output $(Build.ArtifactStagingDirectory)/nupkg
displayName: Run dotnet pack
# Publish
- publish: $(Build.ArtifactStagingDirectory)/nupkg
artifact: nupkg
displayName: Publish NuGet packages
- publish: $(Build.SourcesDirectory)
artifact: build_output
displayName: Publish build output
- stage: Test
dependsOn: Build
variables:
NUGET_PACKAGES: $(Pipeline.Workspace)/.nuget/packages
jobs:
- job: UnitTests
displayName: Unit Tests
strategy:
matrix:
Windows:
vmImage: 'windows-latest'
Linux:
vmImage: 'ubuntu-latest'
macOS:
vmImage: 'macos-latest'
pool:
vmImage: $(vmImage)
steps:
# Setup test environment
- task: DownloadPipelineArtifact@2
displayName: Download build output artifact
inputs:
artifact: build_output
path: $(Build.SourcesDirectory)
- task: UseDotNet@2
displayName: Use .NET SDK from global.json
inputs:
useGlobalJson: true
# Cache and restore NuGet packages
- task: Cache@2
condition: ${{ parameters.cache_nuget }}
displayName: Cache NuGet packages
inputs:
key: 'nuget | "$(Agent.OS)" | **/packages.lock.json, !**/bin/**, !**/obj/**'
restoreKeys: |
nuget | "$(Agent.OS)"
nuget
path: $(NUGET_PACKAGES)
- script: dotnet restore $(solution) --locked-mode
displayName: Restore NuGet packages
# Test
- script: dotnet test --solution $(solution) --configuration $(buildConfiguration) --no-build --results-directory $(Build.ArtifactStagingDirectory)/tests --report-trx
displayName: Run dotnet test
# Publish
- task: PublishTestResults@2
displayName: Publish test results
condition: succeededOrFailed()
inputs:
testResultsFormat: VSTest
testResultsFiles: '*.trx'
searchFolder: $(Build.ArtifactStagingDirectory)/tests
testRunTitle: Unit Tests - $(Agent.OS)
configuration: $(buildConfiguration)
- stage: ReleaseMyGet
displayName: Release to MyGet
dependsOn:
- Build
- Test
condition: |
and(
succeeded('Build'),
ne('${{ parameters.release_myget }}', 'skip'),
or(
ne('${{ parameters.release_myget }}', 'auto'),
eq(dependencies.Build.outputs['Build.build.NBGV_PublicRelease'], true)
)
)
jobs:
- job: NuGet
pool:
vmImage: 'windows-latest' # NuGetCommand@2 requires Mono and is no longer supported on Ubuntu 24.04+
steps:
- checkout: none
- download: current
artifact: nupkg
displayName: Download nupkg artifact
- task: NuGetCommand@2
displayName: NuGet push
inputs:
command: push
packagesToPush: '$(Pipeline.Workspace)/nupkg/*.nupkg'
nuGetFeedType: external
${{ if eq(parameters.release_myget, 'nightly') }}:
publishFeedCredentials: 'MyGet - Nightly'
${{ else }}:
publishFeedCredentials: 'MyGet - Pre-releases'
- stage: Release
dependsOn:
- Build
- Test
- ReleaseMyGet
condition: |
and(
succeeded('Build'),
ne('${{ parameters.release }}', 'skip'),
or(
ne('${{ parameters.release }}', 'auto'),
eq(dependencies.Build.outputs['Build.build.NBGV_PublicRelease'], true)
)
)
jobs:
- job: NuGet
pool:
vmImage: 'windows-latest' # NuGetCommand@2 requires Mono and is no longer supported on Ubuntu 24.04+
steps:
- checkout: none
- download: current
artifact: nupkg
displayName: Download nupkg artifact
- task: NuGetCommand@2
displayName: NuGet push
inputs:
command: push
packagesToPush: '$(Pipeline.Workspace)/nupkg/*.nupkg'
nuGetFeedType: external
publishFeedCredentials: 'NuGet'
# Generate SBOM on development branch
- stage: SBOM
dependsOn: Build
condition: |
and(
succeeded(),
ne('${{ parameters.sbom }}', 'skip'),
or(
ne('${{ parameters.sbom }}', 'auto'),
eq(variables['Build.SourceBranch'], 'refs/heads/develop')
)
)
variables:
majorVersion: $[ stageDependencies.Build.Build.outputs['build.NBGV_VersionMajor'] ]
jobs:
- job: GenerateSBOM
displayName: Generate SBOM
pool:
vmImage: $(vmImage)
steps:
- template: generate-sbom.yml
parameters:
productGroup: 'Umbraco'
productName: 'Umbraco.JsonSchema.Extensions'
baseUrl: $(DT_BASE_URL)
apiKey: $(DT_API_KEY)
majorVersion: $(majorVersion)