install.sh: auto-fetch latest release tag
This commit is contained in:
15
install.sh
15
install.sh
@@ -4,7 +4,6 @@ set -e
|
||||
REPO="chris/agent-tui"
|
||||
BASE_URL="https://gitea.yeeted.lol"
|
||||
INSTALL_DIR="${INSTALL_DIR:-/usr/local/bin}"
|
||||
TAG="${1:-v0.1.0}"
|
||||
|
||||
OS=$(uname -s | tr '[:upper:]' '[:lower:]')
|
||||
ARCH=$(uname -m)
|
||||
@@ -20,6 +19,18 @@ case "$OS" in
|
||||
*) echo "Unsupported OS: $OS" >&2; exit 1 ;;
|
||||
esac
|
||||
|
||||
# Resolve tag: use argument, or fetch latest release
|
||||
if [ -n "$1" ]; then
|
||||
TAG="$1"
|
||||
else
|
||||
TAG=$(curl -fsSL "${BASE_URL}/api/v1/repos/${REPO}/releases?limit=1" \
|
||||
| grep -o '"tag_name":"[^"]*"' | head -1 | cut -d'"' -f4)
|
||||
if [ -z "$TAG" ]; then
|
||||
echo "Error: could not determine latest release" >&2
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
BINARY="agent-tui-${OS}-${ARCH}"
|
||||
URL="${BASE_URL}/${REPO}/releases/download/${TAG}/${BINARY}"
|
||||
|
||||
@@ -45,4 +56,4 @@ else
|
||||
sudo mv "$TMP" "${INSTALL_DIR}/agent-tui"
|
||||
fi
|
||||
|
||||
echo "Installed agent-tui to ${INSTALL_DIR}/agent-tui"
|
||||
echo "Installed agent-tui ${TAG} to ${INSTALL_DIR}/agent-tui"
|
||||
|
||||
Reference in New Issue
Block a user