Use GoReleaser to build and publish binaries, then configure a Homebrew tap to install them.
- Create a
.goreleaser.ymlfile in your project root to define build targets and release artifacts.
builds:
- id: myapp
main: ./cmd/myapp
goos: [linux, darwin, windows]
goarch: [amd64, arm64]
archives:
- format: tar.gz
name_template: "{{ .ProjectName }}-{{ .Version }}-{{ .Os }}-{{ .Arch }}"
release:
draft: true
- Run GoReleaser locally or in CI to generate release assets on a tagged push.
goreleaser release --clean
- Create a Homebrew tap repository and add a formula file named
myapp.rbthat points to your GitHub release.
class Myapp < Formula
desc "My Go CLI application"
homepage "https://github.com/username/myapp"
url "https://github.com/username/myapp/releases/download/v1.0.0/myapp-1.0.0-darwin-amd64.tar.gz"
sha256 "<insert_sha256>"
license "MIT"
version "1.0.0"
def install
bin.install "myapp"
end
end
- Push the formula to your tap and install it via Homebrew.
git push origin main
brew install username/tap/myapp
- Update the formula version and SHA256 checksum in your tap whenever you release a new version.
brew bump-formula-pr --url="https://github.com/username/myapp/releases/download/v1.1.0/myapp-1.1.0-darwin-amd64.tar.gz" username/tap/myapp