forked from tomchavakis/nuget-license
-
-
Notifications
You must be signed in to change notification settings - Fork 9
260 lines (207 loc) · 8.22 KB
/
action.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
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
name: "Main workflow"
on:
push:
branches:
- main
pull_request:
branches:
- "**"
jobs:
test:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, macos-latest]
framework: [net6.0, net8.0]
include:
- framework: net6.0
dotnetVersion: "6.0.x"
- framework: net8.0
dotnetVersion: "8.0.x"
steps:
- uses: actions/checkout@v4
- name: Setup dotnet ${{ matrix.dotnetVersion }}
uses: actions/setup-dotnet@v4
with:
dotnet-version: ${{ matrix.dotnetVersion }}
- uses: browser-actions/setup-chrome@latest
- name: restore
run: dotnet restore -p:TargetFramework=${{ matrix.framework }}
- name: build
run: dotnet build --configuration Release
- name: test
run: dotnet test --configuration Release -f ${{ matrix.framework }} --no-restore
test_windows:
runs-on: windows-latest
strategy:
matrix:
framework: [net6.0, net8.0, net472]
include:
- framework: net6.0
dotnetVersion: "6.0.x"
- framework: net8.0
dotnetVersion: "8.0.x"
steps:
- uses: actions/checkout@v4
- name: Setup dotnet ${{ matrix.dotnetVersion }}
uses: actions/setup-dotnet@v4
with:
dotnet-version: ${{ matrix.dotnetVersion }}
- uses: nuget/setup-nuget@v2
- run: nuget restore NuGetUtility.sln
- uses: browser-actions/setup-chrome@latest
- name: Add msbuild to PATH
uses: microsoft/setup-msbuild@v2
- name: build
run: msbuild -t:rebuild -property:Configuration=TestWindows
- name: test
uses: josepho0918/vstest-action@main
with:
testAssembly: "NuGetUtility.Test.dll"
searchFolder: "tests/NuGetUtility.Test/bin/TestWindows/${{ matrix.framework }}/"
runInParallel: true
check_code_format:
runs-on: ubuntu-latest
steps:
- name: Checkout repo
uses: actions/checkout@v4
- name: restore
run: dotnet restore
- name: check format
run: dotnet format --verify-no-changes
check_licenses:
runs-on: ubuntu-latest
strategy:
matrix:
targetFramework: [net6.0, net8.0]
project: [App, Tests, ProjectWithReferenceContainingLicenseExpression]
include:
- targetFramework: net6.0
dotnetVersion: "6.0.x"
- targetFramework: net8.0
dotnetVersion: "8.0.x"
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup dotnet ${{ matrix.dotnetVersion }}
uses: actions/setup-dotnet@v4
with:
dotnet-version: ${{ matrix.dotnetVersion }}
- name: restore
run: dotnet restore NuGetUtility.sln
- name: build
run: dotnet publish ./src/NuGetLicenseCore/NuGetLicenseCore.csproj --configuration Release -o ./release -f ${{ matrix.targetFramework }} --no-restore
- name: check
run: dotnet ./release/NuGetLicenseCore.dll -ji ./.github/workflows/assets/${{ matrix.project }}/projectsToCheck.json -t -a ./.github/workflows/assets/${{ matrix.project }}/allowedLicenses.json -o JsonPretty -override ./.github/workflows/assets/${{ matrix.project }}/overwritePackageInformation.json -ignore ./.github/workflows/assets/${{ matrix.project }}/ignorePackages.json -mapping ./.github/workflows/assets/${{ matrix.project }}/urlToLicenseMapping.json -d ./licenses/${{ matrix.project }}/${{ matrix.targetFramework }}
- name: show downloaded licenses
shell: pwsh
run: |
foreach($file in Get-ChildItem -Path ./licenses/${{ matrix.project }}/${{ matrix.targetFramework }})
{
Write-Host ::group::$file
Get-Content $file.FullName
Write-Host ::endgroup::
}
check_licenses_net472:
runs-on: windows-latest
strategy:
matrix:
project: [App, Tests, ProjectWithReferenceContainingLicenseExpression]
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: nuget/setup-nuget@v2
- run: nuget restore NuGetUtility.sln
- name: Add msbuild to PATH
uses: microsoft/setup-msbuild@v2
- name: fully qualify release path
id: release_path
shell: pwsh
run: |
$path = [System.IO.Path]::GetFullPath("./release");
echo "publish to path: $path"
echo "path=$path" >> $env:GITHUB_OUTPUT
- name: build
run: msbuild ./src/NuGetLicenseFramework/NuGetLicenseFramework.csproj /t:Publish /p:configuration=Release /p:PublishDir=${{ steps.release_path.outputs.path }}
- name: check
run: ${{ steps.release_path.outputs.path }}/NuGetLicenseFramework.exe -ji ./.github/workflows/assets/${{ matrix.project }}/projectsToCheck.json -t -a ./.github/workflows/assets/${{ matrix.project }}/allowedLicenses.json -o JsonPretty -override ./.github/workflows/assets/${{ matrix.project }}/overwritePackageInformation.json -ignore ./.github/workflows/assets/${{ matrix.project }}/ignorePackages.json -mapping ./.github/workflows/assets/${{ matrix.project }}/urlToLicenseMapping.json -d ./licenses/${{ matrix.project }}
- name: show downloaded licenses
shell: pwsh
run: |
foreach($file in Get-ChildItem -Path ./licenses/${{ matrix.project }})
{
Write-Host ::group::$file
Get-Content $file.FullName
Write-Host ::endgroup::
}
check_version_command:
runs-on: ubuntu-latest
strategy:
matrix:
targetFramework: [net6.0, net8.0]
include:
- targetFramework: net6.0
dotnetVersion: "6.0.x"
- targetFramework: net8.0
dotnetVersion: "8.0.x"
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup dotnet ${{ matrix.dotnetVersion }}
uses: actions/setup-dotnet@v4
with:
dotnet-version: ${{ matrix.dotnetVersion }}
- name: restore
run: dotnet restore NuGetUtility.sln
- uses: paulhatch/[email protected]
id: version
name: version
with:
tag_prefix: "v"
version_format: "${major}.${minor}.${patch}-test${increment}"
- name: build
run: dotnet publish ./src/NuGetLicenseCore/NuGetLicenseCore.csproj --configuration Release -o ./release -f ${{ matrix.targetFramework }} --no-restore -p:Version=${{ steps.version.outputs.version }}
- name: check app version
shell: pwsh
run: |
$cmdOutput = dotnet ./release/NuGetLicenseCore.dll --version | Out-String
if(!($cmdOutput.Trim() -like '${{ steps.version.outputs.version }}')) {
Write-Host Versions do not match: read $cmdOutput, expected ${{ steps.version.outputs.version }}
exit 1;
}
check_version_command_net472:
runs-on: windows-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: nuget/setup-nuget@v2
- run: nuget restore NuGetUtility.sln
- name: Add msbuild to PATH
uses: microsoft/setup-msbuild@v2
- name: fully qualify release path
id: release_path
shell: pwsh
run: |
$path = [System.IO.Path]::GetFullPath("./release");
echo "publish to path: $path"
echo "path=$path" >> $env:GITHUB_OUTPUT
- uses: paulhatch/[email protected]
id: version
name: version
with:
tag_prefix: "v"
version_format: "${major}.${minor}.${patch}-test${increment}"
- name: build
run: msbuild ./src/NuGetLicenseFramework/NuGetLicenseFramework.csproj /t:Publish /p:configuration=Release /p:PublishDir=${{ steps.release_path.outputs.path }} /p:Version=${{ steps.version.outputs.version }}
- name: check app version
shell: pwsh
run: |
$cmdOutput = ${{ steps.release_path.outputs.path }}/NuGetLicenseFramework.exe --version | Out-String
if(!($cmdOutput.Trim() -like '${{ steps.version.outputs.version }}')) {
Write-Host Versions do not match: read $cmdOutput, expected ${{ steps.version.outputs.version }}
exit 1;
}