DEV Community

loading...
Cover image for Push a NuGet package with SemVer to nuget.org by using GitHub Actions

Push a NuGet package with SemVer to nuget.org by using GitHub Actions

Georgy Sayganov
・1 min read

Example

As an example, please see the repositry:

GitHub logo sayganov / EventBus.RabbitMQ.Standard

A library for event-based communication by using RabbitMQ.

How-To

1. Firstly, create a new NuGet package on nuget.org. To do that, you need to upload the first version of your library manually.
2. Go to nuget.org/account/apikeys and create an API key for the NuGet package.
3. Go to the Secrets section in your repository settings and create a secret called NUGET_API_KEY with the value of the API key.
4. Add the following GitVersion.yml file to the root of the repository.

NOTE: You can adjust tag and mode depends on your needs.

5. Add the following build.yml file to the repository. It must be placed in {repo-name}/.github/workflows/.

NOTE: Do not forget to change YOUR_PROJECT_NAME to the actual name of your project.

NOTE: You can adjust different parameters depends on your needs, for example, paths.

6. Now, when you push a new version of your library to the repository it is going to be built, packed, and pushed to nuget.org with a proper version, for example, 1.0.5.

References

Discussion (0)