Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

install latest patch in go-build script #258

Merged
merged 2 commits into from
Oct 28, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 11 additions & 5 deletions plugins/go-build/bin/go-build
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
# -g/--debug Build a debug version
#

GO_BUILD_VERSION="2.0.0beta1"
GO_BUILD_VERSION="2.0.0"

OLDIFS="$IFS"

Expand Down Expand Up @@ -747,6 +747,10 @@ sort_versions() {
LC_ALL=C sort -t. -k 1,1 -k 2,2n -k 3,3n -k 4,4n -k 5,5n | awk '{print $2}'
}

latest_version() {
list_definitions | grep -oE "^$1\\.([0-9]+)?" | tail -1
}

unset VERBOSE
unset KEEP_BUILD_PATH
unset DEBUG
Expand Down Expand Up @@ -804,11 +808,13 @@ done

DEFINITION_PATH="${ARGUMENTS[0]}"

# NOTE: Try to capture semantic versions such as `1.11` which don't have a patch version.
# A patch version of 0 will be added, e.g they'll be changed to `1.11.0`.
# The latest patch version will be located, e.g if 1.11 is supplied they'll be changed to `1.11.x`.
# NOTE: Try to capture semantic versions such as `1.11` which don't have a patch version and install latest patch.
if grep -q -E "^[0-9]+\.[0-9]+(\s*)$" <<<${DEFINITION_PATH}; then
DEFINITION_PATH="${DEFINITION_PATH}.0"
echo "Adding patch version 0 to ${DEFINITION_PATH}"
REGEX=$(echo $DEFINITION_PATH | sed s/\\./\\\\./)
LATEST_PATCH=$(latest_version $REGEX)
echo "Using latest patch version $LATEST_PATCH"
DEFINITION_PATH="$LATEST_PATCH"
fi

if [ -z "$DEFINITION_PATH" ]; then
Expand Down
2 changes: 1 addition & 1 deletion plugins/go-build/test/goenv-install.bats
Original file line number Diff line number Diff line change
Expand Up @@ -873,7 +873,7 @@ OUT

assert_success
assert_output <<-OUT
go-build 2.0.0beta1
go-build 2.0.0
OUT
}

Expand Down