chore(deps): update dotnet monorepo #432
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: ci | |
on: | |
push: | |
branches: [ main ] | |
tags: [ '*' ] | |
paths-ignore: | |
- '**.md' | |
pull_request: | |
branches: [ main ] | |
workflow_dispatch: | |
env: | |
DOTNET_CLI_TELEMETRY_OPTOUT: true | |
DOTNET_NOLOGO: true | |
DOTNET_SYSTEM_CONSOLE_ALLOW_ANSI_COLOR_REDIRECTION: 1 | |
NUGET_XMLDOC_MODE: skip | |
TERM: xterm | |
permissions: {} | |
jobs: | |
build-test: | |
name: ${{ matrix.os-name }} | |
runs-on: ${{ matrix.runner }} | |
outputs: | |
dotnet-sdk-version: ${{ steps.setup-dotnet.outputs.dotnet-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 }} | |
permissions: | |
attestations: write | |
contents: write | |
id-token: write | |
strategy: | |
fail-fast: false | |
matrix: | |
include: | |
- os-name: macos | |
runner: macos-latest | |
- os-name: linux | |
runner: ubuntu-latest | |
- os-name: windows | |
runner: windows-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 | |
with: | |
fetch-depth: 0 | |
filter: 'tree:0' | |
show-progress: false | |
- name: Setup .NET SDK | |
uses: actions/setup-dotnet@d4c94342e560b34958eacfc5d055d21461ed1c5d # v5.0.0 | |
id: setup-dotnet | |
- name: Build | |
run: dotnet build --configuration Release | |
- name: Test | |
run: dotnet test --configuration Release --logger:"GitHubActions;report-warnings=false" | |
- name: Generate SBOM | |
uses: anchore/sbom-action@f8bdd1d8ac5e901a77a92f111440fdb1b593736b # v0.20.6 | |
if: runner.os == 'Windows' | |
with: | |
artifact-name: grafana-opentelemetry-dotnet.spdx.json | |
output-file: ./artifacts/grafana-opentelemetry-dotnet.spdx.json | |
path: ./artifacts/bin | |
upload-release-assets: true | |
- name: Attest artifacts | |
uses: actions/attest-build-provenance@977bb373ede98d70efdf65b84cb5f73e068dcc2a # v3.0.0 | |
if: | | |
runner.os == 'Windows' && | |
github.event.repository.fork == false && | |
(github.ref_name == github.event.repository.default_branch || startsWith(github.ref, 'refs/tags/')) | |
with: | |
subject-path: | | |
./artifacts/bin/Grafana.OpenTelemetry*/release*/Grafana.OpenTelemetry*.dll | |
./artifacts/package/release/* | |
- name: Publish NuGet packages | |
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2 | |
with: | |
name: packages-${{ matrix.os-name }} | |
path: ./artifacts/package/release | |
if-no-files-found: error | |
- name: Get .NET tools versions | |
id: get-dotnet-tools-versions | |
shell: pwsh | |
run: | | |
$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-test | |
runs-on: ubuntu-latest | |
steps: | |
- name: Download packages | |
uses: actions/download-artifact@634f93cb2916e3fdff6788551b99b062d0335ce0 # v5.0.0 | |
with: | |
name: packages-windows | |
- name: Setup .NET SDK | |
uses: actions/setup-dotnet@d4c94342e560b34958eacfc5d055d21461ed1c5d # v5.0.0 | |
with: | |
dotnet-version: ${{ needs.build-test.outputs.dotnet-sdk-version }} | |
- name: Install NuGet package validation tools | |
shell: pwsh | |
env: | |
DOTNET_VALIDATE_VERSION: ${{ needs.build-test.outputs.dotnet-validate-version }} | |
NUGET_PACKAGE_VALIDATION_VERSION: ${{ needs.build-test.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 | |
} | |
publish-feedz-io: | |
needs: [ build-test, validate-packages ] | |
runs-on: ubuntu-latest | |
if: | | |
github.event.repository.fork == false && | |
(github.ref_name == github.event.repository.default_branch || startsWith(github.ref, 'refs/tags/')) | |
environment: | |
name: feedz.io | |
permissions: | |
contents: read | |
id-token: write | |
steps: | |
- name: Download packages | |
uses: actions/download-artifact@634f93cb2916e3fdff6788551b99b062d0335ce0 # v5.0.0 | |
with: | |
name: packages-windows | |
- name: Setup .NET SDK | |
uses: actions/setup-dotnet@d4c94342e560b34958eacfc5d055d21461ed1c5d # v5.0.0 | |
with: | |
dotnet-version: ${{ needs.build-test.outputs.dotnet-sdk-version }} | |
- uses: grafana/shared-workflows/actions/get-vault-secrets@a37de51f3d713a30a9e4b21bcdfbd38170020593 # get-vault-secrets/v1.3.0 | |
id: get-token | |
with: | |
export_env: false | |
repo_secrets: | | |
token=feedz-io:token | |
- name: Push NuGet packages to feedz.io | |
shell: bash | |
env: | |
API_KEY: ${{ fromJSON(steps.get-token.outputs.secrets).token }} | |
SOURCE: 'https://f.feedz.io/${{ github.repository }}/nuget/index.json' | |
run: dotnet nuget push "*.nupkg" --api-key "${API_KEY}" --skip-duplicate --source "${SOURCE}" | |
publish-nuget: | |
needs: [ build-test, validate-packages ] | |
runs-on: ubuntu-latest | |
if: | | |
github.event.repository.fork == false && | |
startsWith(github.ref, 'refs/tags/') | |
environment: | |
name: NuGet.org | |
url: https://www.nuget.org/profiles/Grafana | |
permissions: | |
contents: read | |
id-token: write | |
steps: | |
- name: Download packages | |
uses: actions/download-artifact@634f93cb2916e3fdff6788551b99b062d0335ce0 # v5.0.0 | |
with: | |
name: packages-windows | |
- name: Setup .NET SDK | |
uses: actions/setup-dotnet@d4c94342e560b34958eacfc5d055d21461ed1c5d # v5.0.0 | |
with: | |
dotnet-version: ${{ needs.build-test.outputs.dotnet-sdk-version }} | |
- uses: grafana/shared-workflows/actions/get-vault-secrets@a37de51f3d713a30a9e4b21bcdfbd38170020593 # get-vault-secrets/v1.3.0 | |
id: get-user | |
with: | |
export_env: false | |
repo_secrets: | | |
user=nuget:user | |
- name: NuGet log in | |
uses: NuGet/login@d22cc5f58ff5b88bf9bd452535b4335137e24544 # v1.1.0 | |
id: nuget-login | |
with: | |
user: ${{ fromJSON(steps.get-user.outputs.secrets).user }} | |
- name: Push NuGet packages to NuGet.org | |
shell: bash | |
env: | |
API_KEY: ${{ steps.nuget-login.outputs.NUGET_API_KEY }} | |
SOURCE: 'https://api.nuget.org/v3/index.json' | |
run: dotnet nuget push "*.nupkg" --api-key "${API_KEY}" --skip-duplicate --source "${SOURCE}" |