Skip to content

Add CI/CD pipeline and NuGet packaging improvements #9

Add CI/CD pipeline and NuGet packaging improvements

Add CI/CD pipeline and NuGet packaging improvements #9

Workflow file for this run

name: CI
on:
push:
branches: [main]
pull_request:
branches: [main]
workflow_dispatch:
env:
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true
DOTNET_CLI_TELEMETRY_OPTOUT: true
DOTNET_NOLOGO: true
jobs:
build:
name: Build & Test
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
steps:
- name: Checkout
uses: actions/checkout@v6
with:
fetch-depth: 0
- name: Setup .NET
uses: actions/setup-dotnet@v5
with:
dotnet-version: |
8.0.x
10.0.x
- name: Restore dependencies
run: dotnet restore
- name: Build
run: dotnet build --no-restore --configuration Release
- name: Test
run: dotnet test --no-build --configuration Release --verbosity normal --logger "trx;LogFileName=test-results.trx" --collect:"XPlat Code Coverage"
- name: Upload test results
uses: actions/upload-artifact@v6
if: always()
with:
name: test-results-${{ matrix.os }}
path: "**/TestResults/*.trx"
retention-days: 7
- name: Upload coverage
uses: actions/upload-artifact@v6
if: matrix.os == 'ubuntu-latest'
with:
name: coverage
path: "**/TestResults/**/coverage.cobertura.xml"
retention-days: 7
pack:
name: Pack NuGet
runs-on: ubuntu-latest
needs: build
steps:
- name: Checkout
uses: actions/checkout@v6
with:
fetch-depth: 0
- name: Setup .NET
uses: actions/setup-dotnet@v5
with:
dotnet-version: |
8.0.x
10.0.x
- name: Restore
run: dotnet restore
- name: Pack
run: dotnet pack --configuration Release --no-restore --output ./artifacts
- name: Upload NuGet package
uses: actions/upload-artifact@v6
with:
name: nuget-package
path: ./artifacts/*.nupkg
retention-days: 30
format-check:
name: Format Check
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v6
- name: Setup .NET
uses: actions/setup-dotnet@v5
with:
dotnet-version: 8.0.x
- name: Restore
run: dotnet restore
- name: Check formatting
run: dotnet format --verify-no-changes --verbosity diagnostic
security-scan:
name: Security Scan
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v6
- name: Setup .NET
uses: actions/setup-dotnet@v5
with:
dotnet-version: 8.0.x
- name: Restore
run: dotnet restore
- name: Run security scan
run: |
dotnet list package --vulnerable --include-transitive 2>&1 | tee vulnerabilities.txt
if grep -q "has the following vulnerable packages" vulnerabilities.txt; then
echo "::error::Vulnerable packages detected"
exit 1
fi