Skip to content

Commit

Permalink
chore: update version and tag extraction in install script
Browse files Browse the repository at this point in the history
  • Loading branch information
mbhall88 committed Nov 25, 2024
1 parent 52b3306 commit 2e61e31
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions install/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -74,12 +74,19 @@ get_tmpdir() {
}

# Gets the latest github release tag (version)
get_version_from_github() {
get_tag_from_github() {
ver=$(wget -qO - "https://api.github.com/repos/${GH_USER}/${PROJECT}/releases/latest" |
grep '"tag_name":' | sed -E 's/.*"([^"]+)".*/\1/')
echo "$ver"
}

# Gets the latest github release version from the tag
get_version_from_tag() {
tag="$1"
ver=$(echo "$tag" | sed -E "s|$PROJECT-([0-9]+\.[0-9]+\.[0-9]+)|\1|")
echo "$ver"
}

# Test if a location is writeable by trying to write to it. Windows does not let
# you test writeability other than by writing: https://stackoverflow.com/q/1999988
test_writeable() {
Expand Down Expand Up @@ -440,9 +447,10 @@ if [ "${PLATFORM}" = "pc-windows-msvc" ]; then
EXT=zip
fi

VERSION=$(get_version_from_github)
URL="${BASE_URL}/latest/download/${PROJECT}-${VERSION}-${TARGET}.${EXT}"
TAG=$(get_tag_from_github)
URL="${BASE_URL}/download/${TAG}/${TAG}-${TARGET}.${EXT}"
info "Tarball URL: ${UNDERLINE}${BLUE}${URL}${NO_COLOR}"
VERSION=$(get_version_from_tag "${TAG}")
confirm "Install $PROJECT ${GREEN}v${VERSION} (latest)${NO_COLOR} to ${BOLD}${GREEN}${BIN_DIR}${NO_COLOR}?"
check_bin_dir "${BIN_DIR}"

Expand Down

0 comments on commit 2e61e31

Please sign in to comment.