Skip to content

chore: define-matrix job writes the matrix to an environment file #3

chore: define-matrix job writes the matrix to an environment file

chore: define-matrix job writes the matrix to an environment file #3

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:
define-matrix:
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}
steps:
- id: set-matrix
run: |
echo 'matrix=["ubuntu-latest", "windows-latest"]' >> $GITHUB_ENV
setup:
needs: define-matrix
runs-on: ${{ fromJson(needs.define-matrix.outputs.matrix) }}
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: ${{ fromJson(needs.define-matrix.outputs.matrix) }}
steps:
- name: Build Project
run: dotnet build --no-restore
test:
needs: build
runs-on: ${{ fromJson(needs.define-matrix.outputs.matrix) }}
steps:
- name: Run Unit Tests
run: dotnet test --no-build --verbosity normal --collect:"XPlat Code Coverage"
upload-coverage:
needs: test
runs-on: ${{ fromJson(needs.define-matrix.outputs.matrix) }}
steps:
- name: Upload Code Coverage
uses: codecov/codecov-action@v3
update_release_draft:
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 }}