diff --git a/.config/dotnet-tools.json b/.config/dotnet-tools.json index ff246d94..37c5ff05 100644 --- a/.config/dotnet-tools.json +++ b/.config/dotnet-tools.json @@ -6,7 +6,15 @@ "version": "0.0.1-preview.537", "commands": [ "dotnet-validate" - ] + ], + "rollForward": false + }, + "meziantou.framework.nugetpackagevalidation.tool": { + "version": "1.0.31", + "commands": [ + "meziantou.validate-nuget-package" + ], + "rollForward": false } } } \ No newline at end of file diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 2e2f4eb9..826db910 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -29,7 +29,8 @@ jobs: outputs: dotnet-sdk-version: ${{ steps.setup-dotnet.outputs.dotnet-version }} - dotnet-validate-version: ${{ steps.get-dotnet-validate-version.outputs.dotnet-validate-version }} + dotnet-validate-version: ${{ steps.get-dotnet-tools-versions.outputs.dotnet-validate-version }} + nuget-package-validation-version: ${{ steps.get-dotnet-tools-versions.outputs.nuget-package-validation-version }} package-names: ${{ steps.build.outputs.package-names }} package-version: ${{ steps.build.outputs.package-version }} @@ -113,12 +114,15 @@ jobs: path: ./artifacts/package/release if-no-files-found: error - - name: Get dotnet-validate version - id: get-dotnet-validate-version + - name: Get .NET tools versions + id: get-dotnet-tools-versions shell: pwsh run: | - $dotnetValidateVersion = (Get-Content "./.config/dotnet-tools.json" | Out-String | ConvertFrom-Json).tools.'dotnet-validate'.version - "dotnet-validate-version=${dotnetValidateVersion}" >> $env:GITHUB_OUTPUT + $manifest = (Get-Content "./.config/dotnet-tools.json" | Out-String | ConvertFrom-Json) + $dotnetValidateVersion = $manifest.tools.'dotnet-validate'.version + $nugetPackageValidationVersion = $manifest.tools.'meziantou.framework.nugetpackagevalidation.tool'.version + "dotnet-validate-version=${dotnetValidateVersion}" >> ${env:GITHUB_OUTPUT} + "nuget-package-validation-version=${nugetPackageValidationVersion}" >> ${env:GITHUB_OUTPUT} validate-packages: needs: build @@ -135,17 +139,33 @@ jobs: with: dotnet-version: ${{ needs.build.outputs.dotnet-sdk-version }} - - name: Validate NuGet packages + - name: Install NuGet package validation tools shell: pwsh env: DOTNET_VALIDATE_VERSION: ${{ needs.build.outputs.dotnet-validate-version }} + NUGET_PACKAGE_VALIDATION_VERSION: ${{ needs.build.outputs.nuget-package-validation-version }} run: | dotnet tool install --global dotnet-validate --version ${env:DOTNET_VALIDATE_VERSION} --allow-roll-forward + dotnet tool install --global Meziantou.Framework.NuGetPackageValidation.Tool --version ${env:NUGET_PACKAGE_VALIDATION_VERSION} --allow-roll-forward + + - name: Validate NuGet packages + shell: pwsh + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | $packages = Get-ChildItem -Filter "*.nupkg" | ForEach-Object { $_.FullName } $invalidPackages = 0 foreach ($package in $packages) { + $isValid = $true dotnet validate package local $package if ($LASTEXITCODE -ne 0) { + $isValid = $false + } + meziantou.validate-nuget-package $package --github-token ${env:GH_TOKEN} + if ($LASTEXITCODE -ne 0) { + $isValid = $false + } + if (-Not $isValid) { $invalidPackages++ } } diff --git a/.github/workflows/bump-version.yml b/.github/workflows/bump-version.yml index 58582a88..dbd8a6d0 100644 --- a/.github/workflows/bump-version.yml +++ b/.github/workflows/bump-version.yml @@ -74,7 +74,7 @@ jobs: "" >> $properties - "version=${updatedVersion}" >> $env:GITHUB_OUTPUT + "version=${updatedVersion}" >> ${env:GITHUB_OUTPUT} - name: Push changes to GitHub id: push-changes @@ -110,9 +110,9 @@ jobs: git commit -m "Bump version`n`nBump version to ${env:NEXT_VERSION} for the next release." -s git push -u origin $branchName - "branch-name=${branchName}" >> $env:GITHUB_OUTPUT - "updated-version=true" >> $env:GITHUB_OUTPUT - "version=${env:NEXT_VERSION}" >> $env:GITHUB_OUTPUT + "branch-name=${branchName}" >> ${env:GITHUB_OUTPUT} + "updated-version=true" >> ${env:GITHUB_OUTPUT} + "version=${env:NEXT_VERSION}" >> ${env:GITHUB_OUTPUT} - name: Create pull request if: steps.push-changes.outputs.updated-version == 'true' diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 23049c90..7ed02a0e 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -36,7 +36,7 @@ jobs: $properties = Join-Path "." "Directory.Build.props" $xml = [xml](Get-Content $properties) $version = $xml.SelectSingleNode('Project/PropertyGroup/VersionPrefix').InnerText - "version=${version}" >> $env:GITHUB_OUTPUT + "version=${version}" >> ${env:GITHUB_OUTPUT} - name: Create release uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0 diff --git a/build.ps1 b/build.ps1 index 3e80cfc1..01f4f51b 100755 --- a/build.ps1 +++ b/build.ps1 @@ -89,7 +89,7 @@ function DotNetTest { $additionalArgs = @() - if (-Not [string]::IsNullOrEmpty($env:GITHUB_SHA)) { + if (-Not [string]::IsNullOrEmpty(${env:GITHUB_SHA})) { $additionalArgs += "--logger:GitHubActions;report-warnings=false" $additionalArgs += "--logger:junit;LogFilePath=junit.xml" }