DockerCLI/scripts/build/.variables

42 lines
1.1 KiB
Bash
Executable File

#!/usr/bin/env sh
set -eu
TARGET=${TARGET:-"build"}
PLATFORM=${PLATFORM:-}
VERSION=${VERSION:-$(git describe --match 'v[0-9]*' --dirty='.m' --always --tags | sed 's/^v//' 2>/dev/null || echo "unknown-version" )}
GITCOMMIT=${GITCOMMIT:-$(git rev-parse --short HEAD 2> /dev/null || true)}
BUILDTIME=${BUILDTIME:-$(date -u +"%Y-%m-%dT%H:%M:%SZ")}
PLATFORM_LDFLAGS=
if test -n "${PLATFORM}"; then
PLATFORM_LDFLAGS="-X \"github.com/docker/cli/cli/version.PlatformName=${PLATFORM}\""
fi
export GO_LDFLAGS="\
-w \
${PLATFORM_LDFLAGS} \
-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}\" \
${GO_LDFLAGS:-} \
"
GOOS="$(go env GOOS)"
GOARCH="$(go env GOARCH)"
if [ "${GOARCH}" = "arm" ]; then
GOARM="$(go env GOARM)"
fi
TARGET="$TARGET/docker-${GOOS}-${GOARCH}"
if [ "${GOARCH}" = "arm" ] && [ -n "${GOARM}" ]; then
TARGET="${TARGET}-v${GOARM}"
fi
if [ "${GOOS}" = "windows" ]; then
TARGET="${TARGET}.exe"
fi
export TARGET
export SOURCE="github.com/docker/cli/cmd/docker"