print-workspace-status.sh 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  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. # This command is used by bazel as the workspace_status_command
  16. # to implement build stamping with git information.
  17. set -o errexit
  18. set -o nounset
  19. set -o pipefail
  20. export KRATOS_ROOT=$(dirname "${BASH_SOURCE}")/..
  21. source "${KRATOS_ROOT}/build/lib/version.sh"
  22. kratos::version::get_version_vars
  23. # Prefix with STABLE_ so that these values are saved to stable-status.txt
  24. # instead of volatile-status.txt.
  25. # Stamped rules will be retriggered by changes to stable-status.txt, but not by
  26. # changes to volatile-status.txt.
  27. # IMPORTANT: the camelCase vars should match the lists in hack/lib/version.sh
  28. # and pkg/version/def.bzl.
  29. cat <<EOF
  30. STABLE_BUILD_GIT_COMMIT ${KRATOS_GIT_COMMIT-}
  31. STABLE_BUILD_SCM_STATUS ${KRATOS_GIT_TREE_STATE-}
  32. STABLE_BUILD_SCM_REVISION ${KRATOS_GIT_VERSION-}
  33. STABLE_BUILD_MAJOR_VERSION ${KRATOS_GIT_MAJOR-}
  34. STABLE_BUILD_MINOR_VERSION ${KRATOS_GIT_MINOR-}
  35. STABLE_BUILD_TIME ${KRATOS_BUILD_TIME-}
  36. STABLE_DOCKER_TAG ${KRATOS_GIT_VERSION/+/_}
  37. gitCommit ${KRATOS_GIT_COMMIT-}
  38. gitTreeState ${KRATOS_GIT_TREE_STATE-}
  39. gitVersion ${KRATOS_GIT_VERSION-}
  40. gitMajor ${KRATOS_GIT_MAJOR-}
  41. gitMinor ${KRATOS_GIT_MINOR-}
  42. buildDate $(date \
  43. ${SOURCE_DATE_EPOCH:+"--date=@${SOURCE_DATE_EPOCH}"} \
  44. -u +'%Y-%m-%dT%H:%M:%SZ')
  45. EOF