C#C
C#3y ago
Alexicon

✅ Simple way to push a C# project as a NuGet package within a GitHub workflow yml

I am not sure if there is a better place to ask this question as its really only C# adjacent, but maybe someone here knows the answer.

Does anyone have a simple and up to date example of how to push a C# project as a NuGet package for GitHub actions? There are a lot of examples online but all of the ones I can find seem to be out of date or use a third-party workflow which I would like to avoid.

If I was using Azure DevOps I would simply add the following to my yml file:

- task: DotNetCoreCLI@2
  displayName: Pack myproject
  inputs:
    command: pack
    packagesToPack: '**/myproject.csproj'
    configuration: release
    versioningScheme: byBuildNumber

- task: DotNetCoreCLI@2
  displayName: Push NuGet packages
  condition: and(succeeded(), eq(variables['Build.SourceBranch'], 'refs/heads/master'))
  inputs:
    command: push
    versioningScheme: byPrereleaseNumber


however, the GitHub actions equivalent seems to elude me.
Was this page helpful?