Pushing plugin to Nuget Gallery with Github Actions

bonjour,

to publish VL plugins, I used to rely on Azure Pipelines to build vs solutions (if any), pack a nuget and push it to nuget.org. i find that process kinda boring though : you have to setup a project there, connect it to your repo and to your nuget feed, get lost in the ton of menus… then github actions came to rescue!

writing a small yml file to your repo, you can trigger that same process on github. i made a small test repo that has a visual studio solution, a VL document that uses this solution and a bunch of help patches, this seems to be working :)

here are the steps :

  • add a new secret to your repo containing a Nuget API key named NUGET_KEY
  • in your nuspec, make sure to also copy the .pdb file. otherwise, the push will succeed anyway but the job will be marked as failed
  • under the Actions tab, click “Setup a workflow yourself” on the right
  • github now creates a main.yml file under .github/workflows and lets you edit it. paste this and adapt it to your project :
name: push_nuget

# on push on master
on:
  push:
    branches:
      - master
    paths-ignore:
      - README.md

jobs:
  build:
    runs-on: windows-latest
    steps:
    - name: Git Checkout
      uses: actions/checkout@master
    
    - name: Setup MSBuild.exe
      uses: warrenbuckley/Setup-MSBuild@v1

    - name: Setup Nuget.exe
      uses: nuget/setup-nuget@v1
      
    - name: Setup .NET Core SDK
      uses: actions/setup-dotnet@v1.4.0
  
    - name: Build
      run: msbuild src\Whatever\Whatever.csproj /t:Build /v:m /m /restore /p:Configuration=Release 
    
    - name: Nuget Pack
      run: nuget pack ./deployment/GithubPackageTest.nuspec -Symbols -SymbolPackageFormat snupkg
      
    - name: Nuget Push
      run: nuget push *.nupkg ${{ secrets.NUGET_KEY }} -src https://api.nuget.org/v3/index.json

with this workflow, a new build will be triggered each time there’s a commit on master, except on README.md.

if you just need to pack some VL files (no vs solution), you can remove the steps named Setup MSBuild.exe and Build.

and you’re done! your project should now be pushed to the Nuget Gallery :)

it case you wanna have a look at the repo on which I experimented that, here it is.

any feedback is welcome :)

cheerz!

ps: github also has a market-place on which you can re-use prebuilt actions like this one. i’ll try to setup one in the next days, but those have to be written in JS so that might take some time :)

9 Likes

verygoodstuff.

here are my additional findings:

  • for the nuget push you can add a -NoSymbols arg to workaround the mentioned problem of having to include .pdb files

  • for the checkout action i had a case where i had to use

    with:
      lfs: 'true'
    
  • i’m using this download action to have unified icons for all our nugets. (you can then ref the .png via the nuspec):

    - name: Download Icon
      uses: carlosperate/download-file-action@v1.0.3
      with:
        file-url: 'https://raw.githubusercontent.com/vvvv/PublicContent/master/nugeticon.png'
        location: './deployment'
    
  • to get an automatic build number i use this:

    - name: Nuget Pack
      run: nuget pack ./deployment/Foo.nuspec -Version ${{env.VERSION}}
      env:
        VERSION: 0.2.${{github.run_number}}-alpha
2 Likes

For reference, check this blogpost : https://vvvv.org/blog/publishing-your-vl-nugets-with-github-actions

2 Likes