Github action to publish a Nuget package to nuget.org

alandecastros

Alan Castro

Posted on May 24, 2020

Github action to publish a Nuget package to nuget.org

Here is the .github/workflows/nuget.yml that I use to deploy my Nuget packages to nuget.org in Github.

Just change YOUR_PROJECT to the path of your .csproj file and create a secret called NUGET_API_KEY at your github project.

name: Nuget Package action name

on:
  push:
    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: Build with dotnet
      run: dotnet build --configuration Release
    - name: Test with dotnet
      run: dotnet test
    - name: Pack with dotnet
      run: dotnet pack YOUR_PROJECT.csproj --output nuget-packages --configuration Release
    - name: Push with dotnet
      run: dotnet nuget push nuget-packages/*.nupkg --api-key ${{ secrets.NUGET_API_KEY }} --source https://api.nuget.org/v3/index.json

Hope it's useful

💖 💪 🙅 🚩
alandecastros
Alan Castro

Posted on May 24, 2020

Join Our Newsletter. No Spam, Only the good stuff.

Sign up to receive the latest update from our blog.

Related