2023-03-30 08:50:00 +00:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
set -e
|
|
|
|
|
|
|
|
echo "Fetching any updates from server:"
|
|
|
|
git pull
|
|
|
|
echo ""
|
|
|
|
|
2023-06-09 08:56:55 +00:00
|
|
|
if [[ -z ${1} ]]; then
|
|
|
|
deftag=$(basename "${PWD}")
|
2023-03-30 08:50:00 +00:00
|
|
|
else
|
2023-06-09 08:56:55 +00:00
|
|
|
deftag="${1}"
|
2023-03-30 08:50:00 +00:00
|
|
|
fi
|
2023-06-09 08:56:55 +00:00
|
|
|
tagpfx=${tag:="${deftag}"}
|
2023-03-30 08:50:00 +00:00
|
|
|
|
2023-06-09 08:56:55 +00:00
|
|
|
last_tag=$(git tag -l "${tagpfx}-*" | sort | tail -1)
|
2023-03-30 08:50:00 +00:00
|
|
|
|
2023-06-09 08:56:55 +00:00
|
|
|
echo "Verifying last tag ${last_tag}:"
|
|
|
|
(git tag -v "${last_tag}" | grep ^gpg:) || true
|
2023-03-30 08:50:00 +00:00
|
|
|
# again to not mask exit status of git with grep
|
2023-06-09 08:56:55 +00:00
|
|
|
git tag -v "${last_tag}" >/dev/null 2>&1
|
2023-03-30 08:50:00 +00:00
|
|
|
echo ""
|
|
|
|
|
2023-06-09 08:56:55 +00:00
|
|
|
echo "Differences between tag ${last_tag} and what you are about to sign:"
|
|
|
|
env PAGER=cat git diff --color "${last_tag}..main"
|
2023-03-30 08:50:00 +00:00
|
|
|
|
|
|
|
iter=1
|
|
|
|
ok=
|
|
|
|
while test -z "$ok"; do
|
2023-06-09 08:56:55 +00:00
|
|
|
this_tag=$(date "+${tagpfx}-%Y-%m-%d-v$(printf "%02d" ${iter})")
|
|
|
|
iter=$(( iter + 1))
|
|
|
|
case $( (
|
|
|
|
echo "${this_tag}"
|
|
|
|
echo "${last_tag}"
|
|
|
|
) | sort | tail -1) in
|
|
|
|
"${last_tag}") ;;
|
|
|
|
|
|
|
|
"${this_tag}")
|
|
|
|
ok=yes
|
|
|
|
;;
|
|
|
|
esac
|
2023-03-30 08:50:00 +00:00
|
|
|
done
|
|
|
|
|
2023-06-09 08:56:55 +00:00
|
|
|
if [ "${deftag}" != "${tagpfx}" ]; then
|
|
|
|
echo -e "Using new tag \e[94m${this_tag}\e[0m according to pattern in cosmos.conf"
|
2023-03-30 08:50:00 +00:00
|
|
|
else
|
2023-06-09 08:56:55 +00:00
|
|
|
echo -e "Using new tag \e[94m${this_tag}\e[0m"
|
2023-03-30 08:50:00 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
echo -e "\e[1mONLY SIGN IF YOU APPROVE OF VERIFICATION AND DIFF ABOVE\e[0m"
|
|
|
|
|
|
|
|
# GITTAGEXTRA is for putting things like "-u 2117364A"
|
2023-06-09 08:56:55 +00:00
|
|
|
# shellcheck disable=SC2086
|
2023-06-09 09:14:18 +00:00
|
|
|
git tag ${GITTAGEXTRA} -s "${this_tag}" -m bump.
|
2023-03-30 08:50:00 +00:00
|
|
|
|
|
|
|
git push
|
|
|
|
git push --tags
|