- Issue #4: currently there is no official release yet so we cant download from installer - I added an installer debugger here to test (f091dbf13bdf109b631951e2558651f560ca8b84) - Issue #5: my another library [fuzzy](https://github.com/versenilvis/fuzzy/) has a logic bug so it causes crash, fix d479c6cb4d8453e50366c9839daaabb45a98a2df - Other: - remove unneeded comments (edd9d05fdd16e682b6b416913e2fa9c3f6599956) - Add some tests - Fix reload crash (3a76e78e655fd8daafb635ec0937667325f75ee4) - New optimized build command (56a4a815f836271b861f32795d2df3b25a3dffc0)
This commit is contained in:
+21
-9
@@ -6,6 +6,8 @@ set -e
|
||||
|
||||
REPO="versenilvis/iris"
|
||||
BIN_DIR="${BIN_DIR:-/usr/local/bin}"
|
||||
# allow overriding the GitHub API base URL for local testing
|
||||
IRIS_API_URL="${IRIS_API_URL:-https://api.github.com}"
|
||||
|
||||
main() {
|
||||
echo "Installing iris..."
|
||||
@@ -55,7 +57,7 @@ main() {
|
||||
echo "Installed iris to ${BIN_DIR}/iris"
|
||||
echo ""
|
||||
|
||||
if "${BIN_DIR}/iris" --version >/dev/null 2>&1; then
|
||||
if "${BIN_DIR}/iris" version >/dev/null 2>&1; then
|
||||
echo "Installation verified."
|
||||
else
|
||||
echo "Warning: could not verify binary"
|
||||
@@ -89,24 +91,34 @@ get_download_url() {
|
||||
arch="$1"
|
||||
|
||||
if command -v curl >/dev/null 2>&1; then
|
||||
releases=$(curl -sL \
|
||||
http_response=$(curl -sL -w "\n%{http_code}" \
|
||||
${GITHUB_TOKEN:+-H "Authorization: Bearer ${GITHUB_TOKEN}"} \
|
||||
"https://api.github.com/repos/${REPO}/releases/latest")
|
||||
"${IRIS_API_URL}/repos/${REPO}/releases/latest")
|
||||
http_code=$(echo "${http_response}" | tail -1)
|
||||
releases=$(echo "${http_response}" | sed '$d')
|
||||
elif command -v wget >/dev/null 2>&1; then
|
||||
releases=$(wget -qO- \
|
||||
tmp_headers=$(mktemp)
|
||||
releases=$(wget -S -qO- \
|
||||
${GITHUB_TOKEN:+--header "Authorization: Bearer ${GITHUB_TOKEN}"} \
|
||||
"https://api.github.com/repos/${REPO}/releases/latest")
|
||||
"${IRIS_API_URL}/repos/${REPO}/releases/latest" 2>"$tmp_headers" || true)
|
||||
http_code=$(grep "HTTP/" "$tmp_headers" | tail -1 | sed -e 's/^[[:space:]]*//' | cut -d' ' -f2)
|
||||
[ -z "${http_code}" ] && http_code="000"
|
||||
rm -f "$tmp_headers"
|
||||
else
|
||||
err "curl or wget is required"
|
||||
fi
|
||||
|
||||
if echo "${releases}" | grep -q "rate limit"; then
|
||||
err "GitHub API rate limited. Try again later or set GITHUB_TOKEN env variable"
|
||||
if [ "${http_code}" = "404" ]; then
|
||||
err "no releases found for ${REPO}. the project may not have published a release yet"
|
||||
fi
|
||||
|
||||
if echo "${releases}" | grep -q '"message"'; then
|
||||
if [ "${http_code}" = "403" ] || echo "${releases}" | grep -q "rate limit"; then
|
||||
err "GitHub API rate limited. try again later or set GITHUB_TOKEN env variable"
|
||||
fi
|
||||
|
||||
if [ "${http_code}" != "200" ]; then
|
||||
msg=$(echo "${releases}" | grep '"message"' | head -1 | cut -d '"' -f 4)
|
||||
err "GitHub API error: ${msg}"
|
||||
err "GitHub API error (HTTP ${http_code}): ${msg}"
|
||||
fi
|
||||
|
||||
url=$(echo "${releases}" | grep "browser_download_url" | grep "${arch}" | head -1 | cut -d '"' -f 4)
|
||||
|
||||
Reference in New Issue
Block a user