-
Notifications
You must be signed in to change notification settings - Fork 0
175 lines (152 loc) · 5.8 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
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: "alpha"
publish:
type: boolean
description: run dotnet publish?
default: true
removePrereleases:
type: boolean
description: nuget unlist preleases?
default: false
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"
$branch = "main"
$conf = "${{github.event.inputs.configuration}}"
$verb = "${{github.event.inputs.verbosity}}"
$publ = "${{github.event.inputs.publish}}"
$removePrereleases = "${{github.event.inputs.removePrereleases}}"
$prefix = "${{github.event.inputs.versionPrefix}}"
$suffix = "${{github.event.inputs.versionSuffix}}"
$bnr = "${{github.run_number}}"
$commitMode = "noop"
if("${{github.event_name}}" -eq "workflow_dispatch"){
$commitMode = "dispatch"
}
else
{
$commitModeMergedPr = "$branch|pull_request|closed|true" -eq "${{github.base_ref}}|${{github.event_name}}|${{github.event.action}}|${{github.event.pull_request.merged}}"
$commitModePush = "$branch|push" -eq "${{github.base_ref}}|${{github.event_name}}"
if($commitModeMergedPr -eq $true)
{
$commitMode = "pushMerge"
}
if($commitModeMergedPr -eq $true)
{
$commitMode = "push"
}
}
$data = @{ #prefix #suffix #configuration #verbosity #publish #removeprerelease
"dispatch" = @("$prefix", "$suffix", "$conf", "$verb", "$publ", "$removePrereleases")
"push" = @("", "alpha.$bnr", "Release", "n", "true", "false")
"pushMerge" = @("", "beta.$bnr", "Release", "n", "true", "false")
"noop" = @("", "noop", "Release", "n", "false", "false")
};
$names = @("versionPrefix","versionSuffix","configuration","verbosity","publish","removePrereleases")
if($data[$commitMode] -eq $null){
Write-Host "Unidentified commit mode $commitMode"
echo "Commit mode could not be identified." >> $env:GITHUB_STEP_SUMMARY
exit 1;
}
foreach($item in $names){
$index = $names.IndexOf($item)
Write-Host "$item=$($data[$commitMode][$index])"
echo "$item=$($data[$commitMode][$index])" >> $env:GITHUB_OUTPUT
echo "$item=$($data[$commitMode][$index])" >> $env:GITHUB_STEP_SUMMARY
}
package:
needs: parameters
uses: taori/actions/.github/workflows/nupkg.yml@v9
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' }}
testArguments: "--filter Category!=SkipInCI"
concurrencyAbortable: true
coverageThreshold: '85 95'
dotnetVersion: 6.0.x
secrets:
nuget: ${{ secrets.NUGET }}