Commit 5289769c authored by Boris Yumankulov's avatar Boris Yumankulov Committed by Vitaly Lipatov

epm play common: add get_github_version function

parent 343d4454
......@@ -77,13 +77,11 @@ epm()
$EPM "$@"
}
eget()
{
epm tool eget "$@"
}
is_supported_arch()
{
local i
......@@ -159,6 +157,22 @@ get_latest_version()
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()
{
[ -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