-
-
Notifications
You must be signed in to change notification settings - Fork 9
/
class-lib-build-only.yml
195 lines (174 loc) · 5.47 KB
/
class-lib-build-only.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
182
183
184
185
186
187
188
189
190
191
192
193
194
195
# Copyright (c) .NET Foundation and Contributors
# Portions Copyright (c) Sankarsan Kampa (a.k.a. k3rn31p4nic). All rights reserved.
# See LICENSE file in the project root for full license information.
parameters:
- name: skipNuGetRestore
type: boolean
default: false
- name: skipNuGetCache
type: boolean
default: false
- name: gitUser
type: string
default: nfbot
- name: gitEmail
type: string
default: nanoframework@outlook.com
- name: skipSonarCloudAnalysis
type: boolean
default: false
- name: sonarCloudProject
type: string
default: dummy-key
- name: nugetConfigPath
type: string
default: ''
- name: runUnitTests
type: boolean
default: false
- name: unitTestRunsettings
type: string
default: '$(System.DefaultWorkingDirectory)\.runsettings'
steps:
# need this here in order to persist GitHub credentials
- checkout: self
submodules: true
fetchDepth: 0
- script: |
git config --global user.email ${{ parameters.gitEmail }}
git config --global user.name ${{ parameters.gitUser }}
git config --global core.autocrlf true
displayName: Setup git identity
# get commit details
- template: get-commit-details.yml
- template: file-checks.yml
- template: install-nbgv-tool.yml
- template: prepare-release.yml
- task: SonarCloudPrepare@3
condition: >-
and(
succeeded(),
eq(variables['StartReleaseCandidate'], false),
not(startsWith(variables['Build.SourceBranch'], 'refs/tags/v')),
not(${{ parameters.skipSonarCloudAnalysis }})
)
displayName: 'Prepare analysis on SonarCloud'
inputs:
SonarCloud: 'sonarcloud-$(System.TeamProject)'
organization: 'nanoframework'
scannerMode: 'dotnet'
projectKey: '${{ parameters.sonarCloudProject }}'
extraProperties: |
sonar.exclusions=**/obj/**,**/*.dll
sonar.cs.vscoveragexml.reportsPaths=$(Agent.TempDirectory)/**/**.coverage
sonar.cs.vstest.reportsPaths=$(Agent.TempDirectory)/**/**.trx
sonar.scanner.skipJreProvisioning=true
- task: InstallNanoMSBuildComponents@1
condition: >-
and(
succeeded(),
eq(variables['StartReleaseCandidate'], false),
not(startsWith(variables['Build.SourceBranch'], 'refs/tags/v'))
)
displayName: Install .NET nanoFramework MSBuild components
inputs:
GitHubToken: $(GitHubToken)
- template: install-nuget.yml
- template: cache-nano-nugets.yml
parameters:
skipNuGetCache: ${{ parameters.skipNuGetCache }}
- task: NuGetCommand@2
condition: >-
and(
succeeded(),
not(${{ parameters.skipNuGetRestore }}),
eq(variables['StartReleaseCandidate'], false),
not(startsWith(variables['Build.SourceBranch'], 'refs/tags/v'))
)
displayName: NuGet restore
retryCountOnTaskFailure: 5
inputs:
restoreSolution: '**/*.sln'
${{ if eq(parameters.nugetConfigPath, '') }}:
feedsToUse: select
${{ else }}:
feedsToUse: config
nugetConfigPath: ${{ parameters.nugetConfigPath }}
- template: versions-check.yml
- task: VSBuild@1
condition: >-
and(
succeeded(),
eq(variables['StartReleaseCandidate'], false),
not(startsWith(variables['Build.SourceBranch'], 'refs/tags/v'))
)
inputs:
solution: '$(solution)'
platform: '$(buildPlatform)'
msbuildArgs: '/p:PublicRelease=true'
configuration: '$(buildConfiguration)'
msbuildArchitecture: 'x64'
maximumCpuCount: true
- template: run-unit-tests.yml
parameters:
runUnitTests: '${{ parameters.runUnitTests }}'
unitTestRunsettings: '${{ parameters.unitTestRunsettings }}'
- template: get-assembly-native-version.yml
- powershell: |
# get subject and commit message for commit
$commitMessage = git log --format='%B' -1
# need to flatten message by removing new lines
$commitMessage = $commitMessage -replace "`r`n", " "
if($commitMessage -like "*PUBLISH_RELEASE*")
{
# set variable
Write-Host "$("##vso[task.setvariable variable=RELEASE_DRAFT;isOutput=true]")false"
Write-Host "$("##vso[task.setvariable variable=RELEASE_VERSION;isOutput=true]")true"
Write-Host "Release draft: FALSE"
}
else
{
# set variable
Write-Host "$("##vso[task.setvariable variable=RELEASE_DRAFT;isOutput=true]")true"
Write-Host "$("##vso[task.setvariable variable=RELEASE_VERSION;isOutput=true]")false"
Write-Host "Release draft: TRUE"
}
name: SetReleaseDraftVar
condition: >-
and(
succeeded(),
eq(variables['StartReleaseCandidate'], false)
)
displayName: Set release draft var
- task: SonarCloudAnalyze@3
condition: >-
and(
succeeded(),
eq(variables['StartReleaseCandidate'], false),
not(startsWith(variables['Build.SourceBranch'], 'refs/tags/v')),
not(${{ parameters.skipSonarCloudAnalysis }})
)
displayName: 'Run Code Analysis'
- task: SonarCloudPublish@3
condition: >-
and(
succeeded(),
eq(variables['StartReleaseCandidate'], false),
not(startsWith(variables['Build.SourceBranch'], 'refs/tags/v')),
not(${{ parameters.skipSonarCloudAnalysis }})
)
displayName: 'Publish Quality Gate Result'
inputs:
pollingTimeoutSec: '300'
- task: UseRubyVersion@0
condition: >-
and(
succeeded(),
eq(variables['System.PullRequest.PullRequestId'], ''),
not(startsWith(variables['Build.SourceBranch'], 'refs/pull/')),
eq(variables['StartReleaseCandidate'], false)
)
displayName: Setup Ruby
inputs:
versionSpec: '= 3.0'
addToPath: true