set -eu
dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
cd "$dir"
tagname=$(grep -m1 version Cargo.toml | cut -d '"' -f2)
if git rev-parse "$tagname" >/dev/null 2>&1
then
echo "tag $tagname already exists" >&2
exit 1
fi
echo "Release $tagname"
read -p "continue? [y/N] " -n 1 -r
echo
if ! [[ $REPLY =~ ^[^Nn]$ ]]; then
exit 0
fi
git tag -s "$tagname" -m "Release $tagname"
git push --tags
gio open "https://github.com/alexheretic/spin-sleep/releases/new?tag=$tagname"