chore: decorate dotnet version in ci name #125
This file contains 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: | |
# Trigger the workflow on push or pull request, | |
# but only for the master branch | |
push: | |
branches: | |
- master | |
paths: | |
- '.github/**' | |
- 'src/**' | |
- build.cake | |
- CodeCoverage.runsettings | |
- dotnet-tools.json | |
- global.json | |
- Key.snk | |
- Paseto.sln | |
pull_request: | |
branches: | |
- master | |
paths: | |
- 'src/**' | |
- build.cake | |
- CodeCoverage.runsettings | |
- dotnet-tools.json | |
- global.json | |
- Key.snk | |
- Paseto.sln | |
release: | |
types: | |
- published | |
env: | |
# Disable the .NET logo in the console output. | |
DOTNET_NOLOGO: true | |
# Set the DOTNET_SKIP_FIRST_TIME_EXPERIENCE environment variable to stop wasting time caching packages | |
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true | |
# Disable sending usage data to Microsoft | |
DOTNET_CLI_TELEMETRY_OPTOUT: true | |
# Set the build number in MinVer | |
MINVERBUILDMETADATA: build.${{github.run_number}} | |
# Set artifacts directory | |
BUILD_ARTIFACT_PATH: './Artifacts' | |
jobs: | |
build: | |
name: Build on ${{matrix.os}} with .NET ${{ matrix.dotnet }} | |
runs-on: ${{matrix.os}} | |
strategy: | |
matrix: | |
os: [ubuntu-latest, windows-latest, macOS-latest] | |
dotnet: [ '6.0.x', '8.0.x' ] | |
steps: | |
- name: 'Checkout' | |
uses: actions/checkout@v4 | |
- name: 'Git Fetch Tags' | |
run: git fetch --tags | |
- name: 'Install .NET SDK' | |
uses: actions/setup-dotnet@v4 | |
with: | |
dotnet-version: ${{ matrix.dotnet }} | |
- name: '.NET Restore' | |
run: dotnet tool restore | |
- name: 'Build Project' | |
run: dotnet cake --target=Build | |
- name: 'Run Unit Tests' | |
run: dotnet cake --target=Test | |
- name: 'Run Unit Tests' | |
run: dotnet test -f net8.0 --no-restore --logger trx -r ${{env.BUILD_ARTIFACT_PATH}} --settings "CodeCoverage.runsettings" | |
if: ${{ false }} # always skip since coverage is somehow always empty in GitHub Actions | |
- name: 'Run Test Report' | |
uses: zyborg/dotnet-tests-report@v1 | |
with: | |
project_path: tests/Paseto.Tests | |
report_name: paseto_dotnet_tests | |
report_title: Paseto.NET Tests | |
github_token: ${{ secrets.GITHUB_TOKEN }} | |
gist_name: paseto_dotnet_tests.md | |
gist_badge_label: 'Paseto Tests: %Counters_passed%/%Counters_total%' | |
gist_token: ${{ secrets.GIST_TOKEN }} | |
if: ${{ false }} # always skip due to 65K limit | |
- name: 'Pack NuGet' | |
run: dotnet cake --target=Pack | |
- name: 'Publish Artifacts' | |
uses: actions/upload-artifact@v4 | |
with: | |
name: ${{matrix.os}} | |
path: | | |
${{env.BUILD_ARTIFACT_PATH}} | |
!${{env.BUILD_ARTIFACT_PATH}}/**/In/**/* | |
coverage: | |
name: 'Process Coverage' | |
runs-on: ubuntu-latest | |
needs: build | |
steps: | |
- name: 'Checkout' | |
uses: actions/checkout@v4 | |
- name: 'Download Artifact' | |
uses: actions/download-artifact@v4 | |
with: | |
name: 'ubuntu-latest' | |
- name: 'Install ReportGenerator' | |
run: dotnet tool install -g dotnet-reportgenerator-globaltool | |
- name: 'Generate Coverage Report' | |
run: reportgenerator -reports:./TestResults/**/coverage.cobertura.xml -targetdir:${{env.BUILD_ARTIFACT_PATH}}/TestResults/Coverage/Reports "-reporttypes:HtmlInline;HTMLChart;Cobertura" | |
- name: 'Upload Coverage' | |
uses: codecov/codecov-action@v4 | |
with: | |
file: Cobertura.xml | |
fail_ci_if_error: false | |
- name: 'Publish Coverage Report' | |
uses: actions/upload-artifact@v4 | |
with: | |
name: 'coverage-report' | |
path: ${{env.BUILD_ARTIFACT_PATH}} | |
benchmark: | |
name: 'Execute Benchmarks' | |
runs-on: ubuntu-latest | |
needs: coverage | |
steps: | |
- name: 'Checkout' | |
uses: actions/checkout@v4 | |
- name: 'Run Benchmarks' | |
run: cd benchmarks/Paseto.Benchmark && dotnet run -f net8.0 -c Release --exporters json --filter '*' | |
- name: 'Store Benchmark Result' | |
uses: rhysd/github-action-benchmark@v1 | |
with: | |
name: Benchmark.Net Benchmark | |
tool: 'benchmarkdotnet' | |
output-file-path: benchmarks/Paseto.Benchmark/BenchmarkDotNet.Artifacts/results/Benchmarks-report-full-compressed.json | |
auto-push: false | |
if: ${{ false }} # always skip for now | |
- name: 'Push Benchmark Result' | |
run: git push 'https://daviddesmet:${{ secrets.GITHUB_TOKEN }}@github.com/daviddesmet/paseto-dotnet.git' gh-pages:gh-pages | |
if: ${{ false }} # always skip for now | |
push-to-github-packages: | |
name: 'Push GitHub Packages' | |
needs: build | |
if: github.ref == 'refs/heads/master' || github.event_name == 'release' | |
environment: | |
name: 'GitHub Packages' | |
url: https://github.com/daviddesmet/paseto-dotnet/packages | |
permissions: | |
packages: write | |
runs-on: windows-latest | |
steps: | |
- name: 'Download Artifact' | |
uses: actions/download-artifact@v4 | |
with: | |
name: 'windows-latest' | |
- name: 'NuGet Push' | |
run: dotnet nuget push *.nupkg --source https://nuget.pkg.github.com/daviddesmet/index.json --skip-duplicate --api-key ${{secrets.GITHUB_TOKEN}} | |
push-to-nuget: | |
name: 'Push NuGet Packages' | |
needs: build | |
if: github.event_name == 'release' | |
environment: | |
name: 'NuGet' | |
url: https://www.nuget.org/packages/Paseto.Core | |
runs-on: windows-latest | |
steps: | |
- name: 'Download Artifact' | |
uses: actions/download-artifact@v4 | |
with: | |
name: 'windows-latest' | |
- name: 'NuGet Push' | |
run: | | |
Get-ChildItem . -Filter *.nupkg | | |
Where-Object { !$_.Name.Contains('preview') } | | |
ForEach-Object { dotnet nuget push $_ --source https://api.nuget.org/v3/index.json --skip-duplicate --api-key ${{secrets.NUGET_API_KEY}} } | |
shell: pwsh |