Commit 2490fb8f authored by Boris Yumankulov's avatar Boris Yumankulov Committed by Vitaly Lipatov

epm play common: add get_github_version function

parent cfbd0941
...@@ -77,13 +77,11 @@ epm() ...@@ -77,13 +77,11 @@ epm()
$EPM "$@" $EPM "$@"
} }
eget() eget()
{ {
epm tool eget "$@" epm tool eget "$@"
} }
is_supported_arch() is_supported_arch()
{ {
local i local i
...@@ -159,6 +157,22 @@ get_latest_version() ...@@ -159,6 +157,22 @@ get_latest_version()
done done
} }
get_github_version()
{
is_command jq || fatal "jq not found, please install jq"
local url="$1"
local user_and_repo=${url#https://github.com/}
local user_and_repo=${user_and_repo%/}
local asset_name="$2"
if [ "$3" == "prerelease" ] ; then
curl -s "https://api.github.com/repos/${user_and_repo}/releases" | jq -r '.[] | .assets[].browser_download_url' | grep "$2" | head -n1
else
curl -s "https://api.github.com/repos/${user_and_repo}/releases" | jq -r '.[] | select(.prerelease == false) | .assets[].browser_download_url' | grep "$2" | head -n1
fi
}
print_product_alt() print_product_alt()
{ {
[ -n "$1" ] || return [ -n "$1" ] || return
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment