[LTP] [PATCH v2 1/6] tools: Add a script for tagging the release

Petr Vorel pvorel@suse.cz
Wed Sep 27 22:21:16 CEST 2023


A helper for new releases.

Functions will be reused in another script (next commit).

Signed-off-by: Petr Vorel <pvorel@suse.cz>
---
 tools/lib.sh         | 31 ++++++++++++++++++++++++++++++
 tools/tag-release.sh | 45 ++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 76 insertions(+)
 create mode 100755 tools/lib.sh
 create mode 100755 tools/tag-release.sh

diff --git a/tools/lib.sh b/tools/lib.sh
new file mode 100755
index 000000000..c96433d28
--- /dev/null
+++ b/tools/lib.sh
@@ -0,0 +1,31 @@
+#!/bin/sh
+# Copyright (c) 2023 Petr Vorel <pvorel@suse.cz>
+
+ask()
+{
+	local msg="$1"
+	local answer
+
+	printf "\n$msg. Proceed? [N/y]: "
+	read answer
+	case "$answer" in
+		[Yy]*) : ;;
+		*) exit 2
+	esac
+}
+
+quit()
+{
+	printf "\n$@\n" >&2
+	exit 1
+}
+
+rod()
+{
+	eval "$@" || quit "$@ failed"
+}
+
+title()
+{
+	echo "===== $1 ====="
+}
diff --git a/tools/tag-release.sh b/tools/tag-release.sh
new file mode 100755
index 000000000..2967c7b4d
--- /dev/null
+++ b/tools/tag-release.sh
@@ -0,0 +1,45 @@
+#!/bin/sh
+# Copyright (c) 2023 Petr Vorel <pvorel@suse.cz>
+# Tag LTP release.
+# https://github.com/linux-test-project/ltp/wiki/LTP-Release-Procedure
+set -e
+
+upstream_git="linux-test-project/ltp"
+tag="$(date +%Y%m%d)"
+old_tag="$(git describe --abbrev=0)"
+tag_msg="LTP $tag"
+
+. $(dirname "$0")/lib.sh
+
+cd $(dirname "$0")/..
+
+if ! git ls-remote --get-url origin | grep -q $upstream_git; then
+	quit "Not an upstream project"
+fi
+
+if ! git --no-pager diff --exit-code; then
+	quit "Please commit your changes before making new release"
+fi
+
+if git show $tag 2> /dev/null; then
+	quit "Tag '$tag' already exists"
+fi
+
+if grep -q "$tag" VERSION; then
+	quit "Tag '$tag' already in VERSION file"
+fi
+
+title "git tag"
+echo "new tag: '$tag', previous tag: '$old_tag'"
+echo "$tag" > VERSION
+git add VERSION
+rod git commit -S --signoff --message \"$tag_msg\" VERSION
+rod git tag --sign --annotate $tag --message \"$tag_msg\"
+git --no-pager show $tag --show-signature
+
+ask "Please check tag and signature"
+
+title "git push"
+ask "Pushing changes to upstream git"
+rod git push origin master:master
+git push origin $tag
-- 
2.40.1



More information about the ltp mailing list