Skip to content

armgit / plane

Public Imported from GitHub
0

πŸ”₯πŸ”₯πŸ”₯ Open-source Jira, Linear, Monday, and ClickUp alternative. Plane is a modern project management platform to manage tasks, sprints, docs, and triage.

chore: Check github releases for upgrades (#6162)

Manish Guptaa0f03d07f306
diff --git a/deploy/selfhost/README.md b/deploy/selfhost/README.md
index d93d85ca14..ccd8bf328c 100644
--- a/deploy/selfhost/README.md
+++ b/deploy/selfhost/README.md
@@ -62,7 +62,7 @@ mkdir plane-selfhost
cd plane-selfhost
-curl -fsSL -o setup.sh https://raw.githubusercontent.com/makeplane/plane/master/deploy/selfhost/install.sh
+curl -fsSL -o setup.sh https://github.com/makeplane/plane/releases/latest/download/setup.sh
chmod +x setup.sh
```
diff --git a/deploy/selfhost/install.sh b/deploy/selfhost/install.sh
index 08cd4d9169..1c2208cab7 100755
--- a/deploy/selfhost/install.sh
+++ b/deploy/selfhost/install.sh
@@ -4,9 +4,12 @@ BRANCH=${BRANCH:-master}
SCRIPT_DIR=$PWD
SERVICE_FOLDER=plane-app
PLANE_INSTALL_DIR=$PWD/$SERVICE_FOLDER
-export APP_RELEASE="stable"
+export APP_RELEASE=stable
export DOCKERHUB_USER=makeplane
export PULL_POLICY=${PULL_POLICY:-if_not_present}
+export GH_REPO=makeplane/plane
+export RELEASE_DOWNLOAD_URL="https://github.com/$GH_REPO/releases/download"
+export FALLBACK_DOWNLOAD_URL="https://raw.githubusercontent.com/$GH_REPO/$BRANCH/deploy/selfhost"
CPU_ARCH=$(uname -m)
OS_NAME=$(uname)
@@ -16,13 +19,6 @@ mkdir -p $PLANE_INSTALL_DIR/archive
DOCKER_FILE_PATH=$PLANE_INSTALL_DIR/docker-compose.yaml
DOCKER_ENV_PATH=$PLANE_INSTALL_DIR/plane.env
-SED_PREFIX=()
-if [ "$OS_NAME" == "Darwin" ]; then
- SED_PREFIX=("-i" "")
-else
- SED_PREFIX=("-i")
-fi
-
function print_header() {
clear
@@ -59,6 +55,17 @@ function spinner() {
printf " \b\b\b\b" >&2
}
+function checkLatestRelease(){
+ echo "Checking for the latest release..." >&2
+ local latest_release=$(curl -s https://api.github.com/repos/$GH_REPO/releases/latest | grep -o '"tag_name": "[^"]*"' | sed 's/"tag_name": "//;s/"//g')
+ if [ -z "$latest_release" ]; then
+ echo "Failed to check for the latest release. Exiting..." >&2
+ exit 1
+ fi
+
+ echo $latest_release
+}
+
function initialize(){
printf "Please wait while we check the availability of Docker images for the selected release ($APP_RELEASE) with ${UPPER_CPU_ARCH} support." >&2
@@ -130,8 +137,12 @@ function updateEnvFile() {
echo "$key=$value" >> "$file"
return
else
- # if key exists, update the value
- sed "${SED_PREFIX[@]}" "s/^$key=.*/$key=$value/g" "$file"
+ if [ "$OS_NAME" == "Darwin" ]; then
+ value=$(echo "$value" | sed 's/|/\\|/g')
+ sed -i '' "s|^$key=.*|$key=$value|g" "$file"
+ else
+ sed -i "s/^$key=.*/$key=$value/g" "$file"
+ fi
fi
else
echo "File not found: $file"
@@ -182,7 +193,7 @@ function buildYourOwnImage(){
local PLANE_TEMP_CODE_DIR=~/tmp/plane
rm -rf $PLANE_TEMP_CODE_DIR
mkdir -p $PLANE_TEMP_CODE_DIR
- REPO=https://github.com/makeplane/plane.git
+ REPO=https://github.com/$GH_REPO.git
git clone "$REPO" "$PLANE_TEMP_CODE_DIR" --branch "$BRANCH" --single-branch --depth 1
cp "$PLANE_TEMP_CODE_DIR/deploy/selfhost/build.yml" "$PLANE_TEMP_CODE_DIR/build.yml"
@@ -204,6 +215,10 @@ function install() {
echo "Begin Installing Plane"
echo ""
+ if [ "$APP_RELEASE" == "stable" ]; then
+ export APP_RELEASE=$(checkLatestRelease)
+ fi
+
local build_image=$(initialize)
if [ "$build_image" == "build" ]; then
@@ -232,8 +247,49 @@ function download() {
mv $PLANE_INSTALL_DIR/docker-compose.yaml $PLANE_INSTALL_DIR/archive/$TS.docker-compose.yaml
fi
- curl -H 'Cache-Control: no-cache, no-store' -s -o $PLANE_INSTALL_DIR/docker-compose.yaml https://raw.githubusercontent.com/makeplane/plane/$BRANCH/deploy/selfhost/docker-compose.yml?$(date +%s)
- curl -H 'Cache-Control: no-cache, no-store' -s -o $PLANE_INSTALL_DIR/variables-upgrade.env https://raw.githubusercontent.com/makeplane/plane/$BRANCH/deploy/selfhost/variables.env?$(date +%s)
+ RESPONSE=$(curl -H 'Cache-Control: no-cache, no-store' -s -w "HTTPSTATUS:%{http_code}" "$RELEASE_DOWNLOAD_URL/$APP_RELEASE/docker-compose.yml?$(date +%s)")
+ BODY=$(echo "$RESPONSE" | sed -e 's/HTTPSTATUS\:.*//g')
+ STATUS=$(echo "$RESPONSE" | tr -d '\n' | sed -e 's/.*HTTPSTATUS://')
+
+ if [ "$STATUS" -eq 200 ]; then
+ echo "$BODY" > $PLANE_INSTALL_DIR/docker-compose.yaml
+ else
+ # Fallback to download from the raw github url
+ RESPONSE=$(curl -H 'Cache-Control: no-cache, no-store' -s -w "HTTPSTATUS:%{http_code}" "$FALLBACK_DOWNLOAD_URL/docker-compose.yml?$(date +%s)")
+ BODY=$(echo "$RESPONSE" | sed -e 's/HTTPSTATUS\:.*//g')
+ STATUS=$(echo "$RESPONSE" | tr -d '\n' | sed -e 's/.*HTTPSTATUS://')
+
+ if [ "$STATUS" -eq 200 ]; then
+ echo "$BODY" > $PLANE_INSTALL_DIR/docker-compose.yaml
+ else
+ echo "Failed to download docker-compose.yml. HTTP Status: $STATUS"
+ echo "URL: $RELEASE_DOWNLOAD_URL/$APP_RELEASE/docker-compose.yml"
+ mv $PLANE_INSTALL_DIR/archive/$TS.docker-compose.yaml $PLANE_INSTALL_DIR/docker-compose.yaml
+ exit 1
+ fi
+ fi
+
+ RESPONSE=$(curl -H 'Cache-Control: no-cache, no-store' -s -w "HTTPSTATUS:%{http_code}" "$RELEASE_DOWNLOAD_URL/$APP_RELEASE/variables.env?$(date +%s)")
+ BODY=$(echo "$RESPONSE" | sed -e 's/HTTPSTATUS\:.*//g')
+ STATUS=$(echo "$RESPONSE" | tr -d '\n' | sed -e 's/.*HTTPSTATUS://')
+
+ if [ "$STATUS" -eq 200 ]; then
+ echo "$BODY" > $PLANE_INSTALL_DIR/variables-upgrade.env
+ else
+ # Fallback to download from the raw github url
+ RESPONSE=$(curl -H 'Cache-Control: no-cache, no-store' -s -w "HTTPSTATUS:%{http_code}" "$FALLBACK_DOWNLOAD_URL/variables.env?$(date +%s)")
+ BODY=$(echo "$RESPONSE" | sed -e 's/HTTPSTATUS\:.*//g')
+ STATUS=$(echo "$RESPONSE" | tr -d '\n' | sed -e 's/.*HTTPSTATUS://')
+
+ if [ "$STATUS" -eq 200 ]; then
+ echo "$BODY" > $PLANE_INSTALL_DIR/variables-upgrade.env
+ else
+ echo "Failed to download variables.env. HTTP Status: $STATUS"
+ echo "URL: $RELEASE_DOWNLOAD_URL/$APP_RELEASE/variables.env"
+ mv $PLANE_INSTALL_DIR/archive/$TS.docker-compose.yaml $PLANE_INSTALL_DIR/docker-compose.yaml
+ exit 1
+ fi
+ fi
if [ -f "$DOCKER_ENV_PATH" ];
then
@@ -335,6 +391,34 @@ function restartServices() {
startServices
}
function upgrade() {
+ local latest_release=$(checkLatestRelease)
+
+ echo ""
+ echo "Current release: $APP_RELEASE"
+
+ if [ "$latest_release" == "$APP_RELEASE" ]; then
+ echo ""
+ echo "You are already using the latest release"
+ exit 0
+ fi
+
+ echo "Latest release: $latest_release"
+ echo ""
+
+ # Check for confirmation to upgrade
+ echo "Do you want to upgrade to the latest release ($latest_release)?"
+ read -p "Continue? [y/N]: " confirm
+
+ if [[ ! "$confirm" =~ ^[Yy]$ ]]; then
+ echo "Exiting..."
+ exit 0
+ fi
+
+ export APP_RELEASE=$latest_release
+
+ echo "Upgrading Plane to the latest release..."
+ echo ""
+
echo "***** STOPPING SERVICES ****"
stopServices