Skip to content

Switch build and test of CI/CD based on OS #166

Switch build and test of CI/CD based on OS

Switch build and test of CI/CD based on OS #166

Workflow file for this run

name: Webhooks CD
permissions:
contents: read
packages: write
on:
push:
branches: [ main ]
jobs:
build:
name: "Build and Test"
strategy:
fail-fast: true
matrix:
dotnet: [ '6.0.x', '7.0.x' ]
os: [ ubuntu-latest, windows-latest ]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- name: Setup .NET ${{ matrix.dotnet }}
uses: actions/setup-dotnet@v4
with:
dotnet-version: ${{ matrix.dotnet }}
- name: Set the TFM for .NET 6.0 in Ubuntu
if: matrix.dotnet == '6.0.x' && startsWith(matrix.os, 'ubuntu')
run: echo "DOTNET_TFM=net6.0" >> $GITHUB_ENV
- name: Set the TFM for .NET 7.0 in Ubuntu
if: matrix.dotnet == '7.0.x' && startsWith(matrix.os, 'ubuntu')
run: echo "DOTNET_TFM=net7.0" >> $GITHUB_ENV
- name: Set the TFM for .NET 8.0 in Ubuntu
if: matrix.dotnet == '8.0.x' && startsWith(matrix.os, 'ubuntu')
run: echo "DOTNET_TFM=net8.0" >> $GITHUB_ENV
- name: Restore dependencies
run: dotnet restore
- name: Build (Ubuntu)
if: startsWith(matrix.os, 'ubuntu')
run: dotnet build --no-restore -c Release -f ${{ env.DOTNET_TFM }}
- name: Build (Windows)
if: startsWith(matrix.os, 'windows')
run: dotnet build --no-restore -c Release -f $env:DOTNET_TFM
- name: Test (Ubuntu)
run: dotnet test --no-build --verbosity normal -c Release -f ${{ env.DOTNET_TFM }} /p:CollectCoverage=true /p:CoverletOutputFormat=opencover /p:Exclude="[*.XUnit]*"
- name: Test (Windows)
if: startsWith(matrix.os, 'windows')
run: dotnet test --no-build --verbosity normal -c Release -f $env:DOTNET_TFM /p:CollectCoverage=true /p:CoverletOutputFormat=opencover /p:Exclude="[*.XUnit]*"
- name: Collect to Codecov
uses: codecov/codecov-action@v3
with:
token: ${{ secrets.OCM_CODECOV_TOKEN }}
publish:
needs: build
name: "Pack"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Pack
run: dotnet pack --configuration Release --include-symbols --version-suffix $GITHUB_RUN_ID --output ./nuget
- name: Push Packages to GitHub NuGet
run: dotnet nuget push ./nuget/**/*.nupkg --skip-duplicate --api-key ${{secrets.GITHUB_TOKEN}} --source "https://nuget.pkg.github.com/deveel/index.json"
clean:
needs: publish
name: "Clean Old Packages"
uses: ./.github/workflows/clean-packages.yml