Skip to content

Commit

Permalink
👷 misc(release): verify version tag format on release
Browse files Browse the repository at this point in the history
  • Loading branch information
welpo committed Feb 7, 2024
1 parent 931386d commit 8eca1e3
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions release
Expand Up @@ -3,6 +3,8 @@
# Inspired by https://github.com/orhun/git-cliff/blob/main/release.sh
set -eu

VERSION_FORMAT="^v[0-9]+\.[0-9]+\.[0-9]+$"

# Check for a clean working directory.
if [ -n "$(git status --porcelain)" ]; then
echo "Your working directory is dirty. Commit or stash your changes before running this script."
Expand All @@ -28,6 +30,12 @@ else
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 ${VERSION_TAG}"
comment="# managed by release script"
sed -E -e "s/^version = .* $comment$/version = \"${VERSION_TAG#v}\" $comment/" Cargo.toml > Cargo.toml.tmp && mv Cargo.toml.tmp Cargo.toml
Expand Down

0 comments on commit 8eca1e3

Please sign in to comment.