-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.yml
81 lines (78 loc) · 3.06 KB
/
build.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
trigger:
batch: true
branches:
include:
- master
tags:
include:
- '*'
paths:
include:
- src/*
- tests/*
- $(projectName).sln
pool:
vmImage: "ubuntu-latest"
variables:
solutionPath: "$(projectName).sln"
projectPath: "src/$(projectName)/$(projectName).csproj"
buildConfiguration: "Release"
major: 1
minor: 0
patch: 3
stages:
- stage: stage_create_package
displayName: Create Nuget package
jobs:
- job: job_create_package
displayName: Create Nuget package
variables:
suffix: $[counter(format('{0}.{1}.{2}', variables.major, variables.minor, variables.patch), 1)]
previewPadded: $[format('-{0}0{1}', 'preview', variables['suffix'])]
previewUnpadded: $[format('-{0}{1}', 'preview', variables['suffix'])]
packageVersion: $(major).$(minor).$(patch)$(previewSuffix)
isMain: $[eq(variables['Build.SourceBranch'], 'refs/heads/master')]
isTag: $[startsWith(variables['Build.SourceBranch'], 'refs/tags/')]
steps:
- script: TMP=$(echo $(previewPadded)) && echo "##vso[task.setvariable variable=previewSuffix]$TMP"
displayName: Use padded suffix
condition: and(gt(10, variables.suffix), eq(variables.isMain, false))
- script: TMP=$(echo $(previewUnpadded)) && echo "##vso[task.setvariable variable=previewSuffix]$TMP"
displayName: Use unpadded suffix
condition: and(le(10, variables.suffix), eq(variables.isMain, false))
- script: TMP=$(echo '') && echo "##vso[task.setvariable variable=previewSuffix]$TMP"
displayName: No suffix
condition: or(eq(variables.isTag, true), eq(variables.isMain, true))
- script: echo Version => $(packageVersion)
displayName: Show version number
condition: or(eq(variables.isTag, true), eq(variables.isMain, false))
- task: DotNetCoreCLI@2
displayName: Restore Nuget packages
inputs:
command: restore
projects: $(projectPath)
feedsToUse: "config"
nugetConfigPath: "nuget.config"
- task: DotNetCoreCLI@2
displayName: Test
inputs:
command: test
projects: $(solutionPath)
- task: DotNetCoreCLI@2
displayName: Create Nuget package
inputs:
command: pack
configurationToPack: "$(buildConfiguration)"
packagesToPack: "$(projectPath)"
versioningScheme: byEnvVar
versionEnvVar: packageVersion
condition: or(eq(variables.isTag, true), eq(variables.isMain, false))
- task: DotNetCoreCLI@2
displayName: Push Nuget package
inputs:
command: push
packagesToPush: "$(Build.ArtifactStagingDirectory)/*.nupkg"
vstsFeed: "contactcentre"
publishVstsFeed: "contactcentre"
nobuild: true
condition: or(eq(variables.isTag, true), eq(variables.isMain, false))