Skip to content

Commit

Permalink
Enforce go1.8+ at build time
Browse files Browse the repository at this point in the history
  • Loading branch information
mislav committed May 17, 2017
1 parent 0300450 commit 0aa5b57
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 deletions.
6 changes: 1 addition & 5 deletions script/bootstrap
Expand Up @@ -16,11 +16,7 @@ if [ -n "$TRAVIS" ] && [ ! -x ~/bin/tmux ]; then
curl -fsSL "https://${AMAZON_S3_BUCKET}.s3.amazonaws.com/${cache_name}.tgz" | tar -xz -C ~
fi

go_ver="$(go version | grep -o '1.[[:digit:]]\+' | head -1)"
if [ "${go_ver#*.}" -lt 8 ]; then
echo "You need to install Go 1.8 or higher to build hub" >&2
STATUS=1
fi
script/build check || STATUS=1

{ ruby --version
if [ -n "$TRAVIS" ]; then
Expand Down
14 changes: 14 additions & 0 deletions script/build
Expand Up @@ -39,7 +39,18 @@ find_packages() {
find_source_files | cut -d/ -f2 | sort -u | grep -v '.go$' | sed 's!^!github.com/github/hub/!'
}

check_go_version() {
local version="$(go version)"
local minor="$(grep -o 'go1.[[:digit:]]\+' <<<"$version" | head -1)"
[ -z "$version" ] || echo "$version"
if [[ -z "$version" || -n "$minor" && "${minor##*.}" -lt 8 ]]; then
echo "You need to install Go 1.8 or higher to build hub" >&2
return 1
fi
}

build_hub() {
check_go_version >/dev/null
setup_gopath
mkdir -p "$(dirname "$1")"
go build -ldflags "-X github.com/github/hub/version.Version=`./script/version`" -o "$1"
Expand Down Expand Up @@ -67,6 +78,9 @@ test )
files )
find_source_files
;;
check )
check_go_version
;;
-h | --help )
sed -ne '/^#/!q;s/.\{1,2\}//;1,2d;p' < "$0"
exit
Expand Down

0 comments on commit 0aa5b57

Please sign in to comment.