Skip to content

Commit ebf3d31

Browse files
Extend NuGet package validation
- Use Meziantou.Framework.NuGetPackageValidation.Tool to extend NuGet package validation. - Use consistent PowerShell environment variable syntax.
1 parent b00b493 commit ebf3d31

6 files changed

Lines changed: 38 additions & 10 deletions

File tree

.config/dotnet-tools.json

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,22 @@
66
"version": "0.0.1-preview.537",
77
"commands": [
88
"dotnet-validate"
9-
]
9+
],
10+
"rollForward": false
1011
},
1112
"markdownsnippets.tool": {
1213
"version": "27.0.2",
1314
"commands": [
1415
"mdsnippets"
15-
]
16+
],
17+
"rollForward": false
18+
},
19+
"meziantou.framework.nugetpackagevalidation.tool": {
20+
"version": "1.0.31",
21+
"commands": [
22+
"meziantou.validate-nuget-package"
23+
],
24+
"rollForward": false
1625
}
1726
}
1827
}

.github/bump-version.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ try {
4848
$writer = $null
4949
}
5050

51-
$githubOutput = $env:GITHUB_OUTPUT
51+
$githubOutput = ${env:GITHUB_OUTPUT}
5252

5353
if (($null -ne $githubOutput) -and (Test-Path $githubOutput)) {
5454
"version=${updatedVersion}" >> $githubOutput

.github/workflows/build.yml

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ jobs:
2929
outputs:
3030
dotnet-sdk-version: ${{ steps.setup-dotnet.outputs.dotnet-version }}
3131
dotnet-validate-version: ${{ steps.get-dotnet-tools-versions.outputs.dotnet-validate-version }}
32+
nuget-package-validation-version: ${{ steps.get-dotnet-tools-versions.outputs.nuget-package-validation-version }}
3233
package-names: ${{ steps.build.outputs.package-names }}
3334
package-version: ${{ steps.build.outputs.package-version }}
3435

@@ -148,7 +149,9 @@ jobs:
148149
run: |
149150
$manifest = (Get-Content "./.config/dotnet-tools.json" | Out-String | ConvertFrom-Json)
150151
$dotnetValidateVersion = $manifest.tools.'dotnet-validate'.version
151-
"dotnet-validate-version=${dotnetValidateVersion}" >> $env:GITHUB_OUTPUT
152+
$nugetPackageValidationVersion = $manifest.tools.'meziantou.framework.nugetpackagevalidation.tool'.version
153+
"dotnet-validate-version=${dotnetValidateVersion}" >> ${env:GITHUB_OUTPUT}
154+
"nuget-package-validation-version=${nugetPackageValidationVersion}" >> ${env:GITHUB_OUTPUT}
152155
153156
validate-packages:
154157
needs: build
@@ -165,17 +168,33 @@ jobs:
165168
with:
166169
dotnet-version: ${{ needs.build.outputs.dotnet-sdk-version }}
167170

168-
- name: Validate NuGet packages
171+
- name: Install NuGet package validation tools
169172
shell: pwsh
170173
env:
171174
DOTNET_VALIDATE_VERSION: ${{ needs.build.outputs.dotnet-validate-version }}
175+
NUGET_PACKAGE_VALIDATION_VERSION: ${{ needs.build.outputs.nuget-package-validation-version }}
172176
run: |
173177
dotnet tool install --global dotnet-validate --version ${env:DOTNET_VALIDATE_VERSION} --allow-roll-forward
178+
dotnet tool install --global Meziantou.Framework.NuGetPackageValidation.Tool --version ${env:NUGET_PACKAGE_VALIDATION_VERSION} --allow-roll-forward
179+
180+
- name: Validate NuGet packages
181+
shell: pwsh
182+
env:
183+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
184+
run: |
174185
$packages = Get-ChildItem -Filter "*.nupkg" | ForEach-Object { $_.FullName }
175186
$invalidPackages = 0
176187
foreach ($package in $packages) {
188+
$isValid = $true
177189
dotnet validate package local $package
178190
if ($LASTEXITCODE -ne 0) {
191+
$isValid = $false
192+
}
193+
meziantou.validate-nuget-package $package --github-token ${env:GH_TOKEN} --excluded-rules IconMustBeSet
194+
if ($LASTEXITCODE -ne 0) {
195+
$isValid = $false
196+
}
197+
if (-Not $isValid) {
179198
$invalidPackages++
180199
}
181200
}

.github/workflows/bump-version.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -79,9 +79,9 @@ jobs:
7979
git commit -m "Bump version`n`nBump version to ${env:NEXT_VERSION} for the next release." -s
8080
git push -u origin $branchName
8181
82-
"branch-name=${branchName}" >> $env:GITHUB_OUTPUT
83-
"updated-version=true" >> $env:GITHUB_OUTPUT
84-
"version=${env:NEXT_VERSION}" >> $env:GITHUB_OUTPUT
82+
"branch-name=${branchName}" >> ${env:GITHUB_OUTPUT}
83+
"updated-version=true" >> ${env:GITHUB_OUTPUT}
84+
"version=${env:NEXT_VERSION}" >> ${env:GITHUB_OUTPUT}
8585
8686
- name: Create pull request
8787
if: steps.push-changes.outputs.updated-version == 'true'

.github/workflows/release.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ jobs:
3939
$properties = Join-Path "." "Directory.Build.props"
4040
$xml = [xml](Get-Content $properties)
4141
$version = $xml.SelectSingleNode('Project/PropertyGroup/VersionPrefix').InnerText
42-
"version=${version}" >> $env:GITHUB_OUTPUT
42+
"version=${version}" >> ${env:GITHUB_OUTPUT}
4343
4444
- name: Create release
4545
uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0

build.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ if ($LASTEXITCODE -ne 0) {
1818

1919
$additionalArgs = @()
2020

21-
if (![string]::IsNullOrEmpty($env:GITHUB_SHA)) {
21+
if (![string]::IsNullOrEmpty(${env:GITHUB_SHA})) {
2222
$additionalArgs += "--logger:GitHubActions;report-warnings=false"
2323
$additionalArgs += "--logger:junit;LogFilePath=junit.xml"
2424
}

0 commit comments

Comments
 (0)