Create workflow #1
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
name: Build And Create Nuget Package | |
on: | |
push: | |
branches: | |
- main | |
pull_request: | |
branches: | |
- main | |
release: | |
types: [created] | |
jobs: | |
build: | |
runs-on: ${{ matrix.os }} | |
strategy: | |
matrix: | |
os: [ 'ubuntu-24.04', 'windows-latest' ] | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Setup .NET | |
uses: actions/setup-dotnet@v4 | |
with: | |
dotnet-version: '8.0.x' | |
- name: Restore dependencies | |
run: dotnet restore src/**/*.csproj | |
- name: Build | |
run: dotnet build --no-restore -c Release src/**/*.csproj | |
publish: | |
runs-on: ubuntu-latest | |
needs: build | |
if: github.event_name == 'release' | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Setup .NET | |
uses: actions/setup-dotnet@v4 | |
with: | |
dotnet-version: '8.0.x' | |
- name: Restore dependencies | |
run: dotnet restore src/**/*.csproj | |
- name: Build | |
run: dotnet build --no-restore -c Release src/**/*.csproj | |
- name: Generate packages | |
run: dotnet pack --no-build --configuration Release src/**/*.csproj --output ./artifacts | |
- name: Publish to NuGet | |
run: dotnet nuget push artifacts/*.nupkg --source https://api.nuget.org/v3/index.json --api-key ${{ secrets.NUGET_API_KEY }} --skip-duplicate |