From 02c7fa68aa39b4db8c2222579c14f4837b9236c9 Mon Sep 17 00:00:00 2001 From: hanruo <552455797@qq.com> Date: Sun, 24 May 2026 14:52:12 +0800 Subject: [PATCH] fix --- scripts/install.sh | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/scripts/install.sh b/scripts/install.sh index 94fbd5b..cf4d8f3 100755 --- a/scripts/install.sh +++ b/scripts/install.sh @@ -1,8 +1,8 @@ #!/usr/bin/env bash # server-config-cli installer # -# Usage: -# curl -fsSL /releases/latest/download/install.sh | bash +# Usage (always latest, no version needed): +# curl -fsSL https://gitea1.deeppolicy.cn:3002/hanruo/server-config-cli/raw/branch/main/scripts/install.sh | bash # # Environment overrides: # VERSION release tag to install (default: latest) @@ -47,7 +47,22 @@ NODE_URL="${NODE_MIRROR}/${NODE_VERSION}/${NODE_PKG}" NODE_DIR="${INSTALL_DIR}/node-${NODE_VERSION}-${NODE_OS}-${NODE_ARCH}" if [ "$VERSION" = "latest" ]; then - BUNDLE_URL="${REPO_BASE}/releases/latest/download/app.mjs" + # Resolve the newest release tag via the API (works on all Gitea versions, + # unlike the GitHub-style /releases/latest/download shortcut). + proto="${REPO_BASE%%://*}" + rest="${REPO_BASE#*://}" + host="${rest%%/*}" + repo_path="${rest#*/}" + API_BASE="${proto}://${host}/api/v1/repos/${repo_path}" + + log "Resolving latest release tag" + TAG=$(curl -fsSL "${API_BASE}/releases/latest" \ + | grep -o '"tag_name"[[:space:]]*:[[:space:]]*"[^"]*"' \ + | head -1 \ + | sed -E 's/.*"tag_name"[[:space:]]*:[[:space:]]*"([^"]*)".*/\1/') + [ -n "$TAG" ] || die "could not resolve latest release tag from ${API_BASE}/releases/latest" + log "Latest release is ${TAG}" + BUNDLE_URL="${REPO_BASE}/releases/download/${TAG}/app.mjs" else BUNDLE_URL="${REPO_BASE}/releases/download/${VERSION}/app.mjs" fi