| #!/usr/bin/env bash |
| |
| # This script will be run by bazel when the build process starts to |
| # generate key-value information that represents the status of the |
| # workspace. The output should be like |
| # |
| # KEY1 VALUE1 |
| # KEY2 VALUE2 |
| # |
| # If the script exits with non-zero code, it's considered as a failure |
| # and the output will be discarded. |
| |
| function rev() { |
| cd $1; git describe --always --match "v[0-9].*" --dirty |
| } |
| |
| # Get Kubernetes version by doing an ugly grep. This returns something line 'v1.19.3'. |
| function kube_ver() { |
| cd $1 |
| grep -A 10 io_k8s_kubernetes third_party/go/repositories.bzl | grep version | head -n 1 | cut -d '"' -f 2 |
| } |
| |
| KUBE_MAJOR=$(kube_ver . | sed -e 's,v,,' | cut -d . -f 1) |
| KUBE_MINOR=$(kube_ver . | sed -e 's,v,,' | cut -d . -f 2) |
| KUBE_PATCH=$(kube_ver . | sed -e 's,v,,' | cut -d . -f 3) |
| |
| echo STABLE_BUILD_GERRIT-OAUTH-PROVIDER_LABEL $(rev .) |
| echo STABLE_BUILD_OWNERS_LABEL $(rev .) |
| echo STABLE_GIT_COMMIT $(git rev-parse HEAD) |
| echo STABLE_GIT_VERSION $(rev .) |
| echo STABLE_BUILDER $(id -un)@$(hostname -f):$(pwd) |
| |
| # Kubernetes compatibility - see //third_party/go:kubernetes_version_def.bzl. |
| echo STABLE_KUBERNETES_buildDate $(date -u +'%Y-%m-%dT%H:%M:%SZ') |
| echo STABLE_KUBERNETES_gitCommit $(git rev-parse HEAD) |
| echo STABLE_KUBERNETES_gitMajor $KUBE_MAJOR |
| echo STABLE_KUBERNETES_gitMinor $KUBE_MINOR |
| if git_status=$(git status --porcelain 2>/dev/null) && [[ -z ${git_status} ]]; then |
| echo STABLE_KUBERNETES_gitTreeState clean |
| else |
| echo STABLE_KUBERNETES_gitTreeState dirty |
| fi |
| echo STABLE_KUBERNETES_gitVersion $(kube_ver .)-hscloud-$(rev .) |