Skip to content

Instantly share code, notes, and snippets.

@NBprojekt
Last active December 28, 2020 09:58
Show Gist options
  • Save NBprojekt/569f9310d8c5adc1bd3ed6e568594b24 to your computer and use it in GitHub Desktop.
Save NBprojekt/569f9310d8c5adc1bd3ed6e568594b24 to your computer and use it in GitHub Desktop.
Deploy nuget package to GitHub using GitHub Actions

Deploy nuget package to GitHub using GitHub Actions

Token

First you need to create an Personal access token with the write:packages scope

Action

.github-cd.yml

name: GitHub CD
on: 
  release:
    types: 
      - published

jobs:
  deploy-package:
    name: Create release package
    runs-on: windows-2019
    env:
      DOTNET_SYSTEM_NET_HTTP_USESOCKETSHTTPHANDLER: 0        # This did finaly the job for me
      GITHUB_REPOSITORY_OWNER: ${{secrets.REPOSITORY_OWNER}} # Repo Owner (NBprojekt)      
      GITHUB_API_KEY: ${{secrets.GITHUB_TOKEN}}              # Github Token 

    steps:
    - name: Checkout
      uses: actions/checkout@v2
    - name: Restore dependencies
      run: dotnet restore
    - name: Pack for release
      run:
        dotnet pack --no-restore --configuration Release ./PROJECT/PROJECT.csproj
    - name: Deploy package to GitHub
      run: |
        dotnet nuget add source https://nuget.pkg.github.com/${{ env.GITHUB_REPOSITORY_OWNER }}/index.json --name github
        dotnet nuget push "*.nupkg" --source github --api-key ${{ env.GITHUB_API_KEY }} --skip-duplicate
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment