I have a GitHub repo that I'd like to automatically compile and publish to NuGet when a commit is pushed.
I have a package that I publish using GitHub actions, here's a snap of the code and a reference link to the complete code. What you need to do is dotnet pack and dotnet push the package. You also need to set the token secret in Git Hub.
- name: Pack
run: dotnet pack --configuration Release /p:Version=${VERSION} --no-build --output .
- name: Push
run: dotnet nuget push PackageName.${VERSION}.nupkg --source https://api.nuget.org/v3/index.json --api-key ${NUGET_TOKEN}
env:
NUGET_TOKEN: ${{ secrets.NUGET_TOKEN }}
Reference to the complete code.