Skip to content

Commit

Permalink
Add homebrew support
Browse files Browse the repository at this point in the history
  • Loading branch information
rs committed Mar 12, 2018
1 parent 8c6ce40 commit a126391
Show file tree
Hide file tree
Showing 3 changed files with 102 additions and 0 deletions.
8 changes: 8 additions & 0 deletions README.md
Expand Up @@ -21,6 +21,14 @@ By default, jplot uses the full size of the terminal, but it is possible to limi

## Install

Using [homebrew](http://brew.sh/):

```
brew install https://raw.githubusercontent.com/rs/jplot/master/jplot.rb
```

From source:

```
go get -u github.com/rs/jplot
```
Expand Down
21 changes: 21 additions & 0 deletions jplot.rb
@@ -0,0 +1,21 @@
class Jplot < Formula
desc "iTerm2 expvar/JSON monitoring tool"
homepage "https://github.com/rs/jplot"
url "https://github.com/rs/jplot/archive/1.0.0.tar.gz"
sha256 "f6816198294c67e5d858effbfb744097a9c1520a494a1da6699b2a99422151d1"
head "https://github.com/rs/jplot.git"

if Hardware::CPU.is_64_bit?
url "https://github.com/rs/jplot/releases/download/1.0.0/jplot_1.0.0_darwin_amd64.zip"
sha256 "13529d71da748903de3e7e034722d30c4ef9cf1329f2dab366547d8afed4ea7e"
else
url "https://github.com/rs/jplot/releases/download/1.0.0/jplot_1.0.0_darwin_386.zip"
sha256 "3581dc8488e45467ff4ec089a1c74216cea7e26e97091247f31f04ee79dd6c22"
end

depends_on "go" => :build

def install
bin.install "jplot"
end
end
73 changes: 73 additions & 0 deletions release.sh
@@ -0,0 +1,73 @@
#!/bin/bash

set -e

VERSION=$1
USER=rs
NAME=jplot
DESC="iTerm2 expvar/JSON monitoring tool"

if [ -z $VERSION ]; then
echo "usage: $0 VERSION"
exit 1
fi

github-release release -u $USER -r $NAME -t $VERSION

rm -rf dist
mkdir dist
cleanup() {
rm -rf dist
}
trap cleanup EXIT

for env in darwin/amd64 darwin/386; do
eval $(echo $env | tr '/' ' ' | xargs printf 'export GOOS=%s; export GOARCH=%s\n')

GOOS=${env%/*}
GOARCH=${env#*/}

bin=$NAME
if [ $GOOS == "windows" ]; then
bin="$NAME.exe"
fi

mkdir -p dist

echo "Building for GOOS=$GOOS GOARCH=$GOARCH"

CGO_ENABLED=0 go build -o dist/$bin
file=${NAME}_${VERSION}_${GOOS}_${GOARCH}.zip
zip dist/$file -j dist/$bin
rm -f dist/$bin

github-release upload -u $USER -r $NAME -t $VERSION -n $file -f dist/$file
done

url=https://github.com/${USER}/${NAME}/archive/${VERSION}.tar.gz
darwin_amd64=${NAME}_${VERSION}_darwin_amd64.zip
darwin_386=${NAME}_${VERSION}_darwin_386.zip

cat << EOF > jplot.rb
class Jplot < Formula
desc "$DESC"
homepage "https://github.com/${USER}/${NAME}"
url "$url"
sha256 "$(curl $url | shasum -a 256 | awk '{print $1}')"
head "https://github.com/${USER}/${NAME}.git"
if Hardware::CPU.is_64_bit?
url "https://github.com/${USER}/${NAME}/releases/download/${VERSION}/${darwin_amd64}"
sha256 "$(shasum -a 256 dist/${darwin_amd64} | awk '{print $1}')"
else
url "https://github.com/${USER}/${NAME}/releases/download/${VERSION}/${darwin_386}"
sha256 "$(shasum -a 256 dist/${darwin_386} | awk '{print $1}')"
end
depends_on "go" => :build
def install
bin.install "$NAME"
end
end
EOF

0 comments on commit a126391

Please sign in to comment.