summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSébastien Helleu <flashcode@flashtux.org>2023-03-24 19:02:59 +0100
committerSébastien Helleu <flashcode@flashtux.org>2023-04-02 14:01:21 +0200
commit058c9f8b84e156bde3e54517ea8eb6108681c0a3 (patch)
tree40d5b3ead11cc0a546e914869c36a1ea40e6c1a3
parentff85d00e7f565963c6cb7443ca763254fa6fe9cd (diff)
downloadweechat-058c9f8b84e156bde3e54517ea8eb6108681c0a3.zip
core: add script bump_version.sh
-rwxr-xr-xtools/bump_version.sh63
1 files changed, 63 insertions, 0 deletions
diff --git a/tools/bump_version.sh b/tools/bump_version.sh
new file mode 100755
index 000000000..4e9e86c19
--- /dev/null
+++ b/tools/bump_version.sh
@@ -0,0 +1,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 (`devel` becomes the `stable`)
+# major bump the major version, set minor + patch to 0
+# minor bump the minor version, set patch to 0
+# patch bump the 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}/" \
+ -e "s/^\(WEECHAT_DEVEL_FULL\)=.*/\1=${NEW_DEVEL_FULL}/" \
+ "${ROOT_DIR}/version.sh"