Skip to content

Commit c6226ce

Browse files
committed
Fix install script
- Don't fiddle together the download url, but take it from the release response - This requires now the `jq` executable Apparently the asset names changed and the constructed download url was not correct. This change will take the url now from github's latest release response.
1 parent 222c781 commit c6226ce

2 files changed

Lines changed: 19 additions & 43 deletions

File tree

docs/install.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,8 @@ existing tag.
108108
The convenient way is to use the `installer.sh` script that is
109109
provided from this repository. It will download the correct binary
110110
from the release page and put it in `/usr/local/bin` on your system.
111-
It requires `curl` and `sudo` to copy the binary to `/usr/local/bin`.
111+
It requires `curl`, `jq` and finally `sudo` to copy the binary to
112+
`/usr/local/bin`.
112113

113114
```
114115
curl -sfSL https://raw.githubusercontent.com/SwissDataScienceCenter/renku-cli/main/install.sh | bash

install.sh

Lines changed: 17 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -68,28 +68,12 @@ print_help() {
6868
debug " Install the given version instead of latest"
6969
}
7070

71-
find_latest_release_name() {
72-
if [ -n "$version" ]; then
73-
echo "$version"
74-
else
75-
# get latest release
76-
local latest_response=$(curl -sSL "$api_url_prefix/latest")
77-
if [[ -z "$latest_response" ]] || [[ "$latest_response" =~ .*404.* ]]; then
78-
debug_v "No latest release. Use nightly."
79-
echo "nightly"
80-
else
81-
debug_v "Latest release response: $latest_response"
82-
if [ -z "$jq" ]; then
83-
echo $latest_response | tr ',' '\n' | grep "tag_name" | cut -d':' -f2 | tr -d '[:space:]'
84-
else
85-
echo $latest_response | jq -r '.tag_name'
86-
fi
87-
fi
88-
fi
89-
}
71+
find_latest_release() {
72+
# get latest release
73+
local latest_response=$(curl -sSL "$api_url_prefix/latest")
74+
local version=$(echo $latest_response | jq -r '.tag_name')
75+
local version_num="${version:1}"
9076

91-
find_binary_name() {
92-
local v=$(echo $version | tr -d 'v')
9377
local suffix=""
9478
case "$os" in
9579
Linux)
@@ -121,15 +105,13 @@ find_binary_name() {
121105
suffix="${suffix}-musl"
122106
fi
123107

124-
if [ "$v" == "nightly" ]; then
125-
debug_v "Obtain correct version for nightly"
126-
v=$(curl -sSL --fail "https://raw.githubusercontent.com/SwissDataScienceCenter/renku-cli/main/Cargo.toml" | grep "^version" | cut -d'=' -f2 | tr -d '[:space:]' | tr -d '"')
127-
suffix="${suffix}-$v"
128-
else
129-
suffix="${suffix}-$v"
108+
local name_prefix="rnk_${suffix}-${version_num}"
109+
local url=$(echo $latest_response | jq -r ".assets[]|select(.name | startswith(\"$name_prefix\"))|.browser_download_url")
110+
if [ -z "$url" ]; then
111+
echo "No download url could be found for $name_prefix."
112+
exit 1
130113
fi
131-
132-
echo "rnk_${suffix}"
114+
echo $version_num $url
133115
}
134116

135117
while getopts "ht:cv" arg; do
@@ -151,13 +133,6 @@ while getopts "ht:cv" arg; do
151133
esac
152134
done
153135

154-
## check for jq otherwise use grep
155-
if ! type -P rjq >/dev/null; then
156-
debug_v "jq is not installed, use grep instead"
157-
else
158-
jq="jq"
159-
fi
160-
161136
# The aarch64 executables won't work on Android
162137
if [ "$dist" == "Android" ]; then
163138
debug "Sorry, Android is not yet supported."
@@ -166,6 +141,8 @@ fi
166141

167142
## check for curl
168143
assert_exec "curl"
144+
## check for jq
145+
assert_exec jq
169146
## check for cut, grep (should be available)
170147
assert_exec "cut"
171148
assert_exec "grep"
@@ -176,7 +153,7 @@ fi
176153

177154
if [ $check_latest -eq 1 ]; then
178155
debug_v "Check for latest version only"
179-
find_latest_release_name
156+
find_latest_release
180157
exit 0
181158
else
182159
# Check for nixos
@@ -189,17 +166,15 @@ else
189166
## check for sudo first
190167
assert_exec "sudo"
191168

192-
version=$(find_latest_release_name)
193-
binary=$(find_binary_name)
194-
url="$dl_url_prefix/download/$version/$binary"
195-
debug "Getting renku-cli $version..."
169+
read version url < <(find_latest_release)
170+
debug "Getting renku-cli $version ..."
196171
debug_v "from: $url"
197172
curl -# -sSL --fail -o "$tdir/rnk" "$url"
198173
chmod 755 "$tdir/rnk"
199174

200175
debug "Installing to $target"
201176
sudo mkdir -p "$target"
202-
sudo cp "$tdir/rnk" "$target/$binary_name"
177+
sudo cp "$tdir/rnk" "$target/rnk"
203178
debug "Done."
204179
fi
205180
fi

0 commit comments

Comments
 (0)