This commit is contained in:
@@ -1,8 +1,8 @@
|
||||
#!/usr/bin/env bash
|
||||
# server-config-cli installer
|
||||
#
|
||||
# Usage:
|
||||
# curl -fsSL <REPO>/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
|
||||
|
||||
Reference in New Issue
Block a user