Robert Gerus | f1bdb9a | 2019-07-21 15:24:52 +0200 | [diff] [blame] | 1 | #!/usr/bin/env bash |
Sergiusz Bazanski | 573da78 | 2019-06-21 19:59:52 +0200 | [diff] [blame] | 2 | |
| 3 | # This script will be run by bazel when the build process starts to |
| 4 | # generate key-value information that represents the status of the |
| 5 | # workspace. The output should be like |
| 6 | # |
| 7 | # KEY1 VALUE1 |
| 8 | # KEY2 VALUE2 |
| 9 | # |
| 10 | # If the script exits with non-zero code, it's considered as a failure |
| 11 | # and the output will be discarded. |
| 12 | |
| 13 | function rev() { |
| 14 | cd $1; git describe --always --match "v[0-9].*" --dirty |
| 15 | } |
| 16 | |
Serge Bazanski | e23717d | 2020-11-03 20:08:23 +0100 | [diff] [blame] | 17 | # Get Kubernetes version by doing an ugly grep. This returns something line 'v1.19.3'. |
| 18 | function kube_ver() { |
| 19 | cd $1 |
| 20 | grep -A 10 io_k8s_kubernetes third_party/go/repositories.bzl | grep version | head -n 1 | cut -d '"' -f 2 |
| 21 | } |
| 22 | |
| 23 | KUBE_MAJOR=$(kube_ver . | sed -e 's,v,,' | cut -d . -f 1) |
| 24 | KUBE_MINOR=$(kube_ver . | sed -e 's,v,,' | cut -d . -f 2) |
| 25 | KUBE_PATCH=$(kube_ver . | sed -e 's,v,,' | cut -d . -f 3) |
| 26 | |
Sergiusz Bazanski | 573da78 | 2019-06-21 19:59:52 +0200 | [diff] [blame] | 27 | echo STABLE_BUILD_GERRIT-OAUTH-PROVIDER_LABEL $(rev .) |
Sergiusz Bazanski | 222a00a | 2020-04-12 18:37:21 +0200 | [diff] [blame] | 28 | echo STABLE_BUILD_OWNERS_LABEL $(rev .) |
Sergiusz Bazanski | 8fe651b | 2019-07-21 23:50:05 +0200 | [diff] [blame] | 29 | echo STABLE_GIT_COMMIT $(git rev-parse HEAD) |
| 30 | echo STABLE_GIT_VERSION $(rev .) |
| 31 | echo STABLE_BUILDER $(id -un)@$(hostname -f):$(pwd) |
Serge Bazanski | e23717d | 2020-11-03 20:08:23 +0100 | [diff] [blame] | 32 | |
| 33 | # Kubernetes compatibility - see //third_party/go/kubernetes:version.bzl. |
| 34 | echo STABLE_KUBERNETES_buildDate $(date -u +'%Y-%m-%dT%H:%M:%SZ') |
| 35 | echo STABLE_KUBERNETES_gitCommit $(git rev-parse HEAD) |
| 36 | echo STABLE_KUBERNETES_gitMajor $KUBE_MAJOR |
| 37 | echo STABLE_KUBERNETES_gitMinor $KUBE_MINOR |
| 38 | if git_status=$(git status --porcelain 2>/dev/null) && [[ -z ${git_status} ]]; then |
| 39 | echo STABLE_KUBERNETES_gitTreeState clean |
| 40 | else |
| 41 | echo STABLE_KUBERNETES_gitTreeState dirty |
| 42 | fi |
| 43 | echo STABLE_KUBERNETES_gitVersion $(kube_ver .)-hscloud-$(rev .) |