How to Distribute Go CLI Binaries (GoReleaser, Homebrew)

Cli
Distribute Go CLI binaries by automating builds with GoReleaser and publishing them via a Homebrew tap for easy installation.

Use GoReleaser to build and publish binaries, then configure a Homebrew tap to install them.

  1. Create a .goreleaser.yml file 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
  1. Run GoReleaser locally or in CI to generate release assets on a tagged push.
goreleaser release --clean
  1. Create a Homebrew tap repository and add a formula file named myapp.rb that 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
  1. Push the formula to your tap and install it via Homebrew.
git push origin main
brew install username/tap/myapp
  1. 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