This repository was used to figure out how to build Go code and package it into a .deb along with configuration and a service file to enable it to be managed by systemd.
I use GoReleaser along with NFPM to achieve this.
The whole pipeline can be used with GitHub Actions for CI automation via the release workflow.
In its current configuration, packages will be built and appear as releases on Github when code is tagged:
git tag -a v0.0.1 -m "new release"
git push origin v0.0.1
With a local install of GoReleaser, without tagging, the following will build a snapshot in a dist directory:
goreleaser --snapshot --skip-publish --rm-dist
My requirement was to deploy to a Raspberry Pi. You'll need to change the build configuration and modify the service file for other architectures.