#!/usr/bin/env sh

set -ex
export "CGO_ENABLED"="1"
export "COMMIT"="f54c212e3a2f75d674b717a9b29052b20b60aefc"
export "FORCE_HOST_GO"="true"
export "GOPROXY"="direct"
export "KUBE_GIT_TREE_STATE"="clean"
export "TARGET_ARCH"="amd64"
export "TARGET_OS"="linux"
export "VERSION"="v1.37.0"

(
cd kubernetes
SANITIZED_VERSION=$(printf '%s' "$VERSION" | sed 's/~/-/g')
git tag "${SANITIZED_VERSION}"
KUBE_BUILD_PLATFORMS=${TARGET_OS}/${TARGET_ARCH} KUBE_VERBOSE=3 WHAT=cmd/kubelet KUBE_CGO_OVERRIDES=kubelet DBG=1 make
if [ "$TARGET_OS" = "windows" ]; then
  mkdir -p _output/bin/
  cp -f _output/local/bin/${TARGET_OS}/${TARGET_ARCH}/kubelet* _output/bin/
fi

)
