release: import options from jenkins script (#714)

* release: import options from jenkins script

* correct chdir

* limit parallel build threads

* VERSION_POSTFIX

* add postfix

* support BUILD_TYPE

* Removed unused.

* Fixed error [#CLICKHOUSE-2960].

* Fix version incrementing

* Fix message
This commit is contained in:
proller 2017-04-20 15:24:25 +03:00 committed by GitHub
parent 2d3e09af82
commit ebd6bb5da4
2 changed files with 74 additions and 45 deletions

63
release
View File

@ -1,34 +1,26 @@
#!/bin/bash #!/bin/bash
source "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/release_lib.sh" CURDIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
cd $CURDIR
source "./release_lib.sh"
CONTROL=debian/control CONTROL=debian/control
CHLOG=debian/changelog CHLOG=debian/changelog
CHDATE=$(LC_ALL=C date -R | sed -e 's/,/\\,/g') # Replace comma to '\,' CHDATE=$(LC_ALL=C date -R | sed -e 's/,/\\,/g') # Replace comma to '\,'
# Build a package with configuration files for Yandex.Metrika. DEBUILD_NOSIGN_OPTIONS="-us -uc"
BUILD_PACKAGE_FOR_METRIKA=$([ -f 'private/Server/metrika/config.xml' ] && echo 'yes')
while [[ $1 == --* ]] while [[ $1 == --* ]]
do do
# Don't sign packages, don't upload, don't create tags. if [[ $1 == '--test' ]]; then
if [[ $1 == '--standalone' ]]
then
STANDALONE='yes'
DEBUILD_NOSIGN_OPTIONS="-us -uc"
shift
elif [[ $1 == '--test' ]]
then
STANDALONE='yes'
TEST='yes' TEST='yes'
DEBUILD_NOSIGN_OPTIONS="-us -uc" VERSION_POSTFIX+=-test
shift shift
elif [[ $1 == '--ignore-deps' ]] elif [[ $1 == '--ignore-deps' ]]; then
then
DEBUILD_NODEPS_OPTIONS="-d" DEBUILD_NODEPS_OPTIONS="-d"
shift shift
elif [[ $1 == '--version' ]] elif [[ $1 == '--version' ]]; then
then
gen_revision_author gen_revision_author
git push git push
exit 0 exit 0
@ -38,22 +30,37 @@ do
fi fi
done done
if [[ $TEST != 'yes' ]] if [ -z "$REVISION" ] ; then
then
# now incrementing done in external release scripts via --version
get_revision_author get_revision_author
else
REVISION=99999
fi fi
# Build options
if [ -n "$SANITIZER" ]
then
CMAKE_BUILD_TYPE=$SANITIZER
VERSION_POSTFIX+=-${SANITIZER,,}
# todo: нужно ли отключить libtcmalloc?
LIBTCMALLOC_OPTS="-DENABLE_LIBTCMALLOC=0"
# GLIBC_COMPATIBILITY отключен по умолчанию
elif [[ $BUILD_TYPE == 'valgrind' ]]; then
LIBTCMALLOC_OPTS="-DENABLE_LIBTCMALLOC=0"
VERSION_POSTFIX+=-$BUILD_TYPE
elif [[ $BUILD_TYPE == 'debug' ]]; then
CMAKE_BUILD_TYPE=Debug
LIBTCMALLOC_OPTS="-DDEBUG_LIBTCMALLOC=1"
VERSION_POSTFIX+=-$BUILD_TYPE
fi
if [ -z "$THREAD_COUNT" ] ; then
THREAD_COUNT=`nproc || grep -c ^processor /proc/cpuinfo`
fi
CMAKE_FLAGS_ADD+=" $LIBTCMALLOC_OPTS -DCMAKE_BUILD_TYPE=$CMAKE_BUILD_TYPE"
REVISION+=$VERSION_POSTFIX
echo -e "\nCurrent revision is $REVISION" echo -e "\nCurrent revision is $REVISION"
gen_changelog "$REVISION" "$CHDATE" "$AUTHOR" "$CHLOG" gen_changelog "$REVISION" "$CHDATE" "$AUTHOR" "$CHLOG"
# Build (only binary packages). # Build (only binary packages).
debuild -eDEB_BUILD_OPTIONS=parallel=`nproc || grep -c ^processor /proc/cpuinfo` -e DEB_CC -e DEB_CXX -e CMAKE_FLAGS_ADD -b ${DEBUILD_NOSIGN_OPTIONS} ${DEBUILD_NODEPS_OPTIONS} debuild -e SSH_AUTH_SOCK -e DEB_BUILD_OPTIONS=parallel=$THREAD_COUNT -e DEB_CC -e DEB_CXX -e CMAKE_FLAGS_ADD="$CMAKE_FLAGS_ADD" -b ${DEBUILD_NOSIGN_OPTIONS} ${DEBUILD_NODEPS_OPTIONS}
if [[ $STANDALONE != 'yes' ]]
then
upload_debs "$REVISION"
fi

View File

@ -13,22 +13,44 @@ function make_control {
function gen_revision_author { function gen_revision_author {
REVISION=$(get_revision) REVISION=$(get_revision)
if [[ $STANDALONE != 'yes' ]] if [ -z $VERSION_PREFIX ] ; then
then VERSION_PREFIX="v1.1."
fi
if [ -z $VERSION_POSTFIX ] ; then
VERSION_POSTFIX="-testing"
fi
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)) REVISION=$(($REVISION + 1))
git_tag_grep=`git tag | grep "$VERSION_PREFIX$REVISION$VERSION_POSTFIX"`
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
auto_message="Auto version update to" auto_message="Auto version update to"
git_log_grep=`git log --oneline --max-count=1 | grep "$auto_message"` git_log_grep=`git log --oneline --max-count=1 | grep "$auto_message"`
if [ "$git_log_grep" == "" ]; then if [ "$git_log_grep" == "" ]; then
git fetch --tags
git_describe=`git describe` 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 sed -i -- "s/VERSION_REVISION .*)/VERSION_REVISION $REVISION)/g;s/VERSION_DESCRIBE .*)/VERSION_DESCRIBE $git_describe)/g" dbms/cmake/version.cmake
git commit -m "$auto_message [$REVISION]" dbms/cmake/version.cmake git commit -m "$auto_message [$REVISION]" dbms/cmake/version.cmake
#git push #git push
tag="v1.1.$REVISION-testing" tag="$VERSION_PREFIX$REVISION$VERSION_POSTFIX"
echo -e "\nTrying to create tag: $tag" echo -e "\nTrying to create tag: $tag"
if git tag -a "$tag" -m "$tag" if git tag -a "$tag" -m "$tag"