From fd98482eed066f05dcf3a71bc2343c1ef189e6cc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Kol=C3=A1rik?= Date: Mon, 11 Nov 2024 16:32:59 +0100 Subject: [PATCH] Helper script to create and possibly push annotated release tag --- scripts/release-tag.sh | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100755 scripts/release-tag.sh diff --git a/scripts/release-tag.sh b/scripts/release-tag.sh new file mode 100755 index 000000000..645e083ee --- /dev/null +++ b/scripts/release-tag.sh @@ -0,0 +1,26 @@ +#!/bin/bash + +ROOT=$(cd $(dirname "$0")/..; pwd) + +## Extract the full version from the top-level CMakeLists.txt +function current_version { + local str + for v in MAJOR MINOR PATCH; do + ## Concatenate particular version parts + str+=$(sed -n "s/set(OPENSMT_VERSION_${v} \([^ )]*\))/\1/p" <"$ROOT"/CMakeLists.txt). + done + str=${str%.} + + printf '%s\n' $str +} + +VERSION=$(current_version) +TAG=v${VERSION} +git tag -a $TAG -m "Release $VERSION" || exit $? + +printf 'Created release tag "%s"\n' $TAG + +read -p 'Do you want to push the tag? [Y/n] ' choice +[[ ${choice,} =~ ^(|y)$ ]] || exit 0 + +git push origin refs/tags/$TAG