Practice repository for automating NuGet Package publishing via GitHub Actions.
- 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.
- 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
, wherex
is the prerelease build iteration. - Publishing a new release will trigger a NuGet Package publish as a release version.
- 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.
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 accessible to the workflow can be configured here.
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.