forked from enterspeedhq/enterspeed-sdk-dotnet
-
Notifications
You must be signed in to change notification settings - Fork 0
/
azure-pipelines.yml
148 lines (135 loc) · 5.2 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
variables:
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: 1
majorVersion: 2
minorVersion: 0
patchVersion: 2
version: $[format('{0}.{1}.{2}', variables.majorVersion, variables.minorVersion, variables.patchVersion)]
${{ if eq(variables['Build.SourceBranch'], 'refs/heads/master') }}:
releaseOnNuget: true
# Versioning: 1.0.0
semVersion: $[format('{0}', variables.version)]
buildName: $[format('{0}', variables.semVersion)]
${{ if eq(variables['Build.SourceBranch'], 'refs/heads/develop') }}:
# Versioning: 1.0.0-develop.123
releaseOnNuget: false
semVersionBase: $[format('{0}-develop', variables.version)]
semVersionRev: $[counter(variables.semVersionBase, 0)]
semVersion: $[format('{0}.{1}', variables.semVersionBase, variables.semVersionRev)]
buildName: $[format('Develop - {0}', variables.semVersion)]
${{ if startsWith(variables['Build.SourceBranch'], 'refs/heads/release/') }}:
# Versioning: 1.0.0-alpha.branch.123
releaseOnNuget: false
semVersionBase: $[format('{0}-alpha.{1}', variables.version, variables['Build.SourceBranchName'])]
semVersionRev: $[counter(variables.semVersionBase, 0)]
semVersion: $[format('{0}.{1}', variables.semVersionBase, variables.semVersionRev)]
buildName: $[format('Release - {0}', variables.semVersion)]
${{ if startsWith(variables['Build.SourceBranch'], 'refs/pull/') }}: # Pull requests
# Versioning: 1.0.0-pr.1.123
releaseOnNuget: false
semVersionBase: $[format('{0}-pr.{1}', variables.version, variables['System.PullRequest.PullRequestId'])]
semVersionRev: $[counter(variables.semVersionBase, 0)]
semVersion: $[format('{0}.{1}', variables.semVersionBase, variables.semVersionRev)]
buildName: $[format('Pull Request - {0}', variables.semVersion)]
${{ if startsWith(variables['Build.SourceBranch'], 'refs/heads/prerelease/') }}:
# Versioning: 1.0.0-alpha.123
releaseOnNuget: true
semVersionBase: $[format('{0}-alpha', variables.version)]
semVersionRev: $[counter(variables.semVersionBase, 1)]
semVersion: $[format('{0}.{1}', variables.semVersionBase, variables.semVersionRev)]
buildName: $[format('Prerelease - {0}', variables.semVersion)]
name: $(BuildID) - $(buildName)
trigger:
branches:
include:
- master
- develop
- release/*
paths:
exclude:
- README.md
- CHANGELOG.md
- documentation/*
stages:
- stage: Build
displayName: Build
jobs:
- job: BuildPlatform
displayName: Build Platform
pool:
vmImage: windows-latest
steps:
- task: UseDotNet@2
displayName: Install .NET 6.0 SDK
inputs:
packageType: sdk
version: "6.0.x"
# NuGet
- task: NuGetToolInstaller@1
displayName: NuGet install
- task: NuGetCommand@2
displayName: NuGet restore
inputs:
restoreSolution: '**\*.sln'
feedsToUse: config
nugetConfigPath: ./NuGet.Config
restoreDirectory: ../lib/packages
# Build solution
- task: DotNetCoreCLI@2
displayName: Dotnet build
inputs:
command: build
projects: "Enterspeed.Sdk.sln"
arguments: "--configuration Release"
# Run unit tests
- task: DotNetCoreCLI@2
displayName: Dotnet test
inputs:
command: test
arguments: '--no-build --configuration Release --collect:"XPlat Code Coverage"'
# Pack NuGet
- task: DotNetCoreCLI@2
displayName: Dotnet pack
inputs:
command: pack
packagesToPack: "**/*.csproj"
versioningScheme: byEnvVar
versionEnvVar: semVersion
arguments: "--configuration Release /p:Version=$(semVersion)"
# Publish artifacts
- task: PublishPipelineArtifact@1
displayName: Publish artifact - nupkg
inputs:
targetPath: "$(Build.ArtifactStagingDirectory)"
artifact: nupkg
- stage: Release
displayName: Release
condition: and(succeeded(), eq(variables.releaseOnNuget, 'true'))
jobs:
- deployment: ReleaseNuGet
displayName: Release on NuGet.org
environment: NuGetOrg
pool:
vmImage: ubuntu-latest
strategy:
runOnce:
deploy:
steps:
- checkout: self
persistCredentials: true
clean: true
fetchDepth: 1
# Tag release in git
- task: Bash@3
displayName: Tag version in git
inputs:
targetType: inline
script: |
git tag $(semVersion)
git push --tags
- task: NuGetCommand@2
displayName: Release on NuGet.org
inputs:
command: push
packagesToPush: "$(Pipeline.Workspace)/**/*.nupkg;!$(Pipeline.Workspace)/**/*.symbols.nupkg"
nuGetFeedType: external
publishFeedCredentials: NuGet.org