blob: 56a3d4d5163b91407ce7adf6732b52c2249bc35f [file] [log] [blame]
Robert Gerusf1bdb9a2019-07-21 15:24:52 +02001#!/usr/bin/env bash
Sergiusz Bazanski573da782019-06-21 19:59:52 +02002
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
13function rev() {
14 cd $1; git describe --always --match "v[0-9].*" --dirty
15}
16
Serge Bazanskie23717d2020-11-03 20:08:23 +010017# Get Kubernetes version by doing an ugly grep. This returns something line 'v1.19.3'.
18function 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
23KUBE_MAJOR=$(kube_ver . | sed -e 's,v,,' | cut -d . -f 1)
24KUBE_MINOR=$(kube_ver . | sed -e 's,v,,' | cut -d . -f 2)
25KUBE_PATCH=$(kube_ver . | sed -e 's,v,,' | cut -d . -f 3)
26
Sergiusz Bazanski573da782019-06-21 19:59:52 +020027echo STABLE_BUILD_GERRIT-OAUTH-PROVIDER_LABEL $(rev .)
Sergiusz Bazanski222a00a2020-04-12 18:37:21 +020028echo STABLE_BUILD_OWNERS_LABEL $(rev .)
Sergiusz Bazanski8fe651b2019-07-21 23:50:05 +020029echo STABLE_GIT_COMMIT $(git rev-parse HEAD)
30echo STABLE_GIT_VERSION $(rev .)
31echo STABLE_BUILDER $(id -un)@$(hostname -f):$(pwd)
Serge Bazanskie23717d2020-11-03 20:08:23 +010032
33# Kubernetes compatibility - see //third_party/go/kubernetes:version.bzl.
34echo STABLE_KUBERNETES_buildDate $(date -u +'%Y-%m-%dT%H:%M:%SZ')
35echo STABLE_KUBERNETES_gitCommit $(git rev-parse HEAD)
36echo STABLE_KUBERNETES_gitMajor $KUBE_MAJOR
37echo STABLE_KUBERNETES_gitMinor $KUBE_MINOR
38if git_status=$(git status --porcelain 2>/dev/null) && [[ -z ${git_status} ]]; then
39 echo STABLE_KUBERNETES_gitTreeState clean
40else
41 echo STABLE_KUBERNETES_gitTreeState dirty
42fi
43echo STABLE_KUBERNETES_gitVersion $(kube_ver .)-hscloud-$(rev .)