-
-
Notifications
You must be signed in to change notification settings - Fork 20
243 lines (206 loc) Β· 8.25 KB
/
build.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
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
name: ποΈπ§ͺπ¦ WinTuner
on:
push:
branches:
- main
tags:
- v*
pull_request:
branches:
- main
workflow_dispatch:
jobs:
test:
name: π οΈ Build and Test C#
runs-on: ubuntu-latest
permissions:
contents: read
issues: read
checks: write
steps:
- name: π¨βπ» Check-out code
uses: actions/checkout@v4
- name: π¨βπ§ Setup .NET Core SDK
uses: actions/setup-dotnet@v4
with:
dotnet-version: 8.x
- name: π Enable problem matchers
run: echo "::add-matcher::.github/matchers/dotnet.json"
- name: π¦ΈββοΈ Restore steriods
uses: actions/cache@v4
with:
path: ~/.nuget/packages
# Look to see if there is a cache hit for the corresponding requirements file
key: ${{ runner.os }}-nuget-${{ hashFiles('**/packages.lock.json') }}
restore-keys: |
${{ runner.os }}-nuget
- name: π Load packages
run: dotnet restore
- name: π οΈ Build code
run: dotnet build --configuration Release --no-restore
- name: βοΈ Testing code
run: dotnet test --configuration Release -v minimal --no-build --logger GitHubActions '/p:CollectCoverage=true;CoverletOutputFormat="json,lcov,cobertura";MergeWith=${{github.workspace}}/coverage.json;CoverletOutput=${{github.workspace}}/coverage' -- RunConfiguration.CollectSourceInformation=true
- name: π Code Coverage report
run: |
dotnet tool install --global dotnet-reportgenerator-globaltool --version 5.2.5
reportgenerator -reports:${{github.workspace}}/coverage.cobertura.xml -targetdir:${{github.workspace}}/report -reporttypes:MarkdownSummaryGithub -filefilters:-*.g.cs "-classfilters:-WixSharp.*;-WingetIntune.Os.*;-WingetIntune.Internal.MsStore.Models.*" -verbosity:Warning
sed -i 's/# Summary/## π Code Coverage/g' ${{github.workspace}}/report/SummaryGithub.md
sed -i 's/## Coverage/### π Code Coverage details/g' ${{github.workspace}}/report/SummaryGithub.md
cat ${{github.workspace}}/report/*.md >> $GITHUB_STEP_SUMMARY
- name: π Check code formatting
if: always()
run: dotnet format --verify-no-changes
testps:
name: π οΈ Build and Test PowerShell
runs-on: ubuntu-latest
permissions:
contents: read
issues: read
checks: write
pull-requests: write
steps:
- name: π¨βπ» Check-out code
uses: actions/checkout@v4
- name: π¨βπ§ Setup .NET Core SDK
uses: actions/setup-dotnet@v4
with:
dotnet-version: 8.x
- name: π Enable problem matchers
run: echo "::add-matcher::.github/matchers/dotnet.json"
- name: π¦ΈββοΈ Restore steriods
uses: actions/cache@v4
with:
path: ~/.nuget/packages
# Look to see if there is a cache hit for the corresponding requirements file
key: ${{ runner.os }}-nuget-${{ hashFiles('**/packages.lock.json') }}
restore-keys: |
${{ runner.os }}-nuget
- name: π Load packages
run: dotnet restore
- name: π οΈ Build module
shell: pwsh
run:
dotnet build ./src/Svrooij.WinTuner.CmdLets/Svrooij.WinTuner.CmdLets.csproj --configuration Release --no-restore -p:Version="0.0.1-dev" -o ./dist/WinTuner
- name: π¦ Install Pester
shell: pwsh
run: Install-Module -Name Pester -Force -SkipPublisherCheck -Scope CurrentUser
- name: π΅οΈ Import module and list commands
shell: pwsh
run: |
Import-Module ./dist/WinTuner/WinTuner.psd1
Get-Command -Module WinTuner
- name: π§ͺ Run test
shell: pwsh
run: |
Import-Module Pester
Import-Module ./dist/WinTuner/WinTuner.psd1
$pesterConfig = [PesterConfiguration]@{
Output = @{
Verbosity = "Normal"
CIFormat = "Auto"
StackTraceVerbosity = "FirstLine"
}
TestResult = @{
Enabled = $true
OutputPath = "${{ github.workspace }}/testresults/TestResults.xml"
OutputFormat = "JUnitXml"
}
Run = @{
Path = "./tests/WinTuner.Cmdlets.Tests"
Exit = $true
}
Should = @{
ErrorAction = "Continue"
}
}
Invoke-Pester -Configuration $pesterConfig
- name: Publish Test Results
uses: EnricoMi/publish-unit-test-result-action@v2
if: always()
with:
files: ${{ github.workspace }}/testresults/*.xml
publish-nuget:
name: π¦ Publish WinTuner to nuget
runs-on: ubuntu-latest
if: startsWith(github.ref, 'refs/tags/')
needs: [test, testps]
steps:
- name: π¨βπ» Check-out code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: π¨βπ§ Setup .NET Core SDK
uses: actions/setup-dotnet@v4
with:
dotnet-version: 8.x
- name: π Enable problem matchers
run: echo "::add-matcher::.github/matchers/dotnet.json"
- name: π¦ΈββοΈ Restore steriods
uses: actions/cache@v4
with:
path: ~/.nuget/packages
# Look to see if there is a cache hit for the corresponding requirements file
key: ${{ runner.os }}-nuget-${{ hashFiles('**/packages.lock.json') }}
restore-keys: |
${{ runner.os }}-nuget
- name: π Load packages
run: dotnet restore
- name: π οΈ Build code
shell: pwsh
run: dotnet build ./src/WingetIntune.Cli/WingetIntune.Cli.csproj --configuration Release --no-restore -p:Version=$("${{ github.ref_name }}".Substring(1))
- name: π¦ Pack WinTuner CLI
shell: pwsh
run: dotnet pack ./src/WingetIntune.Cli/WingetIntune.Cli.csproj --configuration Release --no-build -p:Version=$("${{ github.ref_name }}".Substring(1))
- name: βοΈ Publish Svrooij.Winget-Intune.Cli to nuget.org
run: dotnet nuget push ./src/WingetIntune.Cli/bin/Release/SvRooij.Winget-Intune.Cli.*.nupkg -k $NUGET_AUTH_TOKEN -s https://api.nuget.org/v3/index.json
env:
NUGET_AUTH_TOKEN: ${{ secrets.NUGET_TOKEN }}
publish-psgallery:
name: π¦ Publish WinTuner to PowerShell Gallery
runs-on: ubuntu-latest
if: startsWith(github.ref, 'refs/tags/')
needs: [test, testps]
steps:
- name: π¨βπ» Check-out code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: π¨βπ§ Setup .NET Core SDK
uses: actions/setup-dotnet@v4
with:
dotnet-version: 8.x
- name: π Enable problem matchers
run: echo "::add-matcher::.github/matchers/dotnet.json"
- name: π¦ΈββοΈ Restore steriods
uses: actions/cache@v4
with:
path: ~/.nuget/packages
# Look to see if there is a cache hit for the corresponding requirements file
key: ${{ runner.os }}-nuget-${{ hashFiles('**/packages.lock.json') }}
restore-keys: |
${{ runner.os }}-nuget
- name: π Load packages
run: dotnet restore
- name: π Set module version
shell: pwsh
id: version
run: |
$version = "${{ github.ref_name }}".Substring(1)
$module = Get-Content -Path src/Svrooij.WinTuner.CmdLets/WinTuner.psd1
$module = $module -replace 'ModuleVersion = ''\d+\.\d+\.\d+''', "ModuleVersion = '$version'"
$module | Set-Content -Path src/Svrooij.WinTuner.CmdLets/WinTuner.psd1
- name: π οΈ Build module
shell: pwsh
run: dotnet build ./src/Svrooij.WinTuner.CmdLets/Svrooij.WinTuner.CmdLets.csproj --configuration Release --no-restore -p:Version=$("${{ github.ref_name }}".Substring(1)) -o ./dist/WinTuner
- name: π§ͺ Import module
shell: pwsh
run: |
Import-Module ./dist/WinTuner/WinTuner.psd1
Get-Command -Module WinTuner
- name: π¦ Publish WinTuner to PowerShell Gallery
shell: pwsh
run: |
Import-Module ./dist/WinTuner/WinTuner.psd1
Publish-Module -Path ./dist/WinTuner -NuGetApiKey $env:PSGALLERY_TOKEN -Repository PSGallery -Force
env:
PSGALLERY_TOKEN: ${{ secrets.PSGALLERY_TOKEN }}