build: Rewrite tagging script

This commit is contained in:
Lorenz Leutgeb 2024-11-12 11:10:50 +01:00 committed by Lorenz Leutgeb
parent 6f34124d43
commit e39653afcf
1 changed files with 24 additions and 12 deletions

View File

@ -1,4 +1,4 @@
#!/bin/sh #! /bin/sh
set -e set -e
if [ $# -ne 1 ]; then if [ $# -ne 1 ]; then
@ -8,31 +8,43 @@ fi
version="$1" version="$1"
tag="v$version" tag="v$version"
commit="$(git rev-parse HEAD)"
signing_key=$(git config user.signingKey)
git show "$commit" git_config_key="user.signingKey"
if [ "$signing_key" != "$(rad self --ssh-key)" ]; then git_rev="$(git rev-parse HEAD)"
echo "The Git signing key does not match the output of 'rad self --ssh-key'." git_key="$(git config $git_config_key)"
if [ "$(printf '%s' "$git_key" | cut -c -5)" != "key::" ]; then
printf "The Git signing key set as \`%s\` does not start with \`key::\`.\n" "$git_config_key"
printf "This is not supported. Refer to <https://git-scm.com/docs/git-config#Documentation/git-config.txt-usersigningKey>.\n"
exit 1
fi
rad_did="$(rad self --did)"
rad_key="$(rad self --ssh-key)"
git show "$git_rev"
if [ "$git_key" != "key::$rad_key" ]; then
printf "The Git signing key set as \`%s\` does not match the output of \`rad self --ssh-key\`. Aborting.\n" "$git_config_key"
exit 1 exit 1
fi fi
printf "\n" printf "\n"
printf "Tag the above commit with \033[35m%s\033[0m, using \033[35m$(rad self --did)\033[0m? [y/N] " "$tag" printf "Tag the above commit with \033[35m%s\033[0m, using \033[35m%s\033[0m? [y/N] " "$tag" "$rad_did"
read -r confirmation read -r confirmation
rad auth
case "$confirmation" in case "$confirmation" in
[Yy]*) [Yy]*)
if git tag --annotate --sign "$tag" -m "Release $version" "$commit"; then rad auth
echo "Tag $tag created and signed over $commit." if git tag --annotate --sign --message="Release $version" "$tag" "$git_rev"; then
printf "Tag %s created and signed over %s.\n" "$tag" "$git_rev"
else else
echo "Failed to create tag." echo "Failed to create tag. Aborting."
exit 1 exit 1
fi ;; fi ;;
*) *)
echo "Operation aborted." echo "Aborting."
exit 1 ;; exit 1 ;;
esac esac