Skip to content

Instantly share code, notes, and snippets.

@uraimo
Last active November 9, 2022 17:12
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save uraimo/5612d8bcdf4ff4aef2f678ef39169ffa to your computer and use it in GitHub Desktop.
Save uraimo/5612d8bcdf4ff4aef2f678ef39169ffa to your computer and use it in GitHub Desktop.
Create a new homebrew formula and submit it/private tap

Creating a new Homebrew formula

Simplified procedure extracted from the contribution guidelines and the guide.

Example for a new go application, the install step and the dependencies will be different if you are building something else.

  1. Update brew:

    brew update

  2. Brew create with the latest source tgz from github:

    brew create https://github.com/MichaelMure/git-bug/archive/0.7.1.tar.gz

  3. Edit the formula, you'll need an install step that build the sources and installs them and a test step that verifies that the build binary is in the right palce or that it works correctly.

class GitBug < Formula
  desc "Distributed, offline-first bug tracker embedded in git, with bridges"
  homepage "https://github.com/MichaelMure/git-bug"
  url "https://github.com/MichaelMure/git-bug/archive/0.7.1.tar.gz"
  sha256 "78a6c7dee159cdad4ad69066d6d8fc4b7c259d5ea6351aaf6709b6ac03ff3d2f"

  depends_on "go" => :build

  def install
    system "make", "build"
    bin.install "git-bug"
  end

  test do
    assert_includes shell_output("#{bin}/git-bug --version"),"git-bug version"
  end
end

Yout new formula will be at the usual place, under /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core/Formula/.

  1. Audit the formula for errors:

     brew audit --new-formula git-bug
     brew audit --strict git-bug
    
  2. Install your local formula:

    HOMEBREW_MAKE_JOBS=1 brew install -v git-bug

  3. If you want to open a PR to Homebrew, create a commit with the new formula with the title " (new formula)" (either cloning the homebrew repo or from github) and open a PR.

Make your own brew tap

Instead of pushing the new formula on

Create a new GitHub repository "homebrew-<name> and add your formulas to the root.

Install the tap and then install one of your formulas:

brew tap uraimo/<name>
brew install uraimo/<name>/yourformula
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment