From 615cf9cb9a06b2f0c4285717a867916131532954 Mon Sep 17 00:00:00 2001 From: Nikita Galaiko Date: Mon, 20 Feb 2023 15:29:17 +0100 Subject: [PATCH] add semver validation --- scripts/next.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/scripts/next.sh b/scripts/next.sh index 41fc65045..ef9b09b48 100755 --- a/scripts/next.sh +++ b/scripts/next.sh @@ -28,9 +28,9 @@ function info() { VERSION="$1" BUMP="$2" -if [[ -z "$VERSION" ]]; then - error "no version specified" -fi +# https://semver.org/ +SEMVER_REGEX="^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?$" +(echo "$VERSION" | grep -Eq "$SEMVER_REGEX") || error "'$VERSION' not a semver" case "$BUMP" in major)