forked from umbraco/Umbraco.Deploy.Contrib
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathazure-pipelines.yml
181 lines (164 loc) · 5.77 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
trigger:
branches:
include:
- 'v2/*'
- 'v3/*'
- 'v4/*'
tags:
include:
- release-2.*
- release-3.*
- release-4.*
pr:
branches:
include:
- 'v2/*'
- 'v3/*'
- 'v4/*'
parameters:
- name: cache_nuget
displayName: Cache NuGet packages
type: boolean
default: false # As long as we're overwriting versions on MyGet, we can't cache NuGet packages by default
- name: release_myget
displayName: Release to pre-release/nightly MyGet feed
type: boolean
default: false
- name: release_myget_nightly
displayName: Release to nightly MyGet feed (instead of pre-release)
type: boolean
default: false
- name: release_nuget
displayName: Release to public NuGet feed
type: boolean
default: false
variables:
solution: Umbraco.Deploy.Contrib.sln
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: 'windows-latest' # Required for .NET Framework projects
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
- task: PublishPipelineArtifact@1
displayName: Publish NuGet packages
inputs:
targetPath: $(Build.ArtifactStagingDirectory)/nupkg
artifactName: nupkg
- task: PublishPipelineArtifact@1
displayName: Publish build output
inputs:
targetPath: $(Build.SourcesDirectory)
artifactName: build_output
- stage: Test
dependsOn: Build
jobs:
- job: UnitTests
displayName: Unit Tests
pool:
vmImage: 'windows-latest'
steps:
# Setup test environment
- task: DownloadPipelineArtifact@2
displayName: Download build artifacts
inputs:
artifact: build_output
path: $(Build.SourcesDirectory)
- task: UseDotNet@2
displayName: Use .NET SDK from global.json
inputs:
useGlobalJson: true
# Test
- script: dotnet test $(solution) --configuration $(buildConfiguration) --no-build --logger trx --results-directory $(Build.ArtifactStagingDirectory)/tests
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
configuration: $(buildConfiguration)
- stage: ReleaseMyGet
displayName: MyGet release
dependsOn: Test
condition: and(succeeded(), or(eq(dependencies.Build.outputs['Build.build.NBGV_PublicRelease'], 'True'), ${{ parameters.release_myget }}))
jobs:
- job:
displayName: Release to pre-release/nightly MyGet feed
steps:
- checkout: none
- task: DownloadPipelineArtifact@2
displayName: Download nupkg
inputs:
artifact: nupkg
path: $(Build.ArtifactStagingDirectory)/nupkg
- task: NuGetCommand@2
displayName: NuGet push
inputs:
command: 'push'
packagesToPush: $(Build.ArtifactStagingDirectory)/nupkg/*.nupkg
nuGetFeedType: 'external'
${{ if eq(parameters.release_myget_nightly, true) }}:
publishFeedCredentials: 'MyGet - Nightly'
${{ else }}:
publishFeedCredentials: 'MyGet - Pre-releases'
- stage: ReleaseNuGet
displayName: NuGet release
dependsOn: ReleaseMyGet
condition: and(succeeded(), or(eq(dependencies.Build.outputs['Build.build.NBGV_PublicRelease'], 'True'), ${{ parameters.release_nuget }}))
jobs:
- job:
displayName: Release to public NuGet feed
steps:
- checkout: none
- task: DownloadPipelineArtifact@2
displayName: Download nupkg
inputs:
artifact: nupkg
path: $(Build.ArtifactStagingDirectory)/nupkg
- task: NuGetCommand@2
displayName: NuGet push
inputs:
command: 'push'
packagesToPush: $(Build.ArtifactStagingDirectory)/nupkg/*.nupkg
nuGetFeedType: 'external'
publishFeedCredentials: 'NuGet'