From d255ef3ed07185fd553b68db270abf633bbe643c Mon Sep 17 00:00:00 2001 From: Stefan Peters Date: Tue, 16 Jan 2024 09:31:49 +0100 Subject: [PATCH] build-all.sh: Improve Node version selection for building older tags --- build/build-all.sh | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/build/build-all.sh b/build/build-all.sh index 01e7100c..7c7bbba7 100755 --- a/build/build-all.sh +++ b/build/build-all.sh @@ -52,6 +52,9 @@ git checkout $GIT_BRANCH rm -rf releases mkdir releases +# From: https://stackoverflow.com/a/18558871 +beginswith() { case $2 in "$1"*) true;; *) false;; esac; } + DEFAULT_TAGS="$(git tag) master dev" TAGS="${*:1}" TAGS="${TAGS:-$DEFAULT_TAGS}" @@ -62,13 +65,12 @@ do echo "==================== Building $TAG ====================" # Checkout tag git checkout $TAG - # Switch Node.js version on certain tags in history - # TODO: Improve this! - if [[ "$TAG" == "0.2.0" ]]; then + # Switch Node.js version on certain tags + if beginswith "0." "$TAG" || beginswith "1.0." "$TAG" || beginswith "1.1." "$TAG" || beginswith "1.2." "$TAG" || beginswith "1.3." "$TAG"; then fnm use --install-if-missing 10 - elif [[ "$TAG" == "1.4.0" ]]; then + elif beginswith "1.4." "$TAG" || beginswith "1.5." "$TAG" || beginswith "1.6." "$TAG" || beginswith "1.7." "$TAG"; then fnm use --install-if-missing 14 - elif [[ "$TAG" == "1.8.0" ]]; then + else fnm use --install-if-missing 20 fi # Install dependencies