2017-08-30 15:20:59 +00:00
|
|
|
set +e
|
|
|
|
|
2017-02-01 14:05:03 +00:00
|
|
|
function get_revision {
|
2017-04-05 11:52:23 +00:00
|
|
|
BASEDIR=$(dirname "${BASH_SOURCE[0]}")
|
|
|
|
grep "set(VERSION_REVISION" ${BASEDIR}/dbms/cmake/version.cmake | sed 's/^.*VERSION_REVISION \(.*\))$/\1/'
|
2017-02-01 14:05:03 +00:00
|
|
|
}
|
2016-03-18 12:17:08 +00:00
|
|
|
|
2017-08-18 13:25:14 +00:00
|
|
|
function get_author {
|
|
|
|
AUTHOR=$(git config --get user.name || echo ${USER})
|
|
|
|
echo $AUTHOR
|
2016-02-07 21:58:58 +00:00
|
|
|
}
|
|
|
|
|
2017-05-07 20:25:26 +00:00
|
|
|
# Generate revision number.
|
|
|
|
# set environment variables REVISION, AUTHOR
|
2016-02-07 21:58:58 +00:00
|
|
|
function gen_revision_author {
|
2017-04-05 11:52:23 +00:00
|
|
|
REVISION=$(get_revision)
|
2017-06-07 06:52:46 +00:00
|
|
|
VERSION_PREFIX="${VERSION_PREFIX:-v1.1.}"
|
|
|
|
VERSION_POSTFIX="${VERSION_POSTFIX:--testing}"
|
2017-04-20 12:24:25 +00:00
|
|
|
|
|
|
|
if [[ $STANDALONE != 'yes' ]]; then
|
|
|
|
|
|
|
|
git fetch --tags
|
|
|
|
|
|
|
|
succeeded=0
|
|
|
|
attempts=0
|
|
|
|
max_attempts=1000
|
|
|
|
while [ $succeeded -eq 0 ] && [ $attempts -le $max_attempts ]; do
|
|
|
|
attempts=$(($attempts + 1))
|
|
|
|
REVISION=$(($REVISION + 1))
|
2017-08-30 15:20:59 +00:00
|
|
|
git_tag_grep=`git tag | grep "$VERSION_PREFIX$REVISION$VERSION_POSTFIX"`
|
2017-04-20 12:24:25 +00:00
|
|
|
if [ "$git_tag_grep" == "" ]; then
|
|
|
|
succeeded=1
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
if [ $succeeded -eq 0 ]; then
|
|
|
|
echo "Fail to create revision up to $REVISION"
|
|
|
|
exit 1
|
|
|
|
fi
|
2017-04-18 10:05:14 +00:00
|
|
|
|
|
|
|
auto_message="Auto version update to"
|
2017-08-30 15:20:59 +00:00
|
|
|
git_log_grep=`git log --oneline --max-count=1 | grep "$auto_message"`
|
2017-04-18 10:05:14 +00:00
|
|
|
if [ "$git_log_grep" == "" ]; then
|
2017-04-20 12:24:25 +00:00
|
|
|
tag="$VERSION_PREFIX$REVISION$VERSION_POSTFIX"
|
2017-04-05 11:52:23 +00:00
|
|
|
|
2017-04-20 12:42:18 +00:00
|
|
|
# First tag for correct git describe
|
2017-04-05 11:52:23 +00:00
|
|
|
echo -e "\nTrying to create tag: $tag"
|
2017-08-30 15:20:59 +00:00
|
|
|
git tag -a "$tag" -m "$tag"
|
2017-04-20 12:50:00 +00:00
|
|
|
|
|
|
|
git_describe=`git describe`
|
|
|
|
sed -i -- "s/VERSION_REVISION .*)/VERSION_REVISION $REVISION)/g;s/VERSION_DESCRIBE .*)/VERSION_DESCRIBE $git_describe)/g" dbms/cmake/version.cmake
|
2017-08-17 16:49:23 +00:00
|
|
|
|
2017-08-18 13:25:14 +00:00
|
|
|
gen_changelog "$REVISION" "" "$AUTHOR" ""
|
2017-08-17 16:49:23 +00:00
|
|
|
git commit -m "$auto_message [$REVISION]" dbms/cmake/version.cmake debian/changelog
|
2017-04-20 12:50:00 +00:00
|
|
|
#git push
|
|
|
|
|
|
|
|
# Second tag for correct version information in version.cmake inside tag
|
|
|
|
if git tag --force -a "$tag" -m "$tag"
|
2017-04-05 11:52:23 +00:00
|
|
|
then
|
|
|
|
echo -e "\nTrying to push tag to origin: $tag"
|
|
|
|
git push origin "$tag"
|
|
|
|
if [ $? -ne 0 ]
|
|
|
|
then
|
|
|
|
git tag -d "$tag"
|
2017-04-18 10:05:14 +00:00
|
|
|
echo "Fail to create tag"
|
|
|
|
exit 1
|
2017-04-05 11:52:23 +00:00
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
else
|
|
|
|
REVISION=$(get_revision)
|
|
|
|
echo reusing old version $REVISION
|
|
|
|
fi
|
|
|
|
|
|
|
|
fi
|
|
|
|
|
2017-07-17 12:48:55 +00:00
|
|
|
AUTHOR=$(git config --get user.name || echo ${USER})
|
2017-04-05 11:52:23 +00:00
|
|
|
export REVISION
|
|
|
|
export AUTHOR
|
2016-02-07 21:58:58 +00:00
|
|
|
}
|
|
|
|
|
2017-03-16 15:35:50 +00:00
|
|
|
function get_revision_author {
|
2017-04-05 11:52:23 +00:00
|
|
|
REVISION=$(get_revision)
|
2017-08-18 13:25:14 +00:00
|
|
|
AUTHOR=$(get_author)
|
2017-04-05 11:52:23 +00:00
|
|
|
export REVISION
|
|
|
|
export AUTHOR
|
2017-03-16 15:35:50 +00:00
|
|
|
}
|
|
|
|
|
2017-05-07 20:25:26 +00:00
|
|
|
# Generate changelog from changelog.in.
|
|
|
|
# changes
|
2016-02-07 21:58:58 +00:00
|
|
|
# programs/CMakeLists.txt
|
|
|
|
# dbms/src/CMakeLists.txt
|
|
|
|
function gen_changelog {
|
2017-04-05 11:52:23 +00:00
|
|
|
REVISION="$1"
|
|
|
|
CHDATE="$2"
|
|
|
|
AUTHOR="$3"
|
|
|
|
CHLOG="$4"
|
2017-08-18 13:25:14 +00:00
|
|
|
if [ -z "REVISION" ] ; then
|
|
|
|
get_revision_author
|
|
|
|
fi
|
|
|
|
|
2017-08-18 01:32:52 +00:00
|
|
|
if [ -z "$CHLOG" ] ; then
|
|
|
|
CHLOG=debian/changelog
|
|
|
|
fi
|
2017-04-05 11:52:23 +00:00
|
|
|
|
2017-08-18 13:25:14 +00:00
|
|
|
if [ -z "$CHDATE" ] ; then
|
|
|
|
CHDATE=$(LC_ALL=C date -R | sed -e 's/,/\\,/g') # Replace comma to '\,'
|
|
|
|
fi
|
|
|
|
|
2017-04-05 11:52:23 +00:00
|
|
|
sed \
|
|
|
|
-e "s/[@]REVISION[@]/$REVISION/g" \
|
|
|
|
-e "s/[@]DATE[@]/$CHDATE/g" \
|
|
|
|
-e "s/[@]AUTHOR[@]/$AUTHOR/g" \
|
|
|
|
-e "s/[@]EMAIL[@]/$(whoami)@yandex-team.ru/g" \
|
|
|
|
< $CHLOG.in > $CHLOG
|
2016-02-07 21:58:58 +00:00
|
|
|
}
|