k8s.io/kubernetes@v1.31.0-alpha.0.0.20240520171757-56147500dadc/hack/print-workspace-status.sh (about)

     1  #!/usr/bin/env bash
     2  # Copyright 2017 The Kubernetes Authors.
     3  #
     4  # Licensed under the Apache License, Version 2.0 (the "License");
     5  # you may not use this file except in compliance with the License.
     6  # You may obtain a copy of the License at
     7  #
     8  #     http://www.apache.org/licenses/LICENSE-2.0
     9  #
    10  # Unless required by applicable law or agreed to in writing, software
    11  # distributed under the License is distributed on an "AS IS" BASIS,
    12  # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    13  # See the License for the specific language governing permissions and
    14  # limitations under the License.
    15  
    16  # This script was used by bazel as the workspace_status_command to implement
    17  # build stamping with git information.
    18  #
    19  # It is still useful for obtaining kube::version::get_version_vars without
    20  # sourcing Kubernetes build internals.
    21  #
    22  # Usage: `hack/print-workspace-status.sh`.
    23  
    24  set -o errexit
    25  set -o nounset
    26  set -o pipefail
    27  
    28  KUBE_ROOT=$(dirname "${BASH_SOURCE[0]}")/..
    29  
    30  source "${KUBE_ROOT}/hack/lib/version.sh"
    31  kube::version::get_version_vars
    32  
    33  # Prefix with STABLE_ so that these values are saved to stable-status.txt
    34  # instead of volatile-status.txt.
    35  # Stamped rules will be retriggered by changes to stable-status.txt, but not by
    36  # changes to volatile-status.txt.
    37  # IMPORTANT: the camelCase vars should match the lists in hack/lib/version.sh
    38  cat <<EOF
    39  STABLE_BUILD_GIT_COMMIT ${KUBE_GIT_COMMIT-}
    40  STABLE_BUILD_SCM_STATUS ${KUBE_GIT_TREE_STATE-}
    41  STABLE_BUILD_SCM_REVISION ${KUBE_GIT_VERSION-}
    42  STABLE_BUILD_MAJOR_VERSION ${KUBE_GIT_MAJOR-}
    43  STABLE_BUILD_MINOR_VERSION ${KUBE_GIT_MINOR-}
    44  STABLE_DOCKER_TAG ${KUBE_GIT_VERSION/+/_}
    45  STABLE_DOCKER_REGISTRY ${KUBE_DOCKER_REGISTRY:-registry.k8s.io}
    46  STABLE_DOCKER_PUSH_REGISTRY ${KUBE_DOCKER_PUSH_REGISTRY:-${KUBE_DOCKER_REGISTRY:-staging-k8s.gcr.io}}
    47  gitCommit ${KUBE_GIT_COMMIT-}
    48  gitTreeState ${KUBE_GIT_TREE_STATE-}
    49  gitVersion ${KUBE_GIT_VERSION-}
    50  gitMajor ${KUBE_GIT_MAJOR-}
    51  gitMinor ${KUBE_GIT_MINOR-}
    52  buildDate $(date \
    53    ${SOURCE_DATE_EPOCH:+"--date=@${SOURCE_DATE_EPOCH}"} \
    54   -u +'%Y-%m-%dT%H:%M:%SZ')
    55  EOF