Skip to content
Snippets Groups Projects
Unverified Commit 443ebf75 authored by Timo Furrer's avatar Timo Furrer
Browse files

Use perl to match semver

parent 31c93539
No related branches found
No related tags found
No related merge requests found
......@@ -75,6 +75,8 @@ check-semantic-version:
rules:
- if: $CI_COMMIT_TAG
image: alpine:latest
before_script:
- apk add perl
script:
- echo -n "$CI_COMMIT_TAG" | ./.gitlab/scripts/check-semantic-version.sh
......
......@@ -3,11 +3,9 @@
# Regex from https://semver.org/#is-there-a-suggested-regular-expression-regex-to-check-a-semver-string
SEMANTIC_VERSION_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-]+)*))?$'
cat - | grep -qE "$SEMANTIC_VERSION_REGEX"
match=$(cat - | perl -ne "print if /$SEMANTIC_VERSION_REGEX/")
exit_code=$?
if [ $exit_code -ne 0 ]; then
if [ -z "$match" ]; then
echo "The given version doesn't match the semantic versioning format."
exit 1
fi
exit $exit_code
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment