Skip to content

Commit

Permalink
Second stab at fixing the version command in build.sh (#1762)
Browse files Browse the repository at this point in the history
* Make sure GOOS=linux and GOARCH=amd64 for version cmd.

The commit forces the version command to run with GOOS=linux and
GOARCH=amd64. The version command was failing to run properly when
cross-compiling to Mac OS and Windows, since the environment
variables were causing the binary produced to not be executable
on Travis CI.

Closes #1759

Signed-off-by: Eric Chlebek <[email protected]>

* Don't pass cross-compile env vars to VERSION_CMD.

Signed-off-by: Eric Chlebek <[email protected]>
  • Loading branch information
echlebek authored Jun 28, 2018
1 parent 6d92b02 commit 5ef80b7
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ VERSION_CMD="GOOS=linux GOARCH=amd64 go run ./version/cmd/version/version.go"
HANDLERS=(slack)

set_race_flag() {
if [ "$GOARCH" == "amd64" ]; then
if [ "$GOARCH" == "amd64" ] && [ "$CGO_ENABLED" == "1" ]; then
RACE="-race"
fi
}
Expand Down Expand Up @@ -79,6 +79,13 @@ build_tool_binary () {
}

build_binary () {
# Unset GOOS and GOARCH so that the version command builds on native OS/arch
unset GOOS
unset GOARCH

local version=$($VERSION_CMD -v)
local prerelease=$($VERSION_CMD -p)

local goos=$1
local goarch=$2
local cmd=$3
Expand All @@ -87,8 +94,6 @@ build_binary () {

local outfile="target/${goos}-${goarch}/${cmd_name}"

local version=$($VERSION_CMD -v)
local prerelease=$($VERSION_CMD -p)
local build_date=$(date +"%Y-%m-%dT%H:%M:%S%z")
local build_sha=$(git rev-parse HEAD)

Expand Down

0 comments on commit 5ef80b7

Please sign in to comment.