mirror of https://github.com/kubernetes/kops.git
bazel: stamp version into build
This commit is contained in:
parent
57ceb5dbab
commit
39d4f21954
|
@ -115,6 +115,10 @@ go_binary(
|
||||||
name = "kops",
|
name = "kops",
|
||||||
library = ":go_default_library",
|
library = ":go_default_library",
|
||||||
visibility = ["//visibility:public"],
|
visibility = ["//visibility:public"],
|
||||||
|
x_defs = {
|
||||||
|
"k8s.io/kops.Version": "1.8.0-alpha.1", # keep
|
||||||
|
"k8s.io/kops.GitVersion": "{BUILD_SCM_REVISION}", # keep
|
||||||
|
},
|
||||||
)
|
)
|
||||||
|
|
||||||
go_test(
|
go_test(
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
build --workspace_status_command=./tools/get_workspace_status
|
|
@ -0,0 +1,30 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# This script will be run bazel when building 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.
|
||||||
|
|
||||||
|
# The code below presents an implementation that works for git repository
|
||||||
|
git_rev=$(git rev-parse HEAD)
|
||||||
|
if [[ $? != 0 ]];
|
||||||
|
then
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
echo "BUILD_SCM_REVISION ${git_rev}"
|
||||||
|
|
||||||
|
# Check whether there are any uncommited changes
|
||||||
|
git diff-index --quiet HEAD --
|
||||||
|
if [[ $? == 0 ]];
|
||||||
|
then
|
||||||
|
tree_status="Clean"
|
||||||
|
else
|
||||||
|
tree_status="Modified"
|
||||||
|
fi
|
||||||
|
echo "BUILD_SCM_STATUS ${tree_status}"
|
||||||
|
|
Loading…
Reference in New Issue