-
Notifications
You must be signed in to change notification settings - Fork 0
182 lines (157 loc) · 5.75 KB
/
CI.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
name: CI
permissions:
contents:
write
pull-requests:
write
pages:
write
id-token:
write
on:
push:
branches: [ main ]
paths:
- .github/workflows/*
- src/**/*
- tests/**/*
pull_request:
branches: [ main ]
types:
- opened
- synchronize
workflow_dispatch:
inputs:
versionPrefix:
type: string
description: e.g 1.1.1
default: ""
versionSuffix:
type: string
description: e.g alpha.1
default: ""
package:
type: boolean
description: run dotnet pack?
default: false
publish:
type: boolean
description: run dotnet publish?
default: false
skipTests:
type: boolean
description: skip tests?
default: false
publishSymbols:
type: boolean
description: publish snupkg?
default: false
removePrereleases:
type: boolean
description: nuget unlist preleases?
default: false
runCoverage:
type: boolean
description: run code coverage?
default: true
configuration:
description: build configuration
required: false
default: Release
type: choice
options:
- Debug
- Release
verbosity:
description: build log verbosity
required: false
default: minimal
type: choice
options:
- quiet
- minimal
- normal
- detailed
- diagnostic
jobs:
parameters:
runs-on: ubuntu-latest
outputs:
versionSuffix: ${{ steps.parameters.outputs.versionSuffix }}
versionPrefix: ${{ steps.parameters.outputs.versionPrefix }}
configuration: ${{ steps.parameters.outputs.configuration }}
verbosity: ${{ steps.parameters.outputs.verbosity }}
publish: ${{ steps.parameters.outputs.publish }}
package: ${{ steps.parameters.outputs.package }}
publishSymbols: ${{ steps.parameters.outputs.publishSymbols }}
removePrereleases: ${{ steps.parameters.outputs.removePrereleases }}
skipTests: ${{ steps.parameters.outputs.skipTests }}
runCoverage: ${{ steps.parameters.outputs.runCoverage }}
steps:
- name: nuget secret verification
env:
NUGET: ${{ secrets.NUGET }}
if: "${{ env.NUGET == '' }}"
uses: actions/github-script@v3
with:
script: |
core.setFailed('"nuget" secret is missing')
- name: Setting up parameters
id: parameters
shell: pwsh
run: |
Write-Host "Setting up parameters"
$suffixMap = @{
"push"="alpha.${{github.run_number}}";
"pull_request"="beta.${{github.run_number}}";
"workflow_dispatch"="${{github.event.inputs.versionSuffix}}"
};
$suffix = $suffixMap['${{github.event_name}}']
if( $suffixMap['workflow_dispatch'] -ne '' -and '${{github.event_name}}' -eq 'workflow_dispatch'){
$suffix = $($suffix.TrimEnd('.') + ".")
$suffix = "$($suffix)${{github.run_number}}"
}
# key name workflow value fallback value
$values = @(
@("versionSuffix", "$suffix", "$suffix"),
@("versionPrefix", "${{github.event.inputs.versionPrefix}}", ""),
@("configuration", "${{github.event.inputs.configuration}}", "Release"),
@("verbosity", "${{github.event.inputs.verbosity}}", "minimal"),
@("publish", "${{github.event.inputs.publish}}", "false"),
@("package", "${{github.event.inputs.package}}", "true"),
@("publishSymbols", "${{github.event.inputs.publishSymbols}}", "false"),
@("removePrereleases", "${{github.event.inputs.removePrereleases}}", "false"),
@("skipTests", "${{github.event.inputs.skipTests}}", "false"),
@("runCoverage", "${{github.event.inputs.runCoverage}}", "true")
)
$manual = $('${{github.event_name}}' -eq 'workflow_dispatch')
foreach($pair in $values){
$value = $pair[2]
if($manual -eq $true){
$value = $pair[1]
}
Write-Host "Setting parameter $($pair[0]) => $value"
#echo "::set-output name=$($pair[0])::$value"
echo "$($pair[0])=$value" >> $env:GITHUB_OUTPUT
}
package:
needs: parameters
uses: taori/actions/.github/workflows/nupkg.yml@main
with:
solutionPath: src/Amusoft.DotnetNew.Tests.sln
packProjects: src/Amusoft.DotnetNew.Tests/Amusoft.DotnetNew.Tests.csproj
versionSuffix: ${{ needs.parameters.outputs.versionSuffix }}
versionPrefix: ${{ needs.parameters.outputs.versionPrefix }}
package: ${{ needs.parameters.outputs.package == 'true' }}
publish: ${{ needs.parameters.outputs.publish == 'true' }}
publishSymbols: ${{ needs.parameters.outputs.publishSymbols == 'true' }}
removePrereleases: ${{ needs.parameters.outputs.removePrereleases == 'true' }}
skipTests: ${{ needs.parameters.outputs.skipTests == 'true' }}
configuration: ${{ needs.parameters.outputs.configuration }}
verbosity: ${{ needs.parameters.outputs.verbosity }}
runCoverage: ${{ needs.parameters.outputs.runCoverage == 'true' }}
concurrencyAbortable: true
coverageThreshold: '85 95'
dotnetVersion: 6.0.x
secrets:
nuget: ${{ secrets.NUGET }}