Skip to content

Commit 94a8176

Browse files
tuhaiheedespino
andcommitted
Update the version generation logic and info
Fow now, if we build Cloudberry from a source zip file (not using git clone), the version information displayed is not matched the right info, always return 1.0.0 like this: ``` PostgreSQL 14.4 (Apache Cloudberry 1.0.0 build dev) ``` In this PR, these changes are made: - Update the PACKAGE_VERSION string from 1.0.0 to 2.0.0-devel - Generate the new configure file with the new configure.ac - Rewrite the `getversion` with a new logic to meet a various version demands for packaging and diagnostics, see the details in the `getversion` file. Co-authored-by: Ed Espino <espino@apache.org>
1 parent f4ad0f7 commit 94a8176

4 files changed

Lines changed: 112 additions & 39 deletions

File tree

configure

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#! /bin/sh
22
# Guess values for system-dependent variables and create Makefiles.
3-
# Generated by GNU Autoconf 2.69 for Apache Cloudberry 1.0.0.
3+
# Generated by GNU Autoconf 2.69 for Apache Cloudberry 2.0.0-devel.
44
#
55
# Report bugs to <dev@cloudberry.apache.org>.
66
#
@@ -582,8 +582,8 @@ MAKEFLAGS=
582582
# Identity of this package.
583583
PACKAGE_NAME='Apache Cloudberry'
584584
PACKAGE_TARNAME='apache-cloudberry'
585-
PACKAGE_VERSION='1.0.0'
586-
PACKAGE_STRING='Apache Cloudberry 1.0.0'
585+
PACKAGE_VERSION='2.0.0-devel'
586+
PACKAGE_STRING='Apache Cloudberry 2.0.0-devel'
587587
PACKAGE_BUGREPORT='dev@cloudberry.apache.org'
588588
PACKAGE_URL='https://cloudberry.apache.org/'
589589

@@ -1513,7 +1513,7 @@ if test "$ac_init_help" = "long"; then
15131513
# Omit some internal or obsolete options to make the list less imposing.
15141514
# This message is too long to be a string in the A/UX 3.1 sh.
15151515
cat <<_ACEOF
1516-
\`configure' configures Apache Cloudberry 1.0.0 to adapt to many kinds of systems.
1516+
\`configure' configures Apache Cloudberry 2.0.0-devel to adapt to many kinds of systems.
15171517

15181518
Usage: $0 [OPTION]... [VAR=VALUE]...
15191519

@@ -1579,7 +1579,7 @@ fi
15791579

15801580
if test -n "$ac_init_help"; then
15811581
case $ac_init_help in
1582-
short | recursive ) echo "Configuration of Apache Cloudberry 1.0.0:";;
1582+
short | recursive ) echo "Configuration of Apache Cloudberry 2.0.0-devel:";;
15831583
esac
15841584
cat <<\_ACEOF
15851585

@@ -1782,7 +1782,7 @@ fi
17821782
test -n "$ac_init_help" && exit $ac_status
17831783
if $ac_init_version; then
17841784
cat <<\_ACEOF
1785-
Apache Cloudberry configure 1.0.0
1785+
Apache Cloudberry configure 2.0.0-devel
17861786
generated by GNU Autoconf 2.69
17871787

17881788
Copyright (C) 2012 Free Software Foundation, Inc.
@@ -2535,7 +2535,7 @@ cat >config.log <<_ACEOF
25352535
This file contains any messages produced by compilers while
25362536
running configure, to aid debugging if configure makes a mistake.
25372537

2538-
It was created by Apache Cloudberry $as_me 1.0.0, which was
2538+
It was created by Apache Cloudberry $as_me 2.0.0-devel, which was
25392539
generated by GNU Autoconf 2.69. Invocation command line was
25402540

25412541
$ $0 $@
@@ -23334,7 +23334,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
2333423334
# report actual input values of CONFIG_FILES etc. instead of their
2333523335
# values after options handling.
2333623336
ac_log="
23337-
This file was extended by Apache Cloudberry $as_me 1.0.0, which was
23337+
This file was extended by Apache Cloudberry $as_me 2.0.0-devel, which was
2333823338
generated by GNU Autoconf 2.69. Invocation command line was
2333923339

2334023340
CONFIG_FILES = $CONFIG_FILES
@@ -23405,7 +23405,7 @@ _ACEOF
2340523405
cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
2340623406
ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`"
2340723407
ac_cs_version="\\
23408-
Apache Cloudberry config.status 1.0.0
23408+
Apache Cloudberry config.status 2.0.0-devel
2340923409
configured by $0, generated by GNU Autoconf 2.69,
2341023410
with options \\"\$ac_cs_config\\"
2341123411

configure.ac

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ m4_pattern_forbid(^PGAC_)dnl to catch undefined macros
2020
dnl The PACKAGE_VERSION from upstream PostgreSQL is maintained in the
2121
dnl PG_PACKAGE_VERSION variable, when merging make sure to update this
2222
dnl variable with the merge conflict from the AC_INIT() statement.
23-
AC_INIT([Apache Cloudberry], [1.0.0], [dev@cloudberry.apache.org], [], [https://cloudberry.apache.org/])
23+
AC_INIT([Apache Cloudberry], [2.0.0-devel], [dev@cloudberry.apache.org], [], [https://cloudberry.apache.org/])
2424
[PG_PACKAGE_VERSION=14.4]
2525
AC_SUBST(PG_PACKAGE_VERSION)
2626

getversion

Lines changed: 101 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,46 +1,119 @@
11
#!/usr/bin/env bash
2+
# ======================================================================
3+
#
4+
# Licensed to the Apache Software Foundation (ASF) under one or more
5+
# contributor license agreements. See the NOTICE file distributed with
6+
# this work for additional information regarding copyright ownership.
7+
# The ASF licenses this file to You under the Apache License, Version 2.0
8+
# (the "License"); you may not use this file except in compliance with
9+
# the License. You may obtain a copy of the License at
10+
#
11+
# http://www.apache.org/licenses/LICENSE-2.0
12+
#
13+
# Unless required by applicable law or agreed to in writing, software
14+
# distributed under the License is distributed on an "AS IS" BASIS,
15+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16+
# See the License for the specific language governing permissions and
17+
# limitations under the License.
18+
#
19+
# -----------------------------------------------------------------------------
20+
# getversion — determine the project version for packaging and diagnostics
21+
# -----------------------------------------------------------------------------
22+
#
23+
# This script computes a version string using the following logic:
24+
#
25+
# 1. Extract the base PACKAGE_VERSION from the `configure` script.
26+
#
27+
# 2. If running inside a Git repository and `git describe` is usable:
28+
#
29+
# a. If the current commit matches an annotated tag exactly:
30+
# VERSION = <tag>
31+
# e.g., VERSION = 2.0.0+RC1
32+
#
33+
# b. If the current commit is ahead of a tag:
34+
# VERSION = <PACKAGE_VERSION>+dev.<N>.g<commit>
35+
# e.g., VERSION = 2.0.1-devel+dev.3.gabcd123
36+
#
37+
# 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>")
39+
#
40+
# 4. If neither a Git repo nor a VERSION file is present:
41+
# VERSION = <PACKAGE_VERSION> from configure
42+
# BUILDNUMBER = dev
43+
#
44+
# 5. If a BUILD_NUMBER file is present and BUILDNUMBER is "dev", it will override the default:
45+
# BUILDNUMBER = $(cat BUILD_NUMBER)
46+
#
47+
# Output:
48+
# - Default: <version> build <build_number>
49+
# - With --short: just <version>
50+
#
51+
# Examples:
52+
# ./getversion
53+
# → 2.0.1-devel+dev.3.gabcd123 build dev
54+
#
55+
# ./getversion --short
56+
# → 2.0.1-devel+dev.3.gabcd123
57+
#
58+
# (On exact tag)
59+
# → 2.0.0+RC1 build dev
60+
#
61+
# Supported Features:
62+
# - Handles annotated tags with special characters like `+` or `-`
63+
# - Produces semver-compatible version strings for CI/CD
64+
# - Works with or without Git
65+
#
66+
# Intended for use in:
67+
# - Release packaging
68+
# - Diagnostic reporting
69+
# - Embedding traceable version info into builds
70+
#
71+
# ======================================================================
272

3-
# Make sure we're running from the root git repository, not whatever submodule
4-
# we could have been called from.
5-
pushd $(dirname "$0") > /dev/null
73+
# Make sure we're running from the root git repository
74+
pushd "$(dirname "$0")" > /dev/null
675

7-
VERSION=$(perl -e 'while(<>){print $1 if (/^PACKAGE_VERSION='\''(.+)'\''$/)}' < configure)
76+
# Extract PACKAGE_VERSION from the configure script
77+
VERSION=$(perl -ne 'print $1 if /^PACKAGE_VERSION='\''(.+)'\''$/' < configure)
878
BUILDNUMBER=dev
979

10-
# Call git describe, and convert it to a semi-semantic version, like
11-
# 5.0.0-alpha.0+dev.52.g123abc
80+
# Function to generate a dev suffix like "dev.1.gabcd123"
1281
generate_dev_version() {
13-
git describe | perl -pe 's/(.*)-([0-9]*)-(g[0-9a-f]*)/\1+dev.\2.\3/'
82+
local latest_tag
83+
latest_tag=$(git describe --tags --abbrev=0)
84+
local full_desc
85+
full_desc=$(git describe --tags --long)
86+
local suffix="${full_desc#$latest_tag-}"
87+
echo "dev.${suffix//-/.}"
1488
}
1589

16-
# If we are in a Git repository and have git installed, build the version
17-
# string using the latest tag in case it's reachable
18-
if type git >/dev/null 2>&1 && [ -d '.git' ] ; then
19-
20-
# Check for tag reachability, in case of shallow clones we might not
21-
# be able to use git describe since the commit which was tagged is
22-
# unreachable even if we have pulled the tags. If we can reach it,
23-
# overwrite the VERSION from autoconf with the output, else append
24-
# HEAD commit info
25-
if git describe >/dev/null 2>&1 ; then
26-
VERSION=$(generate_dev_version)
27-
else
28-
VERSION+=+
29-
VERSION+=$(git rev-parse --short HEAD)
30-
fi
31-
# If not a git repository and VERSION file exists, use version string from file.
90+
# Check if we're in a Git repo and git is available
91+
if type git >/dev/null 2>&1 && [ -d '.git' ]; then
92+
# Ensure git describe doesn't fail due to shallow clone
93+
if git describe --tags --long >/dev/null 2>&1; then
94+
if git describe --exact-match >/dev/null 2>&1; then
95+
# We're exactly on a tag
96+
VERSION=$(git describe --exact-match)
97+
else
98+
# Not on a tag: add dev version suffix
99+
VERSION+="+$(generate_dev_version)"
100+
fi
101+
fi
102+
# Not a git repo but VERSION file exists
32103
elif [[ -s ./VERSION ]]; then
33-
VERSION=$(awk -F' build ' '{print $1}' ./VERSION)
34-
BUILDNUMBER=$(awk -F' build ' '{print $2}' ./VERSION)
104+
VERSION=$(awk -F' build ' '{print $1}' ./VERSION)
105+
BUILDNUMBER=$(awk -F' build ' '{print $2}' ./VERSION)
35106
fi
36107

108+
# Handle optional flag
37109
FLAG="${1:-noflag}"
38-
if [ "$FLAG" = '--short' ] ; then
110+
if [ "$FLAG" = "--short" ]; then
39111
echo "${VERSION}"
40112
else
41-
if [[ ${BUILDNUMBER} = 'dev' && -f BUILD_NUMBER ]] ; then
42-
BUILDNUMBER=`cat BUILD_NUMBER`
113+
if [[ ${BUILDNUMBER} = "dev" && -f BUILD_NUMBER ]]; then
114+
BUILDNUMBER=$(<BUILD_NUMBER)
43115
fi
44116
echo "${VERSION} build ${BUILDNUMBER}"
45117
fi
118+
46119
popd > /dev/null

gpMgmt/bin/gppylib/gpversion.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
% os.path.split(__file__)[-1])
1919
sys.exit(1)
2020

21-
MAIN_VERSION = [1,99] # version number for main
21+
MAIN_VERSION = [2,99] # version number for main
2222

2323

2424
#============================================================

0 commit comments

Comments
 (0)