diff mbox series

[1/5] tools: Add a script for tagging the release

Message ID 20230920095318.340582-2-pvorel@suse.cz
State Changes Requested
Headers show
Series Release scripts and docs | expand

Commit Message

Petr Vorel Sept. 20, 2023, 9:53 a.m. UTC
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 | 80 ++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 111 insertions(+)
 create mode 100755 tools/lib.sh
 create mode 100755 tools/tag-release.sh
diff mbox series

Patch

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..18bef4b17
--- /dev/null
+++ b/tools/tag-release.sh
@@ -0,0 +1,80 @@ 
+#!/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"
+relnotes="/tmp/$(basename $upstream_git)-release-$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 "Creating skeleton file for release notes"
+cat > $relnotes <<EOF
+TODO: Add changelog
+
+## credit
+Many thanks to the people contributing to this release:
+\`\`\`
+    $ git shortlog -sen $old_tag..
+EOF
+git shortlog -s -n $old_tag.. >> $relnotes
+
+cat >> $relnotes <<EOF
+\`\`\`
+
+Also thanks to patch reviewers:
+
+$ git log $old_tag.. | grep -Ei '(reviewed|acked)-by:' | sed 's/.*by: //' | sort | uniq -c | sort -n -r
+\`\`\`
+EOF
+
+git log $old_tag.. | grep -Ei '(reviewed|acked)-by:' | sed 's/.*by: //' | sort | uniq -c | sort -n -r >> $relnotes
+
+cat >> $relnotes <<EOF
+\`\`\`
+
+and testers:
+$ git log $old_tag.. | grep -Ei 'tested-by:' | sed 's/.*by: //' | sort | uniq -c | sort -n -r
+\`\`\`
+EOF
+git log $old_tag.. | grep -Ei 'tested-by:' | sed 's/.*by: //' | sort | uniq -c | sort -n -r >> $relnotes
+echo '```'  >> $relnotes
+
+echo "Skeleton file for release notes: $relnotes"
+
+title "git push"
+ask "Pushing changes to upstream git"
+rod git push origin master:master
+git push origin $tag