Skip to content

Commit 6520da4

Browse files
Jeff PeelerJay Boyd
Jeff Peeler
authored and
Jay Boyd
committed
catalog: add versioning for release build
Currently the version is derived from the upstream service catalog tag. also adds build date in ldflags
1 parent cfe9131 commit 6520da4

File tree

3 files changed

+17
-2
lines changed

3 files changed

+17
-2
lines changed

.tito/lib/origin/common.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ def get_os_git_vars():
3131
shell utilities. The git tree state is spoofed.
3232
"""
3333
git_vars = {}
34-
for var in ["COMMIT", "VERSION", "MAJOR", "MINOR"]:
34+
for var in ["COMMIT", "VERSION", "MAJOR", "MINOR", "CATALOG_VERSION"]:
3535
var_name = "OS_GIT_{}".format(var)
3636
git_vars[var_name] = run_command(
3737
"bash -c 'source ./hack/lib/init.sh; os::build::version::openshift_vars; echo ${}'".format(var_name)

hack/lib/build/version.sh

+15
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,21 @@ readonly -f os::build::version::get_vars
2626
function os::build::version::openshift_vars() {
2727
local git=(git --work-tree "${OS_ROOT}")
2828

29+
if [[ -z "${OS_GIT_CATALOG_VERSION:-}" ]]; then
30+
# search git merge commits for template text and extract version
31+
# subject template: Merge version v0.0.14 of Service Catalog from https://github.com/openshift/service-catalog:v0.0.14+origin
32+
summary_text="$(${git[@]} log --merges --grep "Merge version v.* of Service Catalog from https://github.com/openshift/service-catalog" --pretty=%s -1)"
33+
if [[ "${summary_text}" =~ Merge[[:space:]]version[[:space:]](v.*)[[:space:]]of[[:space:]]Service[[:space:]]Catalog ]]; then
34+
OS_GIT_CATALOG_VERSION="${BASH_REMATCH[1]}"
35+
else
36+
os::log::fatal "Unable to find version for service catalog - (this should never happen)"
37+
fi
38+
39+
if git_status=$("${git[@]}" status --porcelain cmd/service-catalog 2>/dev/null) && [[ -n ${git_status} ]]; then
40+
OS_GIT_CATALOG_VERSION+="dirty"
41+
fi
42+
fi
43+
2944
if [[ -n ${OS_GIT_COMMIT-} ]] || OS_GIT_COMMIT=$("${git[@]}" rev-parse --short "HEAD^{commit}" 2>/dev/null); then
3045
if [[ -z ${OS_GIT_TREE_STATE-} ]]; then
3146
# Check if the tree is dirty. default to dirty

origin.spec

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
%global shortcommit %(c=%{commit}; echo ${c:0:7})
2727
# os_git_vars needed to run hack scripts during rpm builds
2828
%{!?os_git_vars:
29-
%global os_git_vars OS_GIT_VERSION='' OS_GIT_COMMIT='' OS_GIT_MAJOR='' OS_GIT_MINOR='' OS_GIT_TREE_STATE=''
29+
%global os_git_vars OS_GIT_VERSION='' OS_GIT_COMMIT='' OS_GIT_MAJOR='' OS_GIT_MINOR='' OS_GIT_TREE_STATE='' OS_GIT_CATALOG_VERSION=''
3030
}
3131

3232
%if 0%{?fedora} || 0%{?epel}

0 commit comments

Comments
 (0)