2017-05-11 18:52:17 -04:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
set -eu
|
|
|
|
|
2017-12-01 08:47:20 -05:00
|
|
|
PLATFORM=${PLATFORM:-}
|
2017-05-11 18:52:17 -04:00
|
|
|
VERSION=${VERSION:-"unknown-version"}
|
|
|
|
GITCOMMIT=${GITCOMMIT:-$(git rev-parse --short HEAD 2> /dev/null || true)}
|
|
|
|
BUILDTIME=${BUILDTIME:-$(date --utc --rfc-3339 ns 2> /dev/null | sed -e 's/ /T/')}
|
|
|
|
|
2017-12-01 08:47:20 -05:00
|
|
|
PLATFORM_LDFLAGS=
|
|
|
|
if test -n "${PLATFORM}"; then
|
2019-01-08 10:03:51 -05:00
|
|
|
PLATFORM_LDFLAGS="-X \"github.com/docker/cli/cli/version.PlatformName=${PLATFORM}\""
|
2017-12-01 08:47:20 -05:00
|
|
|
fi
|
|
|
|
|
2017-05-11 18:52:17 -04:00
|
|
|
export LDFLAGS="\
|
|
|
|
-w \
|
2017-12-01 08:47:20 -05:00
|
|
|
${PLATFORM_LDFLAGS} \
|
2019-01-08 10:03:51 -05:00
|
|
|
-X \"github.com/docker/cli/cli/version.GitCommit=${GITCOMMIT}\" \
|
|
|
|
-X \"github.com/docker/cli/cli/version.BuildTime=${BUILDTIME}\" \
|
|
|
|
-X \"github.com/docker/cli/cli/version.Version=${VERSION}\" \
|
2017-05-11 18:52:17 -04:00
|
|
|
${LDFLAGS:-} \
|
|
|
|
"
|
|
|
|
|
2017-05-25 12:41:56 -04:00
|
|
|
GOOS="${GOOS:-$(go env GOHOSTOS)}"
|
|
|
|
GOARCH="${GOARCH:-$(go env GOHOSTARCH)}"
|
2019-05-02 12:05:47 -04:00
|
|
|
if [ "${GOARCH}" = "arm" ]; then
|
|
|
|
GOARM="${GOARM:-$(go env GOHOSTARM)}"
|
|
|
|
fi
|
|
|
|
|
|
|
|
TARGET="build/docker-$GOOS-$GOARCH"
|
|
|
|
if [ "${GOARCH}" = "arm" ] && [ -n "${GOARM}" ]; then
|
|
|
|
TARGET="${TARGET}-v${GOARM}"
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ "${GOOS}" = "windows" ]; then
|
|
|
|
TARGET="${TARGET}.exe"
|
|
|
|
fi
|
|
|
|
export TARGET
|
|
|
|
|
2017-05-11 18:52:17 -04:00
|
|
|
export SOURCE="github.com/docker/cli/cmd/docker"
|