|
| 1 | +name: ci |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: [ main ] |
| 6 | + paths-ignore: |
| 7 | + - '**.md' |
| 8 | + pull_request: |
| 9 | + branches: [ main ] |
| 10 | + workflow_dispatch: |
| 11 | + |
| 12 | +env: |
| 13 | + DOTNET_CLI_TELEMETRY_OPTOUT: true |
| 14 | + DOTNET_NOLOGO: true |
| 15 | + DOTNET_SYSTEM_CONSOLE_ALLOW_ANSI_COLOR_REDIRECTION: 1 |
| 16 | + NUGET_XMLDOC_MODE: skip |
| 17 | + TERM: xterm |
| 18 | + |
| 19 | +permissions: {} |
| 20 | + |
| 21 | +jobs: |
| 22 | + build-test: |
| 23 | + name: ${{ matrix.os }} |
| 24 | + runs-on: ${{ matrix.os }} |
| 25 | + |
| 26 | + outputs: |
| 27 | + dotnet-sdk-version: ${{ steps.setup-dotnet.outputs.dotnet-version }} |
| 28 | + |
| 29 | + permissions: |
| 30 | + attestations: write |
| 31 | + contents: write |
| 32 | + id-token: write |
| 33 | + |
| 34 | + strategy: |
| 35 | + fail-fast: false |
| 36 | + matrix: |
| 37 | + os: [ macos-latest, ubuntu-latest, windows-latest ] |
| 38 | + include: |
| 39 | + - os: macos-latest |
| 40 | + os-name: macos |
| 41 | + - os: ubuntu-latest |
| 42 | + os-name: linux |
| 43 | + - os: windows-latest |
| 44 | + os-name: windows |
| 45 | + |
| 46 | + steps: |
| 47 | + |
| 48 | + - name: Checkout code |
| 49 | + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 |
| 50 | + with: |
| 51 | + filter: 'tree:0' |
| 52 | + show-progress: false |
| 53 | + |
| 54 | + - name: Setup .NET SDK |
| 55 | + uses: actions/setup-dotnet@67a3573c9a986a3f9c594539f4ab511d57bb3ce9 # v4.3.1 |
| 56 | + id: setup-dotnet |
| 57 | + |
| 58 | + - name: Build |
| 59 | + run: dotnet build --configuration Release |
| 60 | + |
| 61 | + - name: Test |
| 62 | + run: dotnet test --configuration Release --logger:"GitHubActions;report-warnings=false" |
| 63 | + |
| 64 | + - name: Generate SBOM |
| 65 | + uses: anchore/sbom-action@9f7302141466aa6482940f15371237e9d9f4c34a # v0.19.0 |
| 66 | + with: |
| 67 | + artifact-name: build-${{ matrix.os-name }}.spdx.json |
| 68 | + output-file: ./artifacts/build.spdx.json |
| 69 | + path: ./artifacts/bin |
| 70 | + upload-release-assets: ${{ runner.os == 'Windows' }} |
| 71 | + |
| 72 | + - name: Attest artifacts |
| 73 | + uses: actions/attest-build-provenance@db473fddc028af60658334401dc6fa3ffd8669fd # v2.3.0 |
| 74 | + if: | |
| 75 | + runner.os == 'Windows' && |
| 76 | + github.event.repository.fork == false && |
| 77 | + (github.ref_name == github.event.repository.default_branch || startsWith(github.ref, 'refs/tags/')) |
| 78 | + with: |
| 79 | + subject-path: | |
| 80 | + ./artifacts/bin/Grafana.OpenTelemetry*/release*/Grafana.OpenTelemetry*.dll |
| 81 | + ./artifacts/package/release/* |
| 82 | +
|
| 83 | + - name: Publish NuGet packages |
| 84 | + uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2 |
| 85 | + with: |
| 86 | + name: packages-${{ matrix.os-name }} |
| 87 | + path: ./artifacts/package/release |
| 88 | + if-no-files-found: error |
| 89 | + |
| 90 | + validate-packages: |
| 91 | + needs: build-test |
| 92 | + runs-on: ubuntu-latest |
| 93 | + steps: |
| 94 | + |
| 95 | + - name: Download packages |
| 96 | + uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0 |
| 97 | + with: |
| 98 | + name: packages-windows |
| 99 | + |
| 100 | + - name: Setup .NET SDK |
| 101 | + uses: actions/setup-dotnet@67a3573c9a986a3f9c594539f4ab511d57bb3ce9 # v4.3.1 |
| 102 | + with: |
| 103 | + dotnet-version: ${{ needs.build-test.outputs.dotnet-sdk-version }} |
| 104 | + |
| 105 | + - name: Validate NuGet packages |
| 106 | + shell: pwsh |
| 107 | + run: | |
| 108 | + dotnet tool install --global dotnet-validate --version 0.0.1-preview.304 --allow-roll-forward |
| 109 | + $packages = Get-ChildItem -Filter "*.nupkg" | ForEach-Object { $_.FullName } |
| 110 | + $invalidPackages = 0 |
| 111 | + foreach ($package in $packages) { |
| 112 | + dotnet validate package local $package |
| 113 | + if ($LASTEXITCODE -ne 0) { |
| 114 | + $invalidPackages++ |
| 115 | + } |
| 116 | + } |
| 117 | + if ($invalidPackages -gt 0) { |
| 118 | + Write-Output "::error::$invalidPackages NuGet package(s) failed validation." |
| 119 | + exit 1 |
| 120 | + } |
0 commit comments