👷 misc(release): verify version tag format on release

This commit is contained in:
welpo 2024-02-07 16:27:54 +01:00
parent c193d4d4e8
commit fcf16a457e
No known key found for this signature in database
GPG Key ID: A2F978CF4EC1F5A6

11
release
View File

@ -3,6 +3,8 @@
# Inspired by https://github.com/orhun/git-cliff/blob/main/release.sh # Inspired by https://github.com/orhun/git-cliff/blob/main/release.sh
set -eu set -eu
VERSION_FORMAT="^v[0-9]+\.[0-9]+\.[0-9]+$"
# Check for a clean working directory. # Check for a clean working directory.
if [ -n "$(git status --porcelain)" ]; then if [ -n "$(git status --porcelain)" ]; then
echo "Your working directory is dirty. Commit or stash your changes before running this script." echo "Your working directory is dirty. Commit or stash your changes before running this script."
@ -28,6 +30,15 @@ else
fi fi
fi fi
# Verify that the version tag matches the expected format.
if ! [[ $VERSION_TAG =~ $VERSION_FORMAT ]]; then
echo "Version tag $VERSION_TAG does not match the expected format ${VERSION_FORMAT}."
exit 1
fi
echo "Preparing release ${VERSION_TAG}…"
echo
# Update CHANGELOG. # Update CHANGELOG.
git cliff --tag "$VERSION_TAG" -o CHANGELOG.md git cliff --tag "$VERSION_TAG" -o CHANGELOG.md