forked from ahoy-cli/ahoy
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.sh
29 lines (27 loc) · 836 Bytes
/
build.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
set -e
NAME='ahoy'
COMMIT=$(git rev-parse --short HEAD)
VERSION=$(git describe --tag $COMMIT)
if [ -z "$GOPATH" ]; then
echo " [Error] You MUST set your \$GOPATH and put this repo within it at \$GOPATH/src/github.com/ahoy-cli/ahoy to build."
exit 1
fi
IFS=':' read -r -a gopaths <<< "$GOPATH"
dir=`pwd`
for gopath in "${gopaths[@]}"; do
repo_path="$gopath/src/github.com/ahoy-cli/ahoy"
if [ "$dir" == "$repo_path" ]; then
found=true
fi
done
if [ -z "$found" ]; then
echo "[Error] This repo should be at one of the following paths:"
for gopath in "${gopaths[@]}"; do
echo "$gopath/src/github.com/ahoy-cli/ahoy"
done
echo " but instead it is at:"
echo " $dir (Move it)"
exit 1
fi
go build -ldflags "-X main.version=$VERSION" -o $NAME "$@"
echo "Built ahoy version $VERSION"