Bump meziantou.framework.nugetpackagevalidation.tool from 1.0.34 to 1… #5134
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: build | |
| on: | |
| push: | |
| branches: | |
| - main | |
| - release/* | |
| tags: [ '*' ] | |
| pull_request: | |
| branches: | |
| - main | |
| - release/* | |
| - dotnet-vnext | |
| workflow_dispatch: | |
| env: | |
| DOTNET_CLI_TELEMETRY_OPTOUT: true | |
| DOTNET_GENERATE_ASPNET_CERTIFICATE: false | |
| DOTNET_NOLOGO: true | |
| DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true | |
| DOTNET_SYSTEM_CONSOLE_ALLOW_ANSI_COLOR_REDIRECTION: 1 | |
| NUGET_XMLDOC_MODE: skip | |
| TERM: xterm | |
| permissions: {} | |
| jobs: | |
| build: | |
| name: ${{ matrix.os }} | |
| runs-on: ${{ matrix.os }} | |
| timeout-minutes: 20 | |
| outputs: | |
| authenticodelint-version: ${{ steps.get-dotnet-tools-versions.outputs.authenticodelint-version }} | |
| dotnet-sdk-version: ${{ steps.setup-dotnet.outputs.dotnet-version }} | |
| dotnet-sign-version: ${{ steps.get-dotnet-tools-versions.outputs.dotnet-sign-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 }} | |
| permissions: | |
| actions: read | |
| contents: write | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| os: [ windows-latest ] | |
| include: | |
| - os: macos-latest | |
| os_name: macos | |
| - os: ubuntu-latest | |
| os_name: linux | |
| - os: windows-latest | |
| os_name: windows | |
| steps: | |
| - name: Update agent configuration | |
| shell: pwsh | |
| run: | | |
| if ($IsWindows) { | |
| "DOTNET_INSTALL_DIR=D:\tools\dotnet" >> ${env:GITHUB_ENV} | |
| "DOTNET_ROOT=D:\tools\dotnet" >> ${env:GITHUB_ENV} | |
| "NUGET_PACKAGES=D:\.nuget\packages" >> ${env:GITHUB_ENV} | |
| } else { | |
| $nugetHome = "~/.nuget/packages" | |
| if (-Not (Test-Path $nugetHome)) { | |
| New-Item -Path $nugetHome -Type Directory -Force | Out-Null | |
| } | |
| $nugetHome = Resolve-Path $nugetHome | |
| "NUGET_PACKAGES=$nugetHome" >> ${env:GITHUB_ENV} | |
| } | |
| - name: Checkout code | |
| uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 | |
| with: | |
| fetch-depth: 0 | |
| persist-credentials: false | |
| show-progress: false | |
| - name: Setup .NET SDKs | |
| uses: actions/setup-dotnet@d4c94342e560b34958eacfc5d055d21461ed1c5d # v5.0.0 | |
| with: | |
| dotnet-version: | | |
| 8.0.x | |
| - name: Setup .NET SDK | |
| uses: actions/setup-dotnet@d4c94342e560b34958eacfc5d055d21461ed1c5d # v5.0.0 | |
| id: setup-dotnet | |
| - name: Build, Test and Package | |
| id: build | |
| shell: pwsh | |
| run: ./build.ps1 | |
| - name: Upload Coverage Reports | |
| if: always() | |
| uses: actions/upload-artifact@330a01c490aca151604b8cf639adc76d48f6c5d4 # v5.0.0 | |
| with: | |
| name: coverage-${{ matrix.os_name }} | |
| path: ./artifacts/coverage-reports | |
| if-no-files-found: ignore | |
| - name: Upload coverage to Codecov | |
| if: always() && github.event.repository.fork == false | |
| uses: codecov/codecov-action@5a1091511ad55cbe89839c7260b706298ca349f7 # v5.5.1 | |
| with: | |
| flags: ${{ matrix.os_name }} | |
| token: ${{ secrets.CODECOV_TOKEN }} | |
| - name: Upload test results to Codecov | |
| uses: codecov/test-results-action@47f89e9acb64b76debcd5ea40642d25a4adced9f # v1.1.1 | |
| if: ${{ !cancelled() }} | |
| with: | |
| flags: ${{ matrix.os_name }} | |
| token: ${{ secrets.CODECOV_TOKEN }} | |
| - name: Publish NuGet packages | |
| uses: actions/upload-artifact@330a01c490aca151604b8cf639adc76d48f6c5d4 # v5.0.0 | |
| with: | |
| name: packages-${{ matrix.os_name }} | |
| path: ./artifacts/package/release | |
| if-no-files-found: error | |
| - name: Upload signing file list | |
| uses: actions/upload-artifact@330a01c490aca151604b8cf639adc76d48f6c5d4 # v5.0.0 | |
| if: matrix.os_name == 'windows' | |
| with: | |
| name: signing-config | |
| path: eng/signing | |
| if-no-files-found: error | |
| - name: Generate SBOM | |
| uses: anchore/sbom-action@8e94d75ddd33f69f691467e42275782e4bfefe84 # v0.20.9 | |
| if: runner.os == 'Windows' | |
| with: | |
| artifact-name: polly.spdx.json | |
| output-file: ./artifacts/polly.spdx.json | |
| path: ./artifacts/bin | |
| upload-release-assets: true | |
| - name: Get .NET tools versions | |
| id: get-dotnet-tools-versions | |
| shell: pwsh | |
| run: | | |
| $manifest = (Get-Content "./.config/dotnet-tools.json" | Out-String | ConvertFrom-Json) | |
| $authenticodelintVersion = $manifest.tools.authenticodelint.version | |
| $dotnetSignVersion = $manifest.tools.sign.version | |
| $dotnetValidateVersion = $manifest.tools.'dotnet-validate'.version | |
| $nugetPackageValidationVersion = $manifest.tools.'meziantou.framework.nugetpackagevalidation.tool'.version | |
| "authenticodelint-version=${authenticodelintVersion}" >> ${env:GITHUB_OUTPUT} | |
| "dotnet-sign-version=${dotnetSignVersion}" >> ${env:GITHUB_OUTPUT} | |
| "dotnet-validate-version=${dotnetValidateVersion}" >> ${env:GITHUB_OUTPUT} | |
| "nuget-package-validation-version=${nugetPackageValidationVersion}" >> ${env:GITHUB_OUTPUT} | |
| validate-packages: | |
| needs: build | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Download packages | |
| uses: actions/download-artifact@018cc2cf5baa6db3ef3c5f8a56943fffe632ef53 # v6.0.0 | |
| with: | |
| name: packages-windows | |
| - name: Setup .NET SDK | |
| uses: actions/setup-dotnet@d4c94342e560b34958eacfc5d055d21461ed1c5d # v5.0.0 | |
| with: | |
| dotnet-version: ${{ needs.build.outputs.dotnet-sdk-version }} | |
| - 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++ | |
| } | |
| } | |
| if ($invalidPackages -gt 0) { | |
| Write-Output "::error::$invalidPackages NuGet package(s) failed validation." | |
| exit 1 | |
| } | |
| sign: | |
| needs: [ build, validate-packages ] | |
| runs-on: windows-latest | |
| if: | | |
| github.event.repository.fork == false && | |
| startsWith(github.ref, 'refs/tags/') | |
| environment: | |
| name: Azure | |
| permissions: | |
| id-token: write | |
| steps: | |
| - name: Download unsigned packages | |
| uses: actions/download-artifact@018cc2cf5baa6db3ef3c5f8a56943fffe632ef53 # v6.0.0 | |
| with: | |
| name: packages-windows | |
| path: packages | |
| - name: Download signing configuration | |
| uses: actions/download-artifact@018cc2cf5baa6db3ef3c5f8a56943fffe632ef53 # v6.0.0 | |
| with: | |
| name: signing-config | |
| path: signing-config | |
| - name: Setup .NET SDK | |
| uses: actions/setup-dotnet@d4c94342e560b34958eacfc5d055d21461ed1c5d # v5.0.0 | |
| with: | |
| dotnet-version: ${{ needs.build.outputs.dotnet-sdk-version }} | |
| - name: Install Sign CLI tool | |
| env: | |
| DOTNET_SIGN_VERSION: ${{ needs.build.outputs.dotnet-sign-version }} | |
| run: dotnet tool install --tool-path . sign --version ${env:DOTNET_SIGN_VERSION} | |
| - name: Azure log in | |
| uses: azure/login@a457da9ea143d694b1b9c7c869ebb04ebe844ef5 # v2.3.0 | |
| with: | |
| client-id: ${{ secrets.SIGN_CLI_APPLICATION_ID }} | |
| subscription-id: ${{ secrets.SIGN_CLI_SUBSCRIPTION_ID }} | |
| tenant-id: ${{ secrets.SIGN_CLI_TENANT_ID }} | |
| - name: Sign artifacts | |
| shell: pwsh | |
| env: | |
| AZURE_KEY_VAULT_CERTIFICATE: ${{ secrets.SIGN_CLI_CERT_NAME }} | |
| AZURE_KEY_VAULT_URL: ${{ secrets.SIGN_CLI_VAULT_URI }} | |
| VERBOSITY: ${{ runner.debug == '1' && 'Debug' || 'Warning' }} | |
| run: | | |
| ./sign code azure-key-vault ` | |
| **/*.nupkg ` | |
| --base-directory "${env:GITHUB_WORKSPACE}/packages" ` | |
| --file-list "${env:GITHUB_WORKSPACE}/signing-config/filelist.txt" ` | |
| --application-name "Polly" ` | |
| --publisher-name "App vNext" ` | |
| --description "Polly" ` | |
| --description-url "https://github.com/${env:GITHUB_REPOSITORY}" ` | |
| --azure-key-vault-certificate ${env:AZURE_KEY_VAULT_CERTIFICATE} ` | |
| --azure-key-vault-url ${env:AZURE_KEY_VAULT_URL} ` | |
| --verbosity "${env:VERBOSITY}" | |
| if ($LASTEXITCODE -ne 0) { | |
| Write-Output "::error::Failed to sign NuGet packages" | |
| exit 1 | |
| } | |
| - name: Upload signed packages | |
| uses: actions/upload-artifact@330a01c490aca151604b8cf639adc76d48f6c5d4 # v5.0.0 | |
| with: | |
| name: signed-packages | |
| path: packages | |
| if-no-files-found: error | |
| validate-signed-packages: | |
| needs: [ build, sign ] | |
| runs-on: windows-latest | |
| permissions: | |
| attestations: write | |
| contents: read | |
| id-token: write | |
| steps: | |
| - name: Download packages | |
| uses: actions/download-artifact@018cc2cf5baa6db3ef3c5f8a56943fffe632ef53 # v6.0.0 | |
| with: | |
| name: signed-packages | |
| - name: Download SBOM | |
| uses: actions/download-artifact@018cc2cf5baa6db3ef3c5f8a56943fffe632ef53 # v6.0.0 | |
| with: | |
| name: polly.spdx.json | |
| path: ./artifacts | |
| - name: Setup .NET SDK | |
| uses: actions/setup-dotnet@d4c94342e560b34958eacfc5d055d21461ed1c5d # v5.0.0 | |
| with: | |
| dotnet-version: ${{ needs.build.outputs.dotnet-sdk-version }} | |
| - name: Validate NuGet packages | |
| shell: pwsh | |
| env: | |
| DOTNET_VALIDATE_VERSION: ${{ needs.build.outputs.dotnet-validate-version }} | |
| run: | | |
| dotnet tool install --global dotnet-validate --version ${env:DOTNET_VALIDATE_VERSION} --allow-roll-forward | |
| if ($LASTEXITCODE -ne 0) { | |
| Write-Output "::error::Failed to install dotnet-validate tool." | |
| exit 1 | |
| } | |
| $packages = Get-ChildItem -Filter "*.nupkg" | ForEach-Object { $_.FullName } | |
| $invalidPackages = 0 | |
| foreach ($package in $packages) { | |
| dotnet validate package local $package | |
| if ($LASTEXITCODE -ne 0) { | |
| $invalidPackages++ | |
| } | |
| } | |
| if ($invalidPackages -gt 0) { | |
| Write-Output "::error::$invalidPackages NuGet package(s) failed validation." | |
| exit 1 | |
| } | |
| - name: Validate signatures | |
| shell: pwsh | |
| env: | |
| AUTHENTICODELINT_VERSION: ${{ needs.build.outputs.authenticodelint-version }} | |
| run: | | |
| dotnet tool install --global AuthenticodeLint --version ${env:AUTHENTICODELINT_VERSION} --allow-roll-forward | |
| if ($LASTEXITCODE -ne 0) { | |
| Write-Output "::error::Failed to install AuthenticodeLint tool." | |
| exit 1 | |
| } | |
| $packages = Get-ChildItem -Filter "*.nupkg" | ForEach-Object { $_.FullName } | |
| $invalidPackages = 0 | |
| foreach ($package in $packages) { | |
| $packageName = Split-Path $package -Leaf | |
| $extractedNupkg = Join-Path "." "extracted" $packageName | |
| Expand-Archive -Path $package -DestinationPath $extractedNupkg -Force | |
| $dlls = Get-ChildItem -Path $extractedNupkg -Filter "*.dll" -Recurse | ForEach-Object { $_.FullName } | |
| $invalidDlls = 0 | |
| foreach ($dll in $dlls) { | |
| authlint -in $dll -verbose | |
| if ($LASTEXITCODE -ne 0) { | |
| Write-Output "::warning::$dll in NuGet package $package failed signature validation." | |
| $invalidDlls++ | |
| } else { | |
| Write-Output "$dll in NuGet package $package has a valid signature." | |
| } | |
| } | |
| if ($invalidDlls -gt 0) { | |
| $invalidPackages++ | |
| } else { | |
| Write-Output "All $($dlls.Length) DLLs in NuGet package $package have valid signatures." | |
| } | |
| dotnet nuget verify $package | |
| if ($LASTEXITCODE -ne 0) { | |
| Write-Output "::warning::$package failed signature validation." | |
| $invalidPackages++ | |
| } else { | |
| Write-Output "$package has a valid signature." | |
| } | |
| } | |
| if ($invalidPackages -gt 0) { | |
| Write-Output "::error::$invalidPackages NuGet package(s) failed signature validation." | |
| exit 1 | |
| } else { | |
| Write-Output "All $($packages.Length) NuGet packages have valid signatures." | |
| } | |
| - name: Extract NuGet package contents | |
| shell: pwsh | |
| run: | | |
| $packages = Get-ChildItem -Filter "*.nupkg" | ForEach-Object { $_.FullName } | |
| $artifactsPath = Join-Path ${env:GITHUB_WORKSPACE} "artifacts" | |
| foreach ($package in $packages) { | |
| $packageName = [System.IO.Path]::GetFileNameWithoutExtension($package) | |
| $packagePath = Join-Path $artifactsPath $packageName | |
| if (-Not (Test-Path -Path $packagePath)) { | |
| New-Item -ItemType Directory -Path $packagePath | Out-Null | |
| } | |
| Expand-Archive -Path $package -DestinationPath $packagePath -Force | Out-Null | |
| } | |
| - name: Attest artifacts | |
| uses: actions/attest-build-provenance@977bb373ede98d70efdf65b84cb5f73e068dcc2a # v3.0.0 | |
| with: | |
| subject-path: | | |
| ./artifacts/polly.spdx.json | |
| ./artifacts/*/lib/**/* | |
| publish-nuget: | |
| needs: [ build, validate-signed-packages ] | |
| runs-on: ubuntu-latest | |
| environment: | |
| name: NuGet.org | |
| url: https://www.nuget.org/profiles/Polly | |
| permissions: | |
| id-token: write | |
| steps: | |
| - name: Download signed packages | |
| uses: actions/download-artifact@018cc2cf5baa6db3ef3c5f8a56943fffe632ef53 # v6.0.0 | |
| with: | |
| name: signed-packages | |
| - name: Setup .NET SDK | |
| uses: actions/setup-dotnet@d4c94342e560b34958eacfc5d055d21461ed1c5d # v5.0.0 | |
| with: | |
| dotnet-version: ${{ needs.build.outputs.dotnet-sdk-version }} | |
| - name: NuGet log in | |
| uses: NuGet/login@d22cc5f58ff5b88bf9bd452535b4335137e24544 # v1.1.0 | |
| id: nuget-login | |
| with: | |
| user: ${{ secrets.NUGET_USER }} | |
| - name: Push signed NuGet packages to NuGet.org | |
| env: | |
| API_KEY: ${{ steps.nuget-login.outputs.NUGET_API_KEY }} | |
| PACKAGE_VERSION: ${{ needs.build.outputs.package-version }} | |
| SOURCE: https://api.nuget.org/v3/index.json | |
| run: dotnet nuget push "*.nupkg" --api-key "${API_KEY}" --skip-duplicate --source "${SOURCE}" && echo "::notice title=nuget.org::Published version ${PACKAGE_VERSION} to NuGet.org." | |
| - name: Generate GitHub application token | |
| id: generate-application-token | |
| uses: actions/create-github-app-token@67018539274d69449ef7c02e8e71183d1719ab42 # v2.1.4 | |
| with: | |
| app-id: ${{ secrets.POLLY_UPDATER_BOT_APP_ID }} | |
| private-key: ${{ secrets.POLLY_UPDATER_BOT_KEY }} | |
| permission-contents: write | |
| - name: Publish nuget_packages_published | |
| uses: peter-evans/repository-dispatch@5fc4efd1a4797ddb68ffd0714a238564e4cc0e6f # v4.0.0 | |
| with: | |
| event-type: nuget_packages_published | |
| token: ${{ steps.generate-application-token.outputs.token }} | |
| client-payload: |- | |
| { | |
| "packages": "${{ needs.build.outputs.package-names }}", | |
| "version": "${{ needs.build.outputs.package-version }}" | |
| } |