GitHub Actions e2e tests
Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
This commit is contained in:
@ -1,6 +1,12 @@
|
||||
#!/usr/bin/env sh
|
||||
set -eu
|
||||
|
||||
: "${CGO_ENABLED=}"
|
||||
: "${GO_LINKMODE=static}"
|
||||
: "${GO_BUILDMODE=}"
|
||||
: "${GO_BUILDTAGS=}"
|
||||
: "${GO_STRIP=}"
|
||||
|
||||
TARGET=${TARGET:-"build"}
|
||||
|
||||
PLATFORM=${PLATFORM:-}
|
||||
@ -8,34 +14,68 @@ VERSION=${VERSION:-$(git describe --match 'v[0-9]*' --dirty='.m' --always --tags
|
||||
GITCOMMIT=${GITCOMMIT:-$(git rev-parse --short HEAD 2> /dev/null || true)}
|
||||
BUILDTIME=${BUILDTIME:-$(date -u --date="@${SOURCE_DATE_EPOCH:-$(date +%s)}" +"%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 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}\" \
|
||||
${LDFLAGS:-} \
|
||||
"
|
||||
|
||||
GOOS="$(go env GOOS)"
|
||||
GOARCH="$(go env GOARCH)"
|
||||
if [ "${GOARCH}" = "arm" ]; then
|
||||
GOARM="$(go env GOARM)"
|
||||
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"
|
||||
TARGET="${TARGET}.exe"
|
||||
fi
|
||||
export TARGET
|
||||
|
||||
if [ -z "$CGO_ENABLED" ]; then
|
||||
case "$(go env GOOS)" in
|
||||
linux)
|
||||
case "$(go env GOARCH)" in
|
||||
amd64|arm64|arm|s390x)
|
||||
CGO_ENABLED=1
|
||||
;;
|
||||
*)
|
||||
CGO_ENABLED=0
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
darwin|windows)
|
||||
CGO_ENABLED=1
|
||||
;;
|
||||
*)
|
||||
CGO_ENABLED=0
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
export CGO_ENABLED
|
||||
|
||||
if [ "$CGO_ENABLED" = "1" ] && [ "$(go env GOOS)" != "windows" ]; then
|
||||
case "$(go env GOARCH)" in
|
||||
mips*|ppc64)
|
||||
# pie build mode is not supported on mips architectures
|
||||
;;
|
||||
*)
|
||||
GO_BUILDMODE="-buildmode=pie"
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
export GO_BUILDMODE
|
||||
|
||||
LDFLAGS="${LDFLAGS:-} -w"
|
||||
LDFLAGS="$LDFLAGS -X \"github.com/docker/cli/cli/version.GitCommit=${GITCOMMIT}\""
|
||||
LDFLAGS="$LDFLAGS -X \"github.com/docker/cli/cli/version.BuildTime=${BUILDTIME}\""
|
||||
LDFLAGS="$LDFLAGS -X \"github.com/docker/cli/cli/version.Version=${VERSION}\""
|
||||
if test -n "${PLATFORM}"; then
|
||||
LDFLAGS="$LDFLAGS -X \"github.com/docker/cli/cli/version.PlatformName=${PLATFORM}\""
|
||||
fi
|
||||
if [ "$CGO_ENABLED" = "1" ] && [ "$GO_LINKMODE" = "static" ] && [ "$(go env GOOS)" = "linux" ]; then
|
||||
LDFLAGS="$LDFLAGS -extldflags -static"
|
||||
fi
|
||||
if [ -n "$GO_STRIP" ]; then
|
||||
LDFLAGS="$LDFLAGS -s"
|
||||
fi
|
||||
export LDFLAGS="$LDFLAGS" # https://github.com/koalaman/shellcheck/issues/2064
|
||||
|
||||
export SOURCE="github.com/docker/cli/cmd/docker"
|
||||
|
||||
@ -5,53 +5,10 @@
|
||||
|
||||
set -eu
|
||||
|
||||
: "${CGO_ENABLED=}"
|
||||
: "${GO_LINKMODE=static}"
|
||||
: "${GO_BUILDMODE=}"
|
||||
: "${GO_BUILDTAGS=}"
|
||||
: "${GO_STRIP=}"
|
||||
|
||||
. ./scripts/build/.variables
|
||||
|
||||
if [ -z "$CGO_ENABLED" ]; then
|
||||
case "$(go env GOOS)" in
|
||||
linux)
|
||||
case "$(go env GOARCH)" in
|
||||
amd64|arm64|arm|s390x)
|
||||
CGO_ENABLED=1
|
||||
;;
|
||||
*)
|
||||
CGO_ENABLED=0
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
darwin|windows)
|
||||
CGO_ENABLED=1
|
||||
;;
|
||||
*)
|
||||
CGO_ENABLED=0
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
export CGO_ENABLED
|
||||
if [ "$CGO_ENABLED" = "1" ] && [ "$(go env GOOS)" != "windows" ]; then
|
||||
case "$(go env GOARCH)" in
|
||||
mips*|ppc64)
|
||||
# pie build mode is not supported on mips architectures
|
||||
;;
|
||||
*)
|
||||
GO_BUILDMODE="-buildmode=pie"
|
||||
;;
|
||||
esac
|
||||
GO_BUILDTAGS="$GO_BUILDTAGS pkcs11"
|
||||
fi
|
||||
|
||||
if [ "$CGO_ENABLED" = "1" ] && [ "$GO_LINKMODE" = "static" ] && [ "$(go env GOOS)" = "linux" ]; then
|
||||
LDFLAGS="$LDFLAGS -extldflags -static"
|
||||
fi
|
||||
|
||||
if [ -n "$GO_STRIP" ]; then
|
||||
LDFLAGS="$LDFLAGS -s -w"
|
||||
GO_BUILDTAGS="$GO_BUILDTAGS pkcs11"
|
||||
fi
|
||||
|
||||
echo "Building $GO_LINKMODE $(basename "${TARGET}")"
|
||||
@ -67,6 +24,6 @@ if [ "$(go env GOOS)" = "windows" ]; then
|
||||
fi
|
||||
fi
|
||||
|
||||
(set -x ; go build -o "${TARGET}" -tags "${GO_BUILDTAGS}" --ldflags "${LDFLAGS}" ${GO_BUILDMODE} "${SOURCE}")
|
||||
(set -x ; go build -o "${TARGET}" -tags "${GO_BUILDTAGS}" -ldflags "${LDFLAGS}" ${GO_BUILDMODE} "${SOURCE}")
|
||||
|
||||
ln -sf "$(basename "${TARGET}")" "$(dirname "${TARGET}")/docker"
|
||||
|
||||
@ -1,21 +1,19 @@
|
||||
#!/usr/bin/env bash
|
||||
#
|
||||
# Build a static binary for the host OS/ARCH
|
||||
# Build plugins examples for the host OS/ARCH
|
||||
#
|
||||
|
||||
set -eu -o pipefail
|
||||
|
||||
source ./scripts/build/.variables
|
||||
|
||||
mkdir -p "build/plugins-${GOOS}-${GOARCH}"
|
||||
for p in cli-plugins/examples/* "$@" ; do
|
||||
[ -d "$p" ] || continue
|
||||
|
||||
n=$(basename "$p")
|
||||
TARGET_PLUGIN="$(dirname "${TARGET}")/plugins-${GOOS}-${GOARCH}/docker-${n}"
|
||||
mkdir -p "$(dirname "${TARGET_PLUGIN}")"
|
||||
|
||||
TARGET="build/plugins-${GOOS}-${GOARCH}/docker-${n}"
|
||||
|
||||
echo "Building statically linked $TARGET"
|
||||
export CGO_ENABLED=0
|
||||
GO111MODULE=auto go build -o "${TARGET}" --ldflags "${LDFLAGS}" "github.com/docker/cli/${p}"
|
||||
echo "Building $GO_LINKMODE $(basename "${TARGET_PLUGIN}")"
|
||||
(set -x ; CGO_ENABLED=0 GO111MODULE=auto go build -o "${TARGET_PLUGIN}" -tags "${GO_BUILDTAGS}" -ldflags "${LDFLAGS}" ${GO_BUILDMODE} "github.com/docker/cli/${p}")
|
||||
done
|
||||
|
||||
@ -1,18 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
#
|
||||
# Build a static binary for the host OS/ARCH
|
||||
#
|
||||
|
||||
set -eu -o pipefail
|
||||
|
||||
source ./scripts/build/.variables
|
||||
|
||||
export CGO_ENABLED=1
|
||||
export GOOS=darwin
|
||||
export GOARCH=amd64
|
||||
export CC=o64-clang
|
||||
export CXX=o64-clang++
|
||||
export LDFLAGS="$LDFLAGS -linkmode external -s"
|
||||
export LDFLAGS_STATIC_DOCKER='-extld='${CC}
|
||||
|
||||
source ./scripts/build/plugins
|
||||
@ -1,14 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
#
|
||||
# Build a static binary for the host OS/ARCH
|
||||
#
|
||||
|
||||
set -eu -o pipefail
|
||||
|
||||
source ./scripts/build/.variables
|
||||
export CC=x86_64-w64-mingw32-gcc
|
||||
export CGO_ENABLED=1
|
||||
export GOOS=windows
|
||||
export GOARCH=amd64
|
||||
|
||||
source ./scripts/build/plugins
|
||||
Reference in New Issue
Block a user