diff --git a/release.sh b/release.sh index e79b478..922612c 100755 --- a/release.sh +++ b/release.sh @@ -28,9 +28,28 @@ fi CURRENT_MAJOR=${CURRENT_VERSION#v} +if ! [[ "$CURRENT_VERSION" =~ ^v[0-9]+$ ]]; then + echo "Error: Invalid version format in $VERSION_FILE. Expected v0, v1, v2, etc." + exit 1 +fi + NEXT_VERSION=$((CURRENT_MAJOR + 1)) NEXT_VERSION_STR="v$NEXT_VERSION" +if git rev-parse "refs/tags/$NEXT_VERSION_STR" >/dev/null 2>&1; then + echo "Error: Tag $NEXT_VERSION_STR already exists locally." + exit 1 +fi + +if git remote get-url origin >/dev/null 2>&1; then + if git ls-remote --tags origin "$NEXT_VERSION_STR" 2>/dev/null | grep -q "$NEXT_VERSION_STR"; then + echo "Error: Tag $NEXT_VERSION_STR already exists on remote." + exit 1 + fi +else + echo "Warning: No remote configured. You can still create the release locally." +fi + echo "Current version: $CURRENT_VERSION" echo "Proposed version: $NEXT_VERSION_STR" echo ""