From 89144786dbd6e556bc251aeff6b397d6e28eddeb Mon Sep 17 00:00:00 2001 From: Jessica Wagantall Date: Thu, 9 Jul 2020 09:25:35 -0700 Subject: [PATCH] Update semver regex for release-job.sh Update semver regex to the one recommended by https://semver.org/ This regex was taken from https://github.com/fsaintjacques/semver-tool which follows the semver guidances and works in bash. Issue: IT-20145 Signed-off-by: Jessica Wagantall Change-Id: I9d1fe49693279f71243df0280eebed266e55ff4e --- releasenotes/notes/release-version-regex-af5a68f1cf28caf5.yaml | 7 +++++++ shell/release-job.sh | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) create mode 100644 releasenotes/notes/release-version-regex-af5a68f1cf28caf5.yaml diff --git a/releasenotes/notes/release-version-regex-af5a68f1cf28caf5.yaml b/releasenotes/notes/release-version-regex-af5a68f1cf28caf5.yaml new file mode 100644 index 00000000..0bf62c9f --- /dev/null +++ b/releasenotes/notes/release-version-regex-af5a68f1cf28caf5.yaml @@ -0,0 +1,7 @@ +--- +fixes: + - | + Release verify will not allow valid semver versions like "1.3.2-1" + which should be accepted. Update semver regex to conform to https://semver.org/ + This regex was taken from https://github.com/fsaintjacques/semver-tool + which follows the semver guidances and works in bash. diff --git a/shell/release-job.sh b/shell/release-job.sh index 5276a684..3ad45306 100644 --- a/shell/release-job.sh +++ b/shell/release-job.sh @@ -218,7 +218,7 @@ verify_schema(){ verify_version(){ # Verify allowed patterns "#.#.#" (SemVer) or "v#.#.#" echo "INFO: Verifying version $VERSION" - allowed_version_regex="^((v?)([0-9]+)\.([0-9]+)\.([0-9]+))$" + allowed_version_regex="^[vV]?(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)(\-(0|[1-9][0-9]*|[0-9]*[A-Za-z-][0-9A-Za-z-]*)(\.(0|[1-9][0-9]*|[0-9]*[A-Za-z-][0-9A-Za-z-]*))*)?(\+[0-9A-Za-z-]+(\.[0-9A-Za-z-]+)*)?$" if [[ $VERSION =~ $allowed_version_regex ]]; then echo "INFO: The version $VERSION is valid" else -- 2.16.6