2021-03-03 02:03:02 -05:00
|
|
|
#!/usr/bin/env sh
|
2017-05-11 18:52:17 -04:00
|
|
|
set -eu
|
|
|
|
|
2021-03-03 02:03:02 -05:00
|
|
|
TARGET=${TARGET:-"build"}
|
|
|
|
|
2017-12-01 08:47:20 -05:00
|
|
|
PLATFORM=${PLATFORM:-}
|
2021-03-05 17:34:32 -05:00
|
|
|
VERSION=${VERSION:-$(git describe --match 'v[0-9]*' --dirty='.m' --always --tags | sed 's/^v//' 2>/dev/null || echo "unknown-version" )}
|
2017-05-11 18:52:17 -04:00
|
|
|
GITCOMMIT=${GITCOMMIT:-$(git rev-parse --short HEAD 2> /dev/null || true)}
|
2019-12-31 09:06:11 -05:00
|
|
|
BUILDTIME=${BUILDTIME:-$(date -u +"%Y-%m-%dT%H:%M:%SZ")}
|
2017-05-11 18:52:17 -04:00
|
|
|
|
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:-} \
|
|
|
|
"
|
|
|
|
|
2021-03-03 02:03:02 -05:00
|
|
|
GOOS="$(go env GOOS)"
|
|
|
|
GOARCH="$(go env GOARCH)"
|
2019-05-02 12:05:47 -04:00
|
|
|
if [ "${GOARCH}" = "arm" ]; then
|
2021-03-03 02:03:02 -05:00
|
|
|
GOARM="$(go env GOARM)"
|
2019-05-02 12:05:47 -04:00
|
|
|
fi
|
|
|
|
|
2021-03-03 02:03:02 -05:00
|
|
|
TARGET="$TARGET/docker-${GOOS}-${GOARCH}"
|
2019-05-02 12:05:47 -04:00
|
|
|
if [ "${GOARCH}" = "arm" ] && [ -n "${GOARM}" ]; then
|
2021-03-03 02:03:02 -05:00
|
|
|
TARGET="${TARGET}-v${GOARM}"
|
2019-05-02 12:05:47 -04:00
|
|
|
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"
|