Skip to content

build

build #4

Workflow file for this run

name: Build and Publish
on:
push:
branches:
- main
tags:
- 'v*' # Matches version tags like v1.0.0
pull_request:
branches:
- main
jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
dotnet-version: [7.0.x, 8.0.x] # Include .NET 7 and .NET 8 versions
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Setup .NET
uses: actions/setup-dotnet@v3
with:
dotnet-version: 8.0.x
- name: Restore dependencies
run: dotnet restore
- name: Build
run: dotnet build --configuration Release --no-restore
- name: Run tests
run: dotnet test --configuration Release --no-restore --verbosity normal
- name: Pack NuGet package
run: dotnet pack --configuration Release --output ./artifacts
- name: Publish to NuGet (Pre-release or CI builds)
if: github.event_name == 'push' && contains(github.ref, 'refs/heads')
env:
NUGET_API_KEY: ${{ secrets.NUGET_API_KEY }}
run: dotnet nuget push ./artifacts/*.nupkg --api-key $NUGET_API_KEY --source https://api.nuget.org/v3/index.json
- name: Publish to NuGet (Release builds)
if: startsWith(github.ref, 'refs/tags')
env:
NUGET_API_KEY: ${{ secrets.NUGET_API_KEY }}
run: dotnet nuget push ./artifacts/*.nupkg --api-key $NUGET_API_KEY --source https://api.nuget.org/v3/index.json