Mercurial > hg > monetdb-java
view version.sh @ 949:ec7530f615bf
Support getting rid of version suffix.
author | Sjoerd Mullender <sjoerd@acm.org> |
---|---|
date | Mon, 13 Jan 2025 12:47:31 +0100 (2 months ago) |
parents | d416e9b6b3d0 |
children | a2033b220db0 |
line wrap: on
line source
#!/usr/bin/env bash # SPDX-License-Identifier: MPL-2.0 # # This Source Code Form is subject to the terms of the Mozilla Public # License, v. 2.0. If a copy of the MPL was not distributed with this # file, You can obtain one at http://mozilla.org/MPL/2.0/. # # Copyright 2024, 2025 MonetDB Foundation; # Copyright August 2008 - 2023 MonetDB B.V.; # Copyright 1997 - July 2008 CWI. if [[ -z $1 ]] ; then echo "Usage: $0 [-w] jdbc <(major|minor|suffix)=newversion> [...]" echo "where -w activates actual write of changes" exit -1 fi PROPERTIES='build.properties' get_value() { local tmp=$(grep -E "^$*=" ${PROPERTIES}) echo ${tmp#*=} } escape_value() { echo "$*" | sed -e 's/\*/\\*/g' -e 's/\./\\./g' } patch="cat" # get rid of the script name case $1 in -w) patch="patch -p0"; shift ;; esac case $1 in jdbc) TYPE=JDBC FILES="monetdb-jdbc-XXX.jar" ;; *) echo "invalid type: $1" exit -1 ;; esac shift CUR_MAJOR=$(eval "get_value '${TYPE}_MAJOR'") CUR_MINOR=$(eval "get_value '${TYPE}_MINOR'") CUR_SUFFIX=$(eval "get_value '${TYPE}_VER_SUFFIX'") NEW_MAJOR=${CUR_MAJOR} NEW_MINOR=${CUR_MINOR} NEW_SUFFIX=${CUR_SUFFIX} ESC_MAJOR=$(escape_value ${CUR_MAJOR}) ESC_MINOR=$(escape_value ${CUR_MINOR}) ESC_SUFFIX=$(escape_value ${CUR_SUFFIX}) for param in $* ; do arg=${param%%=*} val=${param#*=} num=$(echo ${val} | grep -E '[0-9]+' -o | head -n1) case ${arg} in major) if [[ -z ${num} ]] ; then echo "major needs a numeric argument!"; exit -1 fi NEW_MAJOR=${num} ;; minor) if [[ -z ${num} ]] ; then echo "minor needs a numeric argument!"; exit -1 fi NEW_MINOR=${num} ;; suffix) NEW_SUFFIX=${val} ;; esac done if [[ -n $CUR_SUFFIX ]]; then CUR_SUFFIX_p=" (${CUR_SUFFIX})" ESC_SUFFIX_p=" (${ESC_SUFFIX})" fi if [[ -n $NEW_SUFFIX ]]; then NEW_SUFFIX_p=" (${NEW_SUFFIX})" fi echo "Current version: ${CUR_MAJOR}.${CUR_MINOR}${CUR_SUFFIX_p}" echo "New version: ${NEW_MAJOR}.${NEW_MINOR}${NEW_SUFFIX_p}" diff="diff -Naur" file="release.txt" sed \ -e "s|version ${ESC_MAJOR}\.${ESC_MINOR}${ESC_SUFFIX_p}|version ${NEW_MAJOR}.${NEW_MINOR}${NEW_SUFFIX_p}|g" \ -e "s|${TYPE}-${ESC_MAJOR}\.${ESC_MINOR}|${TYPE}-${NEW_MAJOR}.${NEW_MINOR}|g" \ -e "s|Release date: 20[0-9][0-9]-[01][0-9]-[0-3][0-9]|Release date: `date +%F`|" \ ${file} | ${diff} ${file} - | ${patch} file="build.properties" sed \ -e "s|${TYPE}_MAJOR=${ESC_MAJOR}|${TYPE}_MAJOR=${NEW_MAJOR}|g" \ -e "s|${TYPE}_MINOR=${ESC_MINOR}|${TYPE}_MINOR=${NEW_MINOR}|g" \ -e "s|${TYPE}_VER_SUFFIX=${ESC_SUFFIX}|${TYPE}_VER_SUFFIX=${NEW_SUFFIX}|g" \ ${file} | ${diff} ${file} - | ${patch} file="pom.xml" sed \ -e "/monetdb-jdbc/,/MonetDB JDBC driver/s|<version>${ESC_MAJOR}\.${ESC_MINOR}</version>|<version>${NEW_MAJOR}.${NEW_MINOR}</version>|g" \ ${file} | ${diff} ${file} - | ${patch}