|
2 | 2 | # Stackdog Security — install script |
3 | 3 | # |
4 | 4 | # Usage: |
5 | | -# curl -fsSL https://raw.githubusercontent.com/vsilent/stackdog/dev/install.sh | sudo bash |
6 | | -# curl -fsSL https://raw.githubusercontent.com/vsilent/stackdog/dev/install.sh | sudo bash -s -- --version v0.2.0 |
| 5 | +# curl -fsSL https://raw.githubusercontent.com/vsilent/stackdog/main/install.sh | sudo bash |
| 6 | +# curl -fsSL https://raw.githubusercontent.com/vsilent/stackdog/main/install.sh | sudo bash -s -- --version v0.2.0 |
7 | 7 | # |
8 | 8 | # Installs the stackdog binary to /usr/local/bin. |
9 | 9 | # Requires: curl, tar, sha256sum (or shasum), Linux x86_64 or aarch64. |
@@ -57,11 +57,23 @@ resolve_version() { |
57 | 57 | fi |
58 | 58 |
|
59 | 59 | info "Fetching latest release..." |
60 | | - TAG="$(curl -fsSL "https://api.github.com/repos/${REPO}/releases/latest" \ |
61 | | - | grep '"tag_name"' | head -1 | sed 's/.*"tag_name": *"\([^"]*\)".*/\1/')" |
| 60 | + TAG="$( |
| 61 | + curl -fsSL "https://api.github.com/repos/${REPO}/releases/latest" 2>/dev/null \ |
| 62 | + | grep '"tag_name"' | head -1 | sed 's/.*"tag_name": *"\([^"]*\)".*/\1/' || true |
| 63 | + )" |
62 | 64 |
|
| 65 | + # GitHub returns 404 for /releases/latest when there are no stable releases |
| 66 | + # (for example only pre-releases). Fall back to the most recent release entry. |
63 | 67 | if [ -z "$TAG" ]; then |
64 | | - error "Could not determine latest release. Specify a version with --version" |
| 68 | + warn "No stable 'latest' release found, trying most recent release..." |
| 69 | + TAG="$( |
| 70 | + curl -fsSL "https://api.github.com/repos/${REPO}/releases?per_page=1" 2>/dev/null \ |
| 71 | + | grep '"tag_name"' | head -1 | sed 's/.*"tag_name": *"\([^"]*\)".*/\1/' || true |
| 72 | + )" |
| 73 | + fi |
| 74 | + |
| 75 | + if [ -z "$TAG" ]; then |
| 76 | + error "Could not determine latest release. Create a GitHub release, or specify one with --version (e.g. --version v0.2.0)." |
65 | 77 | fi |
66 | 78 |
|
67 | 79 | VERSION="$(echo "$TAG" | sed 's/^v//')" |
|
0 commit comments