Skip to content

Commit

Permalink
Merge pull request #4 from micovery/main
Browse files Browse the repository at this point in the history
fix: modify install script to prioritize stable releases
  • Loading branch information
micovery authored May 1, 2024
2 parents 58fda1a + 1ab269f commit 17bf472
Showing 1 changed file with 31 additions and 2 deletions.
33 changes: 31 additions & 2 deletions install
Original file line number Diff line number Diff line change
Expand Up @@ -88,15 +88,44 @@ checkCurrentVersion() {
fi
}


sortSemver() {
local lines=""
while read version; do
if [[ -z "${lines}" ]] ; then
lines=$(printf '%s' "${version}")
else
lines=$(printf '%s\n%s' "${lines}" "${version}")
fi
done
echo "$lines" | sed -r 's:^v::' | sed -r 's:-:~:' | sort -r -V | sed -r 's:^:v:' | sed -r 's:~:-:'
}

pickLatestRelease() {
local first=""
while read version; do
first="${version}"
if [[ "${version}" != *"-"* ]] ; then
echo "${version}"
return
fi
done
echo "${first}"
}

getReleasedTags() {
local releaseUrl="${1}"
curl -s "${releaseUrl}" | grep "tag_name" | sed -r 's;^[^:]+:[^"]*"([^"]+)".*;\1;'
}

getLatestRelease() {
local releaseUrl="https://api.github.com/repos/${GITHUB_ORG}/${GITHUB_REPO}/releases"
local latest_release=""

latest_release=$(curl -s $releaseUrl | grep \"tag_name\" | grep -v rc | awk 'NR==1{print $2}' | sed -n 's/\"\(.*\)\",/\1/p')
latest_release=$(getReleasedTags $releaseUrl | sortSemver | pickLatestRelease)
ret_val=$latest_release
}


createTmpDir() {
ret_val=$(mktemp -dt ${BINARY_FILENAME}-tmp)
}
Expand Down

0 comments on commit 17bf472

Please sign in to comment.