Update main.yml #5
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
# 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 | |
- name: Run Unit Tests | |
run: dotnet test --no-build --verbosity normal --collect:"XPlat Code Coverage" | |
- name: Upload Code Coverage | |
uses: codecov/codecov-action@v3 | |
update_release_draft: | |
needs: build | |
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 }} |