-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathversion.sh
executable file
·92 lines (76 loc) · 2.15 KB
/
version.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
#!/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] <(major|minor)=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
CUR_MAJOR=$(eval "get_value 'JDBC_MAJOR'")
CUR_MINOR=$(eval "get_value 'JDBC_MINOR'")
NEW_MAJOR=${CUR_MAJOR}
NEW_MINOR=${CUR_MINOR}
ESC_MAJOR=$(escape_value ${CUR_MAJOR})
ESC_MINOR=$(escape_value ${CUR_MINOR})
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}
;;
esac
done
echo "Current version: ${CUR_MAJOR}.${CUR_MINOR}"
echo "New version: ${NEW_MAJOR}.${NEW_MINOR}"
diff="diff -Naur"
file="release.txt"
sed \
-e "s|version ${ESC_MAJOR}\.${ESC_MINOR}|version ${NEW_MAJOR}.${NEW_MINOR}|g" \
-e "s|JDBC-${ESC_MAJOR}\.${ESC_MINOR}|JDBC-${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|JDBC_MAJOR=${ESC_MAJOR}|JDBC_MAJOR=${NEW_MAJOR}|g" \
-e "s|JDBC_MINOR=${ESC_MINOR}|JDBC_MINOR=${NEW_MINOR}|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}