# Homebrew Formula for a Go app ## Add go build script to your Git repo **gobuild.sh** ```bash #!/bin/bash set -eux export GOPATH="$(pwd)/.gobuild" SRCDIR="${GOPATH}/src/github.com/mickep76/tf" [ -d ${GOPATH} ] && rm -rf ${GOPATH} mkdir -p ${GOPATH}/{src,pkg,bin} mkdir -p ${SRCDIR} cp tf.go ${SRCDIR} ( echo ${GOPATH} cd ${SRCDIR} go get . go install . ) ``` ## Create tar.gz You can do this by tagging your Github repository with a version. ## Update Brew ```bash brew update ``` ## Create Formula skel ```bash brew create 'https://github.com/mickep76/tf/archive/0.2.tar.gz' ``` ## Modify Formula **/usr/local/Library/Formula/tf.rb** ``` class Tf < Formula homepage "https://github.com/mickep76/tf" url "https://github.com/mickep76/tf/archive/0.2.tar.gz" sha256 "b59730cfbc3c62027bd91942c70d3d07c2bbc4f82b0332d17da977bb7f2041bc" depends_on "go" => :build def install system "gobuild.sh" bin.install ".gobuild/bin/tf" => "tf" end test do system "#{bin}/tf", "--help" end end ``` ## Audit Formula ```bash brew audit --strict tf ``` ## Test local install ```bash HOMEBREW_MAKE_JOBS=1 brew install -v tf ``` ## Github pull request [Github pull request](https://help.github.com/articles/using-pull-requests/) ## Make your own Tap Create a Git repo called "homebrew-something". Add your formula to the root of the repo. After this you can use it like: *The "name" should not include "-homebrew" which is a prefix* ```bash brew tap / brew install // ```