-
Notifications
You must be signed in to change notification settings - Fork 1
/
azure-pipelines.yml
113 lines (109 loc) · 4.93 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
trigger:
batch: true
branches:
include:
- master
variables:
BuildProjects: '**/*.csproj' # Projects to Restore & Build
BuildConfiguration: release
stages:
- stage: Build
displayName: 'Build & Test'
variables:
TestProjects: '**/*Tests/*.csproj' # Projects to Test
jobs:
- job: 'Build_And_Test'
pool:
vmImage: 'windows-latest'
steps:
- checkout: self
persistCredentials: true
clean: true
#allow steps to use the agent git credentials
- task: gittools.gitversion.gitversion-task.GitVersion@4 # Automatically creates a GitVersion.NuGetVersion variable.
displayName: GitVersion
inputs:
preferBundledVersion: false
- task: DotNetCoreCLI@2
displayName: Build
inputs:
projects: '$(BuildProjects)'
arguments: '--configuration $(BuildConfiguration) -p:VersionPrefix=$(GitVersion.NuGetVersion)'
- task: DotNetCoreCLI@2
displayName: Test
inputs:
command: test
projects: '$(TestProjects)'
arguments: '--configuration $(BuildConfiguration) /p:CollectCoverage=true /p:CoverletOutputFormat=cobertura'
- script: |
dotnet tool install -g dotnet-reportgenerator-globaltool
reportgenerator -reports:$(Build.SourcesDirectory)/**/coverage.cobertura.xml -targetdir:$(Build.SourcesDirectory)/CodeCoverage -reporttypes:Cobertura
displayName: Create Code coverage report
- task: PublishCodeCoverageResults@1
displayName: 'Publish code coverage'
inputs:
codeCoverageTool: Cobertura
summaryFileLocation: '$(Build.SourcesDirectory)/CodeCoverage/Cobertura.xml'
- task: DotNetCoreCLI@2
displayName: 'dotnet publish Banjo.CLI'
inputs:
command: publish
publishWebProjects: false
projects: 'Banjo.CLI/Banjo.CLI.csproj'
arguments: '--configuration $(BuildConfiguration) --output $(Build.ArtifactStagingDirectory)/Banjo.CLI'
zipAfterPublish: false
modifyOutputPath: false
- task: PublishPipelineArtifact@1
displayName: 'Publish Banjo.CLI Pipeline Artifact'
inputs:
path: '$(Build.ArtifactStagingDirectory)/Banjo.CLI'
artifact: Banjo.CLI
- task: PublishPipelineArtifact@1
displayName: 'Publish nupkg as Pipeline Artifact'
inputs:
path: 'Banjo.CLI/Banjo.CLI.$(GitVersion.NuGetVersion).nupkg'
artifact: CLI
- pwsh: |
# adapted from: https://developercommunity.visualstudio.com/idea/1007477/missing-gui-option-create-git-tag-after-successful.html?childToView=1014307#comment-1014307
# configure the git user as the user that requested this pipline run
Write-Host "git config user.email $env:BUILD_REQUESTEDFOREMAIL"
git config user.email $env:BUILD_REQUESTEDFOREMAIL
Write-Host "git config user.name $env:BUILD_REQUESTEDFOR"
git config user.name $env:BUILD_REQUESTEDFOR
# set a tag name and message for annotated tag
Write-Host "git tag -a $env:TAG -m ""Tagged for release by $env:BUILD_REQUESTEDFOR"""
git tag -a $env:TAG -m "Tagged for release by $env:BUILD_REQUESTEDFOR"
Write-Host "git push origin $env:TAG"
git push origin $env:TAG
condition: and(succeeded(), eq(variables['Build.SourceBranch'], 'refs/heads/master')) #only tag master commits
env:
TAG: $(GitVersion.NuGetVersion)
displayName: Tag master commit
failOnStderr: false
continueOnError: true # The task seems to _always_ fail even when it's successfully created the tag
- stage: Publish_Nuget
displayName: 'Publish CLI'
dependsOn: Build
condition: and(succeeded(), or( eq(variables['Build.SourceBranch'], 'refs/heads/master') , eq(variables['Build.Reason'], 'PullRequest') ) ) # Only run for master or PR, after Build has succeeded
jobs:
- job: CLI
pool:
vmImage: 'windows-latest'
# dependsOn: Build
steps:
- checkout: none
- task: DownloadPipelineArtifact@2
displayName: 'Download CLI Artifact'
inputs:
artifactName: CLI
targetPath: '$(Pipeline.Workspace)/CLI'
- task: NuGetAuthenticate@0
displayName: 'NuGet Authenticate'
- task: NuGetCommand@2
displayName: 'Nuget Publish Banjo.CLI'
inputs:
command: push
packagesToPush: '$(Pipeline.Workspace)/CLI/Banjo.CLI.*.nupkg'
publishVstsFeed: 'Labs/Banjo'
allowPackageConflicts: true
verbosityPush: Normal