-
Notifications
You must be signed in to change notification settings - Fork 0
/
release.sh
executable file
·59 lines (47 loc) · 1.2 KB
/
release.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#!/usr/bin/env bash
set -e
version=$(cat main.go | grep "^const version = " | sed 's/^const version = "//;s/"$//')
package="histkeep"
bin="histkeep"
repo="https://github.com/bbeardsley/histkeep-cli"
platforms=(
"windows/amd64"
"windows/386"
"darwin/amd64"
"darwin/arm64"
"linux/amd64"
"linux/386"
"linux/arm"
)
rm -f dist/*
for platform in "${platforms[@]}"
do
platform_split=(${platform//\// })
GOOS=${platform_split[0]}
GOARCH=${platform_split[1]}
BIN="${bin}"
if [ $GOOS = "windows" ]; then
BIN="${bin}.exe"
fi
ZIP=$package'_v'$version'_'$GOOS'_'$GOARCH'.zip'
echo "Building for GOOS=$GOOS GOARCH=$GOARCH"
env GOOS=$GOOS GOARCH=$GOARCH go build -o dist/${BIN} &&
zip -q dist/${ZIP} -j dist/${BIN} &&
rm dist/${BIN}
done
DARWIN_AMD64=${package}_v${version}_darwin_amd64.zip
cat << EOF > dist/${package}.rb
# This file was generated by release.sh
require 'formula'
class HistKeepCli < Formula
homepage '${repo}'
version '${version}'
if Hardware::CPU.is_64_bit?
url '${repo}/releases/download/v${version}/${DARWIN_AMD64}'
sha '$( sha256sum dist/${DARWIN_AMD64} | awk '{ print $1 }' | xargs printf )'
end
def install
bin.install '${BIN}'
end
end
EOF