#!/usr/bin/env bash

# Copyright 2022 The Kubernetes Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

set -e
set -x

REPO_ROOT=$(git rev-parse --show-toplevel)
cd ${REPO_ROOT}
cd ..
WORKSPACE=$(pwd)
cd ${REPO_ROOT}

# Create bindir
BINDIR=${WORKSPACE}/bin
export PATH=${BINDIR}:${PATH}
mkdir -p "${BINDIR}"

export KUBE_ROOT=${REPO_ROOT}
source "${REPO_ROOT}/tools/version.sh"
get_version_vars
unset KUBE_ROOT
export KUBE_GIT_COMMIT
export KUBE_GIT_MAJOR
export KUBE_GIT_MINOR
export KUBE_GIT_TREE_STATE
export KUBE_GIT_VERSION

BUILD_DATE=$(date ${SOURCE_DATE_EPOCH:+"--date=@${SOURCE_DATE_EPOCH}"} -u +'%Y-%m-%dT%H:%M:%SZ')
export BUILD_DATE
