I am a huge fan of a goreleaser tool that enables users to build Go projects and package/publish build artifacts in a fully automated and highly customizable way. We’ve have been using goreleaser with all our recent projects and we couldn’t be any happier since then.
But once the artifacts are built and published, the next important step is to make them easily installable. Especially if you provide deb/rpm packages which are built with NFPM integration.
The “challenge” with deb/rpm packages comes to light when project owners want to add those packages to Apt/Yum repositories. Goreleaser doesn’t provide any integrations with 3rd party repositories nor there are Apt/Yum repositories which are free and provide an API to upload artifacts. Or are there?
Actually there is at least one - the gemfury.io project that does just that (and even more).
Gemfury is a private package repository to help you easily reuse code without worrying about its hosting or deployment. It integrates directly with existing package management tools that you already use.
Among other repositories, Fury provides a Yum/Apt repo for pre-built deb/rpm packages. It is free for public packages, which makes it a good choice for OSS projects. It also sports a hefty number of options to upload artifacts, from a simple
curl to a push via its own CLI tool.
Just register within the service and generate a push token, and you are good to go leveraging Goreleaser to push your artifacts to Fury.
Once you have a Fury' push token, it is a matter of a few lines of code on the Goreleaser side.
I am using Goreleaser' Github action to build and publish artifacts, therefore I added push token to repo’s secrets and added it as another environment variable of a goreleaser action:
This will make our
FURYPUSHTOKEN secret value to be available inside the Goreleaser' Env vars under the
nfpm section of your
.goreleaser.yml file add
id field. This identification string will be used in Step 3 to scope which artifacts will be pushed to Fury. Since Fury will be used exclusively for dep/rpm artifacts, by using the
id related to them we will skip artifacts which are generated in the
build section of goreleaser (aka archives).
Now we need to tell Goreleaser to actually push those deb/rpm files it produced to a Fury repo. This is easily done with the custom publishers feature.
Look how easy it is. Now on every goreleaser' build, artifacts from nfpm will be concurrently uploaded to Fury and immediately available to the users of those Apt/Yum repositories. Do note, that by default pushed artifacts have a private scope, so don’t forget to visit Fury' account dashboard and make them public.
Did I say that Goreleaser is a great tool? I bet I did, so consider supporting it if you have a chance.