Skip to content

Commit a126391

Browse files
committed
Add homebrew support
1 parent 8c6ce40 commit a126391

File tree

3 files changed

+102
-0
lines changed

3 files changed

+102
-0
lines changed

README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,14 @@ By default, jplot uses the full size of the terminal, but it is possible to limi
2121

2222
## Install
2323

24+
Using [homebrew](http://brew.sh/):
25+
26+
```
27+
brew install https://raw.githubusercontent.com/rs/jplot/master/jplot.rb
28+
```
29+
30+
From source:
31+
2432
```
2533
go get -u github.com/rs/jplot
2634
```

jplot.rb

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
class Jplot < Formula
2+
desc "iTerm2 expvar/JSON monitoring tool"
3+
homepage "https://github.com/rs/jplot"
4+
url "https://github.com/rs/jplot/archive/1.0.0.tar.gz"
5+
sha256 "f6816198294c67e5d858effbfb744097a9c1520a494a1da6699b2a99422151d1"
6+
head "https://github.com/rs/jplot.git"
7+
8+
if Hardware::CPU.is_64_bit?
9+
url "https://github.com/rs/jplot/releases/download/1.0.0/jplot_1.0.0_darwin_amd64.zip"
10+
sha256 "13529d71da748903de3e7e034722d30c4ef9cf1329f2dab366547d8afed4ea7e"
11+
else
12+
url "https://github.com/rs/jplot/releases/download/1.0.0/jplot_1.0.0_darwin_386.zip"
13+
sha256 "3581dc8488e45467ff4ec089a1c74216cea7e26e97091247f31f04ee79dd6c22"
14+
end
15+
16+
depends_on "go" => :build
17+
18+
def install
19+
bin.install "jplot"
20+
end
21+
end

release.sh

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
#!/bin/bash
2+
3+
set -e
4+
5+
VERSION=$1
6+
USER=rs
7+
NAME=jplot
8+
DESC="iTerm2 expvar/JSON monitoring tool"
9+
10+
if [ -z $VERSION ]; then
11+
echo "usage: $0 VERSION"
12+
exit 1
13+
fi
14+
15+
github-release release -u $USER -r $NAME -t $VERSION
16+
17+
rm -rf dist
18+
mkdir dist
19+
cleanup() {
20+
rm -rf dist
21+
}
22+
trap cleanup EXIT
23+
24+
for env in darwin/amd64 darwin/386; do
25+
eval $(echo $env | tr '/' ' ' | xargs printf 'export GOOS=%s; export GOARCH=%s\n')
26+
27+
GOOS=${env%/*}
28+
GOARCH=${env#*/}
29+
30+
bin=$NAME
31+
if [ $GOOS == "windows" ]; then
32+
bin="$NAME.exe"
33+
fi
34+
35+
mkdir -p dist
36+
37+
echo "Building for GOOS=$GOOS GOARCH=$GOARCH"
38+
39+
CGO_ENABLED=0 go build -o dist/$bin
40+
file=${NAME}_${VERSION}_${GOOS}_${GOARCH}.zip
41+
zip dist/$file -j dist/$bin
42+
rm -f dist/$bin
43+
44+
github-release upload -u $USER -r $NAME -t $VERSION -n $file -f dist/$file
45+
done
46+
47+
url=https://github.com/${USER}/${NAME}/archive/${VERSION}.tar.gz
48+
darwin_amd64=${NAME}_${VERSION}_darwin_amd64.zip
49+
darwin_386=${NAME}_${VERSION}_darwin_386.zip
50+
51+
cat << EOF > jplot.rb
52+
class Jplot < Formula
53+
desc "$DESC"
54+
homepage "https://github.com/${USER}/${NAME}"
55+
url "$url"
56+
sha256 "$(curl $url | shasum -a 256 | awk '{print $1}')"
57+
head "https://github.com/${USER}/${NAME}.git"
58+
59+
if Hardware::CPU.is_64_bit?
60+
url "https://github.com/${USER}/${NAME}/releases/download/${VERSION}/${darwin_amd64}"
61+
sha256 "$(shasum -a 256 dist/${darwin_amd64} | awk '{print $1}')"
62+
else
63+
url "https://github.com/${USER}/${NAME}/releases/download/${VERSION}/${darwin_386}"
64+
sha256 "$(shasum -a 256 dist/${darwin_386} | awk '{print $1}')"
65+
end
66+
67+
depends_on "go" => :build
68+
69+
def install
70+
bin.install "$NAME"
71+
end
72+
end
73+
EOF

0 commit comments

Comments
 (0)