Skip to content

Add multi-targeting and GitHub Actions for auto NuGet publishing #3

Add multi-targeting and GitHub Actions for auto NuGet publishing

Add multi-targeting and GitHub Actions for auto NuGet publishing #3

Workflow file for this run

name: Publish NuGet Package
on:
push:
branches:
- main
tags:
- 'v*.*.*'
jobs:
publish:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Setup .NET SDK
uses: actions/setup-dotnet@v4
with:
dotnet-version: |
6.0.x
8.0.x
- name: Install GitVersion
uses: gittools/actions/gitversion/[email protected]
- name: Use GitVersion to get version info
id: gitversion
run: gitversion /output json /showvariable SemVer
- name: Restore dependencies
run: dotnet restore
- name: Build
run: dotnet build --configuration Release --no-restore
- name: Pack NuGet
run: dotnet pack --configuration Release -p:PackageVersion=${{ steps.gitversion.outputs.SemVer }} --no-build -o out
- name: Push to NuGet
if: success() && github.event_name == 'push'
run: dotnet nuget push out/*.nupkg --api-key ${{ secrets.NUGET_API_KEY }} --source https://api.nuget.org/v3/index.json