From 2f152b7d24cb798c54bc848c80de9518cb385935 Mon Sep 17 00:00:00 2001 From: vsilent Date: Tue, 31 Mar 2026 21:44:02 +0300 Subject: [PATCH] install: fallback when latest release is missing - Handle GitHub /releases/latest 404 gracefully\n- Fallback to most recent release entry\n- Improve install usage examples to main branch URL Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- install.sh | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/install.sh b/install.sh index 11e9942..514bef4 100755 --- a/install.sh +++ b/install.sh @@ -2,8 +2,8 @@ # Stackdog Security — install script # # Usage: -# curl -fsSL https://raw.githubusercontent.com/vsilent/stackdog/dev/install.sh | sudo bash -# curl -fsSL https://raw.githubusercontent.com/vsilent/stackdog/dev/install.sh | sudo bash -s -- --version v0.2.0 +# curl -fsSL https://raw.githubusercontent.com/vsilent/stackdog/main/install.sh | sudo bash +# curl -fsSL https://raw.githubusercontent.com/vsilent/stackdog/main/install.sh | sudo bash -s -- --version v0.2.0 # # Installs the stackdog binary to /usr/local/bin. # Requires: curl, tar, sha256sum (or shasum), Linux x86_64 or aarch64. @@ -57,11 +57,23 @@ resolve_version() { fi info "Fetching latest release..." - TAG="$(curl -fsSL "https://api.github.com/repos/${REPO}/releases/latest" \ - | grep '"tag_name"' | head -1 | sed 's/.*"tag_name": *"\([^"]*\)".*/\1/')" + TAG="$( + curl -fsSL "https://api.github.com/repos/${REPO}/releases/latest" 2>/dev/null \ + | grep '"tag_name"' | head -1 | sed 's/.*"tag_name": *"\([^"]*\)".*/\1/' || true + )" + # GitHub returns 404 for /releases/latest when there are no stable releases + # (for example only pre-releases). Fall back to the most recent release entry. if [ -z "$TAG" ]; then - error "Could not determine latest release. Specify a version with --version" + warn "No stable 'latest' release found, trying most recent release..." + TAG="$( + curl -fsSL "https://api.github.com/repos/${REPO}/releases?per_page=1" 2>/dev/null \ + | grep '"tag_name"' | head -1 | sed 's/.*"tag_name": *"\([^"]*\)".*/\1/' || true + )" + fi + + if [ -z "$TAG" ]; then + error "Could not determine latest release. Create a GitHub release, or specify one with --version (e.g. --version v0.2.0)." fi VERSION="$(echo "$TAG" | sed 's/^v//')"