fix update to latest
This commit is contained in:
parent
50eaac6b2a
commit
c8b36f3ec5
@ -30,15 +30,71 @@ function update_script() {
|
||||
msg_error "No ${APP} Installation Found!"
|
||||
exit
|
||||
fi
|
||||
msg_info "Updating ${APP}"
|
||||
systemctl stop snowshare
|
||||
|
||||
# S'assurer que jq est installé pour l'analyse de l'API
|
||||
if ! command -v jq &> /dev/null; then
|
||||
msg_info "Installing 'jq' (required for update check)..."
|
||||
apt-get update &>/dev/null
|
||||
apt-get install -y jq &>/dev/null
|
||||
if ! command -v jq &> /dev/null; then
|
||||
msg_error "Failed to install 'jq'. Cannot proceed with update."
|
||||
exit 1
|
||||
fi
|
||||
msg_ok "Installed 'jq'"
|
||||
fi
|
||||
|
||||
msg_info "Checking for ${APP} updates..."
|
||||
cd /opt/snowshare
|
||||
git pull
|
||||
|
||||
# Obtenir le tag local actuel
|
||||
CURRENT_TAG=$(git describe --tags 2>/dev/null)
|
||||
if [ $? -ne 0 ]; then
|
||||
msg_warn "Could not determine current version tag. Fetching latest..."
|
||||
CURRENT_TAG="unknown"
|
||||
fi
|
||||
|
||||
# Obtenir le tag de la dernière release depuis GitHub
|
||||
LATEST_TAG=$(curl -s "https://api.github.com/repos/TuroYT/snowshare/releases/latest" | jq -r .tag_name)
|
||||
|
||||
if [ -z "$LATEST_TAG" ] || [ "$LATEST_TAG" == "null" ]; then
|
||||
msg_error "Failed to fetch the latest release tag from GitHub."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
msg_info "Current version: $CURRENT_TAG"
|
||||
msg_info "Latest version: $LATEST_TAG"
|
||||
|
||||
if [ "$CURRENT_TAG" == "$LATEST_TAG" ]; then
|
||||
msg_ok "${APP} is already up to date."
|
||||
exit
|
||||
fi
|
||||
|
||||
msg_info "Updating ${APP} to $LATEST_TAG..."
|
||||
systemctl stop snowshare
|
||||
|
||||
# Récupérer les nouveaux tags
|
||||
git fetch --tags
|
||||
|
||||
# Se placer sur le dernier tag
|
||||
git checkout $LATEST_TAG
|
||||
if [ $? -ne 0 ]; then
|
||||
msg_error "Failed to checkout tag $LATEST_TAG. Aborting update."
|
||||
systemctl start snowshare
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Relancer les étapes d'installation et de build
|
||||
msg_info "Installing dependencies..."
|
||||
npm ci
|
||||
msg_info "Generating Prisma client..."
|
||||
npx prisma generate
|
||||
msg_info "Applying database migrations..."
|
||||
npx prisma migrate deploy # Important pour les changements de schéma
|
||||
msg_info "Building application..."
|
||||
npm run build
|
||||
|
||||
systemctl start snowshare
|
||||
msg_ok "Updated ${APP}"
|
||||
msg_ok "Updated ${APP} to $LATEST_TAG"
|
||||
exit
|
||||
}
|
||||
|
||||
@ -49,4 +105,4 @@ description
|
||||
msg_ok "Completed Successfully!\n"
|
||||
echo -e "${CREATING}${GN}${APP} setup has been successfully initialized!${CL}"
|
||||
echo -e "${INFO}${YW} Access it using the following URL:${CL}"
|
||||
echo -e "${TAB}${GATEWAY}${BGN}http://${IP}:3000${CL}"
|
||||
echo -e "${TAB}${GATEWAY}${BGN}http://${IP}:3000${CL}"
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user