Skip to content

chore: simplify main workflow #4

chore: simplify main workflow

chore: simplify main workflow #4

Workflow file for this run

# This workflow triggers on pushes to the main branch.
# It builds the project, runs tests to ensure stability and creates a release draft.
name: Main Branch CI
on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]
permissions:
contents: read
jobs:
setup:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, windows-latest]
dotnet: ['7.x', '8.x']
steps:
- name: Checkout Source Code
uses: actions/checkout@v3
- name: Setup .NET
uses: actions/setup-dotnet@v3
with:
dotnet-version: ${{ matrix.dotnet }}
- name: Cache NuGet packages
uses: actions/cache@v3
with:
path: ~/.nuget/packages
key: ${{ runner.os }}-nuget-${{ hashFiles('**/packages.lock.json') }}
restore-keys: |
${{ runner.os }}-nuget-
- name: Restore dependencies
run: dotnet restore
build:
needs: setup
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, windows-latest]
dotnet: ['7.x', '8.x']
steps:
- name: Build Project
run: dotnet build --no-restore
test:
needs: build
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, windows-latest]
dotnet: ['7.x', '8.x']
steps:
- name: Run Unit Tests
run: dotnet test --no-build --verbosity normal --collect:"XPlat Code Coverage"
upload-coverage:
needs: test
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, windows-latest]
dotnet: ['7.x', '8.x']
steps:
- name: Upload Code Coverage
uses: codecov/codecov-action@v3
update_release_draft:
needs: upload-coverage
permissions:
contents: write
pull-requests: write
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/main'
steps:
- uses: release-drafter/release-drafter@v5
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}