gnalvesteffer / github-actions-practice

Practice for automating NuGet package publishing via GitHub Actions.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

GitHub Actions Practice

Practice repository for automating NuGet Package publishing via GitHub Actions.

Publishing NuGet Package

  • When a commit containing changes to the ExampleClassLibrary project is pushed to the main branch, the Publish NuGet Package workflow will automatically build and publish a prerelease NuGet package for it.
  • When a Release is published, the workflow will trigger and publish a release version of the NuGet package, and attach a build of the .nupkg and ExampleConsoleApp to the release.

Versioning

  • The package's version string is automatically generated using the latest tag via MinVer, referenced in the ExampleClassLibrary project.
  • Commits pushed to main will have its package version suffixed with -prerelease.x, where x is the prerelease build iteration.
  • Publishing a new release will trigger a NuGet Package publish as a release version.

Creating a Release package

  • Create a new release via this link and create a new version tag following the semantic versioning scheme (for example: "0.1.0").
  • The Publish NuGet Package workflow will trigger when the release is published and will generate a release version of the package.
  • The Attach Example App To Release workflow will build the ExampleConsoleApp project and upload the artifacts to the release page.

GitHub Action Workflow

See the Publish NuGet Package workflow for reference.

At a high-level the workflow:

  • Checks out the repo
  • Sets up .NET 6
  • Builds the ExampleClassLibrary project
  • Builds the NuGet package using the project's build output
  • Publishes the NuGet package

Variables & Secrets

Variables & secrets accessible to the workflow can be configured here.

Testing GitHub Actions locally

To easily test Github Actions locally, you can use act.

Once act is setup in your environment, you can run act at the root of the repo. This will run the workflows in a Docker container on your machine, providing the benefit of a quicker feedback loop as you develop workflows.

About

Practice for automating NuGet package publishing via GitHub Actions.


Languages

Language:C# 100.0%