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
--- /dev/null
+---
+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.
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