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.

[INFRA-1039] fix(deployments): find the latest release when the GitHub API returns compact JSON (#9916)

Akshat Jainb348e442e99c
diff --git a/deployments/cli/community/install.sh b/deployments/cli/community/install.sh
index accd89c812..bae937673d 100755
--- a/deployments/cli/community/install.sh
+++ b/deployments/cli/community/install.sh
@@ -57,7 +57,7 @@ function spinner() {
function checkLatestRelease(){
echo "Checking for the latest release..." >&2
- local latest_release=$(curl -sSL https://api.github.com/repos/$GH_REPO/releases/latest | grep -o '"tag_name": "[^"]*"' | sed 's/"tag_name": "//;s/"//g')
+ local latest_release=$(curl -sSL 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
@@ -217,7 +217,9 @@ function install() {
echo ""
if [ "$APP_RELEASE" == "stable" ]; then
- export APP_RELEASE=$(checkLatestRelease)
+ # exit inside checkLatestRelease only leaves the $(...) subshell
+ APP_RELEASE=$(checkLatestRelease) || exit 1
+ export APP_RELEASE
fi
local build_image=$(initialize)
@@ -424,7 +426,8 @@ function restartServices() {
startServices
}
function upgrade() {
- local latest_release=$(checkLatestRelease)
+ local latest_release
+ latest_release=$(checkLatestRelease) || exit 1
echo ""
echo "Current release: $APP_RELEASE"
diff --git a/deployments/swarm/community/swarm.sh b/deployments/swarm/community/swarm.sh
index 02f170f4d3..8a1da47b1a 100755
--- a/deployments/swarm/community/swarm.sh
+++ b/deployments/swarm/community/swarm.sh
@@ -38,7 +38,7 @@ EOF
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')
+ 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
@@ -220,7 +220,7 @@ function deployStack() {
if [ ! -f "$DOCKER_FILE_PATH" ] || [ ! -f "$DOCKER_ENV_PATH" ]; then
echo "Configuration files not found"
echo "Downloading it now......"
- APP_RELEASE=$(checkLatestRelease)
+ APP_RELEASE=$(checkLatestRelease) || exit 1
download
fi
if [ -z "$stack_name" ]; then
@@ -335,7 +335,8 @@ function upgrade() {
exit 1
fi
- local latest_release=$(checkLatestRelease)
+ local latest_release
+ latest_release=$(checkLatestRelease) || exit 1
echo ""
echo "Current release: $APP_RELEASE"