mirror of
https://github.com/memohai/Memoh.git
synced 2026-04-25 07:00:48 +09:00
feat: dynamic version to install.sh (#70)
This commit is contained in:
+28
-6
@@ -7,9 +7,10 @@ RED='\033[0;31m'
|
|||||||
NC='\033[0m'
|
NC='\033[0m'
|
||||||
|
|
||||||
REPO="https://github.com/memohai/Memoh.git"
|
REPO="https://github.com/memohai/Memoh.git"
|
||||||
BRANCH="main"
|
REPO_API="https://api.github.com/repos/memohai/Memoh"
|
||||||
DIR="Memoh"
|
DIR="Memoh"
|
||||||
SILENT=false
|
SILENT=false
|
||||||
|
MEMOH_VERSION="${MEMOH_VERSION:-latest}"
|
||||||
|
|
||||||
# Parse flags
|
# Parse flags
|
||||||
for arg in "$@"; do
|
for arg in "$@"; do
|
||||||
@@ -52,6 +53,26 @@ fi
|
|||||||
echo "${GREEN}✓ Docker and Docker Compose detected${NC}"
|
echo "${GREEN}✓ Docker and Docker Compose detected${NC}"
|
||||||
echo ""
|
echo ""
|
||||||
|
|
||||||
|
# Resolve MEMOH_VERSION: if empty or "latest", fetch the latest release tag from GitHub
|
||||||
|
if [ -z "$MEMOH_VERSION" ] || [ "$MEMOH_VERSION" = "latest" ]; then
|
||||||
|
echo "Fetching latest release version from GitHub..."
|
||||||
|
if command -v curl >/dev/null 2>&1; then
|
||||||
|
MEMOH_VERSION=$(curl -fsSL "$REPO_API/releases/latest" | grep '"tag_name"' | head -1 | sed 's/.*"tag_name"[[:space:]]*:[[:space:]]*"\([^"]*\)".*/\1/')
|
||||||
|
elif command -v wget >/dev/null 2>&1; then
|
||||||
|
MEMOH_VERSION=$(wget -qO- "$REPO_API/releases/latest" | grep '"tag_name"' | head -1 | sed 's/.*"tag_name"[[:space:]]*:[[:space:]]*"\([^"]*\)".*/\1/')
|
||||||
|
else
|
||||||
|
echo "${RED}Error: curl or wget is required to fetch the latest version${NC}"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
if [ -z "$MEMOH_VERSION" ]; then
|
||||||
|
echo "${RED}Error: Failed to fetch latest release version from GitHub${NC}"
|
||||||
|
echo "You can set MEMOH_VERSION manually, e.g.: MEMOH_VERSION=v1.0.0 sh install.sh"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
echo "${GREEN}✓ Version: ${MEMOH_VERSION}${NC}"
|
||||||
|
echo ""
|
||||||
|
|
||||||
# Generate random JWT secret
|
# Generate random JWT secret
|
||||||
gen_secret() {
|
gen_secret() {
|
||||||
if command -v openssl >/dev/null 2>&1; then
|
if command -v openssl >/dev/null 2>&1; then
|
||||||
@@ -120,14 +141,15 @@ fi
|
|||||||
mkdir -p "$WORKSPACE"
|
mkdir -p "$WORKSPACE"
|
||||||
cd "$WORKSPACE"
|
cd "$WORKSPACE"
|
||||||
|
|
||||||
# Clone or update
|
# Clone or update to the target version tag
|
||||||
if [ -d "$DIR" ]; then
|
if [ -d "$DIR" ]; then
|
||||||
echo "Updating existing installation in $WORKSPACE..."
|
echo "Updating existing installation in $WORKSPACE to ${MEMOH_VERSION}..."
|
||||||
cd "$DIR"
|
cd "$DIR"
|
||||||
git pull --ff-only 2>/dev/null || true
|
git fetch --tags --depth 1 origin "refs/tags/${MEMOH_VERSION}:refs/tags/${MEMOH_VERSION}" 2>/dev/null || git fetch --tags --depth 1 origin
|
||||||
|
git checkout "${MEMOH_VERSION}" 2>/dev/null || { echo "${RED}Error: Tag ${MEMOH_VERSION} not found${NC}"; exit 1; }
|
||||||
else
|
else
|
||||||
echo "Cloning Memoh into $WORKSPACE..."
|
echo "Cloning Memoh (${MEMOH_VERSION}) into $WORKSPACE..."
|
||||||
git clone --depth 1 -b "$BRANCH" "$REPO" "$DIR"
|
git clone --depth 1 -b "$MEMOH_VERSION" "$REPO" "$DIR"
|
||||||
cd "$DIR"
|
cd "$DIR"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user