Update semver regex for release-job.sh 93/64493/2
authorJessica Wagantall <jwagantall@linuxfoundation.org>
Thu, 9 Jul 2020 16:25:35 +0000 (09:25 -0700)
committerJessica Wagantall <jwagantall@linuxfoundation.org>
Thu, 9 Jul 2020 21:40:25 +0000 (14:40 -0700)
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 <jwagantall@linuxfoundation.org>
Change-Id: I9d1fe49693279f71243df0280eebed266e55ff4e

releasenotes/notes/release-version-regex-af5a68f1cf28caf5.yaml [new file with mode: 0644]
shell/release-job.sh

diff --git a/releasenotes/notes/release-version-regex-af5a68f1cf28caf5.yaml b/releasenotes/notes/release-version-regex-af5a68f1cf28caf5.yaml
new file mode 100644 (file)
index 0000000..0bf62c9
--- /dev/null
@@ -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.
index 5276a68..3ad4530 100644 (file)
@@ -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