Skip to content

Commit

Permalink
NET-962: add semver check (#2854)
Browse files Browse the repository at this point in the history
* add semver check

* indentation on if
  • Loading branch information
abhishek9686 authored Mar 12, 2024
1 parent 8fa898e commit 24c784a
Showing 1 changed file with 30 additions and 2 deletions.
32 changes: 30 additions & 2 deletions scripts/nm-quick.sh
Original file line number Diff line number Diff line change
Expand Up @@ -708,7 +708,12 @@ upgrade() {
unset IMAGE_TAG
unset BUILD_TAG
IMAGE_TAG=$UI_IMAGE_TAG
BUILD_TAG=$UI_IMAGE_TAG
semver=$(chsv_check_version_ex "$UI_IMAGE_TAG")
if [[ ! "$semver" ]]; then
BUILD_TAG=$LATEST
else
BUILD_TAG=$UI_IMAGE_TAG
fi
echo "-----------------------------------------------------"
echo "Provide Details for pro installation:"
echo " 1. Log into https://app.netmaker.io"
Expand All @@ -734,7 +739,13 @@ downgrade () {
unset IMAGE_TAG
unset BUILD_TAG
IMAGE_TAG=$UI_IMAGE_TAG
BUILD_TAG=$UI_IMAGE_TAG

semver=$(chsv_check_version_ex "$UI_IMAGE_TAG")
if [[ ! "$semver" ]]; then
BUILD_TAG=$LATEST
else
BUILD_TAG=$UI_IMAGE_TAG
fi
save_config
if [ -a "$SCRIPT_DIR"/docker-compose.override.yml ]; then
rm -f "$SCRIPT_DIR"/docker-compose.override.yml
Expand All @@ -744,6 +755,23 @@ downgrade () {
install_netmaker
}

function chsv_check_version() {
if [[ $1 =~ ^(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-]+)*))?$ ]]; then
echo "$1"
else
echo ""
fi
}

function chsv_check_version_ex() {
if [[ $1 =~ ^v.+$ ]]; then
chsv_check_version "${1:1}"
else
chsv_check_version "${1}"
fi
}



main (){

Expand Down

0 comments on commit 24c784a

Please sign in to comment.