Release 1.3.3
install.sh now installs the newest published tag by default instead of tracking the master branch, so 'curl ... | sh' installs a real release and reports its version. The tag is resolved from the Gitea tags API, falling back to master if the lookup fails. MOVE_VERSION still pins an explicit ref.
This commit is contained in:
+37
-2
@@ -30,7 +30,9 @@
|
||||
# version is replaced, and the config is left alone.
|
||||
#
|
||||
# Env vars (all optional):
|
||||
# MOVE_VERSION Branch or tag to install. Default: master.
|
||||
# MOVE_VERSION Branch or tag to install. Default: the newest tag
|
||||
# published to the repo, falling back to the master
|
||||
# branch if that can't be determined.
|
||||
# MOVE_FORCE Set to 1 to skip every prompt and reinstall
|
||||
# unconditionally. Does not touch the user config.
|
||||
# MOVE_RESEED_CONFIG Set to 1 to overwrite the user config with the
|
||||
@@ -52,7 +54,9 @@ REPO_OWNER="nokeo08"
|
||||
REPO_NAME="Move"
|
||||
GITEA_HOST="gitea.cahlen.com"
|
||||
|
||||
MOVE_VERSION="${MOVE_VERSION:-master}"
|
||||
# Left empty when unset so it can be resolved to the latest tag once the
|
||||
# prerequisite tools are confirmed present (see "Resolve version" below).
|
||||
MOVE_VERSION="${MOVE_VERSION:-}"
|
||||
MOVE_FORCE="${MOVE_FORCE:-0}"
|
||||
MOVE_RESEED_CONFIG="${MOVE_RESEED_CONFIG:-0}"
|
||||
|
||||
@@ -80,6 +84,20 @@ assert_safe_dir() {
|
||||
esac
|
||||
}
|
||||
|
||||
# Print the newest tag name published to the repo (e.g. v1.3.2), or return
|
||||
# non-zero if it can't be determined. The Gitea tags API lists newest first,
|
||||
# so with ?limit=1 the sole entry is the latest tag; grep+sed pull its "name"
|
||||
# without a jq dependency. Any failure -- offline, API error, no tags, a
|
||||
# missing grep/sed -- collapses to a non-zero return and lets the caller fall
|
||||
# back to the master branch.
|
||||
resolve_latest_tag() {
|
||||
_tags_url="https://$GITEA_HOST/api/v1/repos/$REPO_OWNER/$REPO_NAME/tags?limit=1"
|
||||
_json=$(curl -fsSL --max-time 10 "$_tags_url" 2>/dev/null) || return 1
|
||||
_tag=$(printf '%s' "$_json" | grep -o '"name":"[^"]*"' | head -n 1 | sed 's/.*:"//; s/"$//')
|
||||
[ -n "$_tag" ] || return 1
|
||||
printf '%s\n' "$_tag"
|
||||
}
|
||||
|
||||
# --- Interactive prompt support ----------------------------------------------
|
||||
#
|
||||
# The documented entry point is `curl -fsSL ... | sh`, which means stdin is
|
||||
@@ -168,6 +186,23 @@ fi
|
||||
BUN_VERSION=$(bun --version)
|
||||
printf '==> Using bun %s\n' "$BUN_VERSION"
|
||||
|
||||
# --- Resolve version to install ----------------------------------------------
|
||||
#
|
||||
# With no explicit MOVE_VERSION, default to the newest published tag so the
|
||||
# plain one-liner installs a real release and reports its version (e.g.
|
||||
# v1.3.2) rather than tracking the moving `master` branch. If the lookup
|
||||
# fails -- offline, API unreachable, or no tags yet -- fall back to master,
|
||||
# preserving the historical behavior instead of aborting.
|
||||
|
||||
if [ -z "$MOVE_VERSION" ]; then
|
||||
if MOVE_VERSION=$(resolve_latest_tag); then
|
||||
printf '==> Latest release is %s\n' "$MOVE_VERSION"
|
||||
else
|
||||
MOVE_VERSION=master
|
||||
printf '==> Could not determine latest release; installing from master\n' >&2
|
||||
fi
|
||||
fi
|
||||
|
||||
# --- Existing install check --------------------------------------------------
|
||||
#
|
||||
# Both questions this script can ask are asked here, before anything is
|
||||
|
||||
Reference in New Issue
Block a user