blob: a45280e1fb5e720c4a22c24716194197871a0e4e (
plain)
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
|
#!/bin/sh
#
# Copyright (C) 2023 Sébastien Helleu <flashcode@flashtux.org>
#
# This file is part of WeeChat, the extensible chat client.
#
# WeeChat is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
# WeeChat is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with WeeChat. If not, see <https://www.gnu.org/licenses/>.
#
#
# Returns current stable or devel version of WeeChat.
#
# Syntax:
# bump_version.sh stable|major|minor|patch
#
# stable bump to the next stable: set stable and devel to
# `devel` value, with only digits and dots
# major bump the devel major version, set minor + patch to 0
# minor bump the devel minor version, set patch to 0
# patch bump the devel patch version
#
set -o errexit
if [ $# -lt 1 ]; then
echo >&2 "usage: $0 stable|major|minor|patch"
exit 1
fi
ROOT_DIR=$(git rev-parse --show-toplevel)
NEW_STABLE=$("${ROOT_DIR}/version.sh" stable)
NEW_DEVEL=$("${ROOT_DIR}/version.sh" devel)
NEW_DEVEL_FULL=$("${ROOT_DIR}/version.sh" devel-full)
case "$1" in
stable ) NEW_STABLE="${NEW_DEVEL}"
NEW_DEVEL_FULL="${NEW_DEVEL}" ;;
major ) NEW_DEVEL=$(echo "${NEW_DEVEL}" | awk -F. '{$(NF-2) = $(NF-2) + 1; $(NF-1) = 0; $NF = 0; print}' OFS=.)
NEW_DEVEL_FULL="${NEW_DEVEL}-dev" ;;
minor ) NEW_DEVEL=$(echo "$NEW_DEVEL" | awk -F. '{$(NF-1) = $(NF-1) + 1; $NF = 0; print}' OFS=.)
NEW_DEVEL_FULL="${NEW_DEVEL}-dev" ;;
patch ) NEW_DEVEL=$(echo "$NEW_DEVEL" | awk -F. '{$NF = $NF + 1; print} ' OFS=.)
NEW_DEVEL_FULL="${NEW_DEVEL}-dev" ;;
* ) echo >&2 "ERROR: unknown version."
exit 1 ;;
esac
sed -i \
-e "s/^\(WEECHAT_STABLE\)=.*/\1=\"${NEW_STABLE}\"/" \
-e "s/^\(WEECHAT_DEVEL\)=.*/\1=\"${NEW_DEVEL_FULL}\"/" \
"${ROOT_DIR}/version.sh"
|