Skip to content

Commit

Permalink
feat: explicit version download (#2455)
Browse files Browse the repository at this point in the history
  • Loading branch information
olwe0002 authored Jan 26, 2024
1 parent 62b9937 commit 7e02c8b
Showing 1 changed file with 18 additions and 6 deletions.
24 changes: 18 additions & 6 deletions build/download.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,17 @@ download() {
tmp="$(ensure mktemp -d)"
ensure cd "$tmp"

# Download latest Gauge zip installer
url="$(ensure curl -Ss https://api.github.com/repos/getgauge/gauge/releases/latest \
| grep "browser_download_url.*$OS.$ARCH.zip" \
| cut -d : -f 2,3 \
| tr -d \")"
# set api url
if [ $VERSION = "latest" ]; then
api_url="https://api.github.com/repos/getgauge/gauge/releases/latest"
else
api_url="https://api.github.com/repos/getgauge/gauge/releases/tags/$VERSION"
fi
# set download url
url="$(ensure curl -Ss $api_url \
| grep "browser_download_url.*$OS.$ARCH.zip" \
| cut -d : -f 2,3 \
| tr -d \")"

say "Downloading binary from URL:$url"
ensure curl -L -o gauge.zip $url
Expand Down Expand Up @@ -109,6 +115,7 @@ set_os_architecture() {

handle_cmd_line_args() {
LOCATION="/usr/local/bin"
VERSION="latest"
for _arg in "$@"; do
case "${_arg%%=*}" in
--verbose)
Expand All @@ -119,6 +126,11 @@ handle_cmd_line_args() {
LOCATION="$(get_value_arg "$_arg")"
fi
;;
--version)
if is_value_arg "$_arg" "version"; then
VERSION="$(get_value_arg "$_arg")"
fi
;;
esac
done
}
Expand Down Expand Up @@ -194,4 +206,4 @@ main() {
download
}

main "$@"
main "$@"

0 comments on commit 7e02c8b

Please sign in to comment.