In the modern era of DevOps, automation has become more popular, whereas creating/uploading packages has become a thing of the past. Moreover, day by day the packages count is increasing in a developer’s life. So, it is not easy to build, publish, and deploy all the packages manually on NuGet.org. We can manage a few packages (1-2) manually but, if we need to manage more packages (5,10 and so on), then it will become a tedious job.
Using GitHub's actions, we can make this process fully automatic.
Here is the step by step guide to automate, build, publish, and deploy (release) package to NuGet.
Step 1
Create a new repository on GitHub and upload your code.
Step 2
Create a GitHub Action, which makes it easy to build and publish. When we are creating a workflow, it creates a .yaml file. In this example, I am creating a workflow for .net core (c#).

Step 3
The previous step creates the workflow for .NET Core environment. It has a predefined structure which is a nice starting point for building and testing. It has the below sample code.
- name: .NET Core
- on:
- push:
- branches: [ master ]
- pull_request:
- branches: [ master ]
- jobs:
- build:
- runs-on: ubuntu-latest
- steps:
- - uses: actions/checkout@v2
- - name: Setup .NET Core
- uses: actions/setup-dotnet@v1
- with:
- dotnet-version: 3.1.101
- - name: Install dependencies
- run: dotnet restore
- - name: Build
- run: dotnet build --configuration Release --no-restore
- - name: Test
- run: dotnet test --no-restore --verbosity normal







Join the conversation! Your thoughts help the community grow.