forked from SharpGenTools/SharpGenTools
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathazure-pipelines.yml
123 lines (121 loc) · 4.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
trigger:
branches:
include:
- master
tags:
include:
- v*.*
pr:
- master
variables:
buildNumber: $[counter(variables['build.reason'], 1000)]
stages:
- stage: Build
jobs:
- job: SharpGenTools_Windows
pool:
vmImage: 'windows-2019'
strategy:
matrix:
Debug:
Config: 'Debug'
Release:
Config: 'Release'
variables:
- name: DOTNET_SKIP_FIRST_TIME_EXPERIENCE
value: "true"
- name: DOTNET_ROLL_FORWARD
value: "Major"
- name: ReleaseVersion
value: ''
- name: ContinuousIntegrationBuild
value: true
- group: SharpGenTools
steps:
- pwsh: |
if ($env:SourceBranch -match 'refs/tags/v(?<Version>.+)')
{
Write-Host "##vso[task.setvariable variable=ReleaseVersion;]$($Matches.Version)"
}
displayName: 'Get Release Name (if this is a tag-triggered build)'
env:
SourceBranch : '$(Build.SourceBranch)'
- pwsh: dotnet tool restore
displayName: 'Restore .NET tools'
- pwsh: ./build.ps1 -Configuration $(Config)
displayName: 'Build SharpGenTools'
env:
ReleaseTag: '$(ReleaseVersion)'
BuildNumber: '$(buildNumber)'
- pwsh: ./test.ps1 -Configuration $(Config)
displayName: 'Run Tests'
env:
ReleaseTag: '$(ReleaseVersion)'
BuildNumber: '$(buildNumber)'
- task: PublishTestResults@2
displayName: 'Publish unit test results'
inputs:
testResultsFormat: 'VSTest'
testResultsFiles: '*.trx'
buildConfiguration: '$(Config)'
searchFolder: '$(Build.SourcesDirectory)/artifacts/test-results'
- pwsh: dotnet reportgenerator -reports:"artifacts\coverage\*.xml" -targetdir:"artifacts\reports" -reporttypes:Cobertura -title:SharpGen
condition: eq(variables['Config'], 'Debug')
displayName: 'Merge coverage reports'
- task: PublishCodeCoverageResults@1
condition: eq(variables['Config'], 'Debug')
displayName: 'Publish code coverage results'
inputs:
summaryFileLocation: '$(Build.SourcesDirectory)/artifacts/reports/*.xml'
codeCoverageTool: Cobertura
- task: CopyFiles@2
condition: eq(variables['Config'], 'Release')
displayName: 'Copy NuGet packages to Artifact staging directory'
inputs:
contents: 'Sharp*/**/Sharp*@(.nupkg|.snupkg)'
targetFolder: '$(Build.ArtifactStagingDirectory)'
flattenFolders: true
- task: PublishBuildArtifacts@1
condition: eq(variables['Config'], 'Release')
displayName: Publish NuGet Packages
inputs:
pathToPublish: '$(Build.ArtifactStagingDirectory)'
artifactName: NuGet Packages
- stage: Deploy
condition: or(eq(variables['Build.SourceBranchName'], 'master'), startsWith(variables['Build.SourceBranch'], 'refs/tags/v'))
dependsOn: Build
jobs:
- job: MyGet_Deploy
condition: not(startsWith(variables['Build.SourceBranch'], 'refs/tags/v'))
pool:
vmImage: 'windows-2019'
steps:
- checkout: none
- task: DownloadBuildArtifacts@0
inputs:
buildType: 'current'
downloadType: 'single'
artifactName: 'NuGet Packages'
downloadPath: '$(Build.ArtifactStagingDirectory)'
- task: NuGetCommand@2
inputs:
command: 'push'
nugetFeedType: 'external'
publishFeedCredentials: 'MyGet'
- job: NuGet_Deploy
condition: startsWith(variables['Build.SourceBranch'], 'refs/tags/v')
pool:
vmImage: 'windows-2019'
steps:
- checkout: none
- task: DownloadBuildArtifacts@0
inputs:
buildType: 'current'
downloadType: 'single'
artifactName: 'NuGet Packages'
downloadPath: '$(Build.ArtifactStagingDirectory)'
- task: NuGetCommand@2
inputs:
command: 'push'
nugetFeedType: 'external'
publishFeedCredentials: 'NuGet'