Skip to content

Instantly share code, notes, and snippets.

@ake-persson
Last active January 28, 2022 17:43
Show Gist options
  • Save ake-persson/ca29cca70f0b458aee4d to your computer and use it in GitHub Desktop.
Save ake-persson/ca29cca70f0b458aee4d to your computer and use it in GitHub Desktop.

Revisions

  1. Michael Persson revised this gist Jun 5, 2015. 1 changed file with 5 additions and 6 deletions.
    11 changes: 5 additions & 6 deletions gistfile1.md
    Original file line number Diff line number Diff line change
    @@ -1,5 +1,7 @@
    # Homebrew Formula for a Go app

    These are quick notes from making my own Formula and Tap.

    ## Add go build script to your Git repo

    **gobuild.sh**
    @@ -88,9 +90,6 @@ 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 <user>/<name>
    brew install <user>/<name>/<formula>
    ```



    brew tap mickep76/funk-gnarge
    brew install mickep76/funk-gnarge/tf
    ```
  2. Michael Persson revised this gist Jun 5, 2015. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion gistfile1.md
    Original file line number Diff line number Diff line change
    @@ -85,7 +85,7 @@ 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*
    *The "name" should not include "homebrew-" which is a prefix*

    ```bash
    brew tap <user>/<name>
  3. Michael Persson revised this gist Jun 5, 2015. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion gistfile1.md
    Original file line number Diff line number Diff line change
    @@ -85,7 +85,7 @@ 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*
    *The "name" should not include "-homebrew" which is a prefix*

    ```bash
    brew tap <user>/<name>
  4. Michael Persson revised this gist Jun 5, 2015. 1 changed file with 17 additions and 1 deletion.
    18 changes: 17 additions & 1 deletion gistfile1.md
    Original file line number Diff line number Diff line change
    @@ -77,4 +77,20 @@ HOMEBREW_MAKE_JOBS=1 brew install -v tf

    ## Github pull request

    [Github pull request](https://help.github.com/articles/using-pull-requests/)
    [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 <user>/<name>
    brew install <user>/<name>/<formula>
    ```



  5. Michael Persson revised this gist Jun 5, 2015. 1 changed file with 4 additions and 4 deletions.
    8 changes: 4 additions & 4 deletions gistfile1.md
    Original file line number Diff line number Diff line change
    @@ -37,7 +37,7 @@ brew update
    ## Create Formula skel

    ```bash
    # brew create 'https://github.com/mickep76/tf/archive/0.2.tar.gz'
    brew create 'https://github.com/mickep76/tf/archive/0.2.tar.gz'
    ```

    ## Modify Formula
    @@ -66,15 +66,15 @@ end
    ## Audit Formula

    ```bash
    # brew audit --strict tf
    brew audit --strict tf
    ```

    ## Test local install

    ```bash
    # HOMEBREW_MAKE_JOBS=1 brew install -v tf
    HOMEBREW_MAKE_JOBS=1 brew install -v tf
    ```

    ## Github pull request

    [Github pull request](https://help.github.com/articles/using-pull-requests/)
    [Github pull request](https://help.github.com/articles/using-pull-requests/)
  6. Michael Persson revised this gist Jun 5, 2015. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions gistfile1.md
    Original file line number Diff line number Diff line change
    @@ -1,4 +1,4 @@
    # Create Homebrew Formula for a Go application
    # Homebrew Formula for a Go app

    ## Add go build script to your Git repo

    @@ -44,7 +44,7 @@ brew update

    **/usr/local/Library/Formula/tf.rb**

    ```bash
    ```
    class Tf < Formula
    homepage "https://github.com/mickep76/tf"
    url "https://github.com/mickep76/tf/archive/0.2.tar.gz"
  7. Michael Persson revised this gist Jun 5, 2015. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion gistfile1.md
    Original file line number Diff line number Diff line change
    @@ -12,7 +12,7 @@ set -eux
    export GOPATH="$(pwd)/.gobuild"
    SRCDIR="${GOPATH}/src/github.com/mickep76/tf"

    [ -d ${TMPDIR} ] && rm -rf ${TMPDIR}
    [ -d ${GOPATH} ] && rm -rf ${GOPATH}
    mkdir -p ${GOPATH}/{src,pkg,bin}
    mkdir -p ${SRCDIR}
    cp tf.go ${SRCDIR}
  8. Michael Persson created this gist Jun 5, 2015.
    80 changes: 80 additions & 0 deletions gistfile1.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,80 @@
    # Create Homebrew Formula for a Go application

    ## 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 ${TMPDIR} ] && rm -rf ${TMPDIR}
    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**

    ```bash
    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/)