diff --git a/testsuite/backward-compatibility/start-sim.sh b/testsuite/backward-compatibility/start-sim.sh index 8be45d7ca98d..9be29cc806c0 100755 --- a/testsuite/backward-compatibility/start-sim.sh +++ b/testsuite/backward-compatibility/start-sim.sh @@ -66,8 +66,11 @@ install_sim_noquic(){ # and for the current branch code git worktree add -f "$BRANCH_DIR" HEAD -latestReleaseCommit="$(git rev-list --exclude='*rc*' --tags --max-count=1)" -latestReleaseTag=$(git describe --tags "$latestReleaseCommit") +SCRIPTDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" + +latestReleaseTag=$($SCRIPTDIR/../find-previous-release-tag.sh) +latestReleaseCommit=$(git rev-list -n1 $latestReleaseTag) + echo "Checking out latest release tag: $latestReleaseTag" git worktree add -f "$RELEASE_DIR" "$latestReleaseCommit" @@ -82,8 +85,6 @@ cat > "$RELEASE_DIR"/private/version/release.go </dev/null 2>&1 && pwd )" - pushd $RELEASE_DIR install_sim_noquic "$RELEASE_DIR"/bin popd diff --git a/testsuite/backward-compatibility/start-up.sh b/testsuite/backward-compatibility/start-up.sh index 372b63274e93..1aff8b041124 100755 --- a/testsuite/backward-compatibility/start-up.sh +++ b/testsuite/backward-compatibility/start-up.sh @@ -37,8 +37,10 @@ RELEASE_BIN="$STORJ_NETWORK_DIR/bin/release" # replace this with a standard go install once go allows install cross-compiled binaries when GOBIN is set # https://github.com/golang/go/issues/57485 git worktree add -f "$STORJ_NETWORK_DIR"/branch HEAD -latestReleaseCommit="$(git rev-list --exclude='*rc*' --tags --max-count=1)" -latestReleaseTag=$(git describe --tags "$latestReleaseCommit") + +latestReleaseTag=$($SCRIPTDIR/../find-previous-release-tag.sh) +latestReleaseCommit=$(git rev-list -n1 $latestReleaseTag) + echo "Checking out latest release tag: $latestReleaseTag" git worktree add -f "$STORJ_NETWORK_DIR"/release "$latestReleaseCommit" pushd "$STORJ_NETWORK_DIR"/release diff --git a/testsuite/find-previous-major-release-tag.sh b/testsuite/find-previous-major-release-tag.sh index d63616845cfc..69c526f46fa8 100755 --- a/testsuite/find-previous-major-release-tag.sh +++ b/testsuite/find-previous-major-release-tag.sh @@ -1,12 +1,6 @@ #!/usr/bin/env bash set -ueo pipefail -# This script finds the previous major tag from the current HEAD position. - -closestHeadVersion="$(git describe --tags)" - -sortedTags="$(git tag --list --sort -version:refname)" - verlte() { # sort and get the first result [ "$1" = "`echo -e "$1\n$2" | sort -V | head -n1`" ] @@ -15,10 +9,32 @@ verlt() { [ "$1" = "$2" ] && return 1 || verlte $1 $2 } -closestZeroVersion="$(echo $closestHeadVersion | cut -d '.' -f 1-2).0" +# This script finds the previous major tag from the current HEAD position. + +closest_head_version="$(git describe --tags)" + +sorted_tags="$(git tag --list --sort -version:refname)" + +# this is ugly, but we use this approach to detect whether we are +# on a main branch, if that's the case, then we'll output the +# latest release version. +if [[ $closest_head_version =~ ^v1\.91\.0\-alpha ]]; then + for tag in $sorted_tags + do + if [[ "$tag" =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then + echo $tag + exit 0 + fi + done + + echo "did not find an appropriate release tag from main branch" + exit 1 +fi + +closest_zero_version="$(echo $closest_head_version | cut -d '.' -f 1-2).0" IFS=$'\n' -for tag in $sortedTags +for tag in $sorted_tags do if [[ ! "$tag" =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then # it's not a proper version so ignore @@ -26,7 +42,7 @@ do fi # the first less than our closest head should be our latest version - if verlt $tag $closestZeroVersion; then + if verlt $tag $closest_zero_version; then echo $tag exit 0 fi diff --git a/testsuite/find-previous-release-tag.sh b/testsuite/find-previous-release-tag.sh index fad383221d31..e238883df4a1 100755 --- a/testsuite/find-previous-release-tag.sh +++ b/testsuite/find-previous-release-tag.sh @@ -1,32 +1,45 @@ #!/usr/bin/env bash -set -ueo pipefail - -# This script finds the previous tag from the current HEAD position. - -closestHeadVersion="$(git describe --tags)" - -sortedTags="$(git tag --list --sort -version:refname)" +set -uo pipefail verlte() { - # sort and get the first result + # sort and check against the first result [ "$1" = "`echo -e "$1\n$2" | sort -V | head -n1`" ] } verlt() { [ "$1" = "$2" ] && return 1 || verlte $1 $2 } +# This script finds the previous tag from the current HEAD position. + +closest_head_version="$(git describe --tags)" + +sorted_tags="$(git tag --list --sort -version:refname)" + +# this is ugly, but we use this approach to detect whether we are +# on a main branch, if that's the case, then we'll output the +# latest release version. +if [[ $closest_head_version =~ ^v1\.91\.0\-alpha ]]; then + for tag in $sorted_tags + do + if [[ "$tag" =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then + echo $tag + exit 0 + fi + done + + echo "did not find an appropriate release tag from main branch" + exit 1 +fi + IFS=$'\n' -for tag in $sortedTags +for tag in $sorted_tags do - if [[ ! "$tag" =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then - # it's not a proper version so ignore - continue - fi - - # the first less than our closest head should be our latest version - if verlt $tag $closestHeadVersion; then - echo $tag - exit 0 + if [[ "$tag" =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then + # the first less than our closest head should be our latest version + if verlt $tag $closest_head_version; then + echo $tag + exit 0 + fi fi done diff --git a/testsuite/rolling-upgrade/start-sim.sh b/testsuite/rolling-upgrade/start-sim.sh index d6a879bbe519..fcdc966d7cf7 100755 --- a/testsuite/rolling-upgrade/start-sim.sh +++ b/testsuite/rolling-upgrade/start-sim.sh @@ -54,9 +54,7 @@ git fetch --tags current_commit=$(git rev-parse HEAD) stage1_release_version=$(git tag -l --sort -version:refname | grep -v rc | head -1) if [[ $BRANCH_NAME = v* ]]; then - current_major_release_version=$(git describe --tags $current_commit | cut -d '.' -f 1-2) - previous_release_version=$(git describe --tags `git rev-list --exclude='*rc*' --exclude=$current_major_release_version* --tags --max-count=1`) - stage1_release_version=$previous_release_version + stage1_release_version=$($SCRIPTDIR/../find-previous-major-release-tag.sh) fi stage1_sat_version=$stage1_release_version stage1_uplink_version=$stage1_release_version