Skip to content

Commit 9f37357

Browse files
edespinotuhaihe
authored andcommitted
Support new VERSION/BUILD\_NUMBER files for non-Git versioning fallback
Enhances `getversion` to handle both legacy and new formats for versioning in non-Git environments. Specifically: * If the `VERSION` file contains a line like `<version> build <build_number>`, both values are extracted as before. * If `VERSION` is a single line and `BUILD_NUMBER` exists, they are combined. This supports Apache Cloudberry packaging conventions while maintaining backward compatibility with earlier versioning styles. Header documentation updated to clarify both paths.
1 parent a3bcbcb commit 9f37357

1 file changed

Lines changed: 17 additions & 3 deletions

File tree

getversion

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,13 @@
3535
# e.g., VERSION = 2.0.1-devel+dev.3.gabcd123
3636
#
3737
# 3. If *not* in a Git repo but a `VERSION` file exists:
38-
# VERSION and BUILDNUMBER are read from that file (format: "<version> build <build_number>")
38+
#
39+
# a. If the file contains a line like "<version> build <build_number>", both values are extracted.
40+
#
41+
# b. Otherwise, the VERSION is read from the file and the BUILDNUMBER is taken from BUILD_NUMBER if it exists.
42+
#
43+
# (This is the case for Apache Cloudberry packaging builds, where these files are created by the
44+
# release script and may also be leveraged by downstream users.)
3945
#
4046
# 4. If neither a Git repo nor a VERSION file is present:
4147
# VERSION = <PACKAGE_VERSION> from configure
@@ -101,8 +107,16 @@ if type git >/dev/null 2>&1 && [ -d '.git' ]; then
101107
fi
102108
# Not a git repo but VERSION file exists
103109
elif [[ -s ./VERSION ]]; then
104-
VERSION=$(awk -F' build ' '{print $1}' ./VERSION)
105-
BUILDNUMBER=$(awk -F' build ' '{print $2}' ./VERSION)
110+
# Support both legacy "<version> build <build_number>" and newer single-version formats
111+
if grep -q ' build ' ./VERSION; then
112+
VERSION=$(awk -F' build ' '{print $1}' ./VERSION)
113+
BUILDNUMBER=$(awk -F' build ' '{print $2}' ./VERSION)
114+
else
115+
VERSION=$(<./VERSION)
116+
if [[ -f ./BUILD_NUMBER ]]; then
117+
BUILDNUMBER=$(<./BUILD_NUMBER)
118+
fi
119+
fi
106120
fi
107121

108122
# Handle optional flag

0 commit comments

Comments
 (0)