blob: 3b9161197e3a21bd58d6c07e1f296d9d275ce703 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
|
#!/usr/bin/bash
variant=WIN
sub_command=$1
case $sub_command in
# retrieve the latest tag
latest-tag)
# echo in green to stderr
echo -e "\033[0;32mRetrieving latest tag...\033[0m" >&2
latests_json=$(curl -X GET --header 'Content-Type: application/json;chartset=UTF-8' 'https://gitee.com/api/v5/repos/sbxlm/sbxlm/releases/latest')
tag=$(echo $latests_json | jq -r ".tag_name")
echo $tag
;;
# retrieve the sbxlm assets with the given tag
url)
tag_name=$2
echo -e "\033[0;32mRetrieving assets for tag $tag_name...\033[0m" >&2
resp=$(curl -X GET --header 'Content-Type: application/json;chartset=UTF-8' "https://gitee.com/api/v5/repos/sbxlm/sbxlm/releases/tags/$tag_name")
download_url=$(echo $resp | jq -r ".assets[] | select(.name) | select(.name | contains(\"$variant\")) | .browser_download_url")
echo $download_url
;;
*)
# show usage
echo "Usage: fetch-release.sh latest-tag"
echo "Usage: fetch-release.sh url <tag>"
exit 1
;;
esac
|