2eb4275e6f
deploy-{server,site,client}.sh 目标主机参数化(DEPLOY_HOST/USER/SSH_KEY),
不传时行为与现状完全一致(只发 EC2)。workflow 的 Deploy 拆成 EC2(前)+
Ali(后,if:always + continue-on-error,影子目标失败不挡线上)。deploy-server
的 ali 分支只换二进制 + reload 独立 nginx(listen 443),不启动 jiu(阿里 DB
为只读从库,切流提升为主后才起)。新增 deploy/nginx-jiu-ali.conf 并打进
configs.tar.gz。
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01YZ4DskSRKsSiheQonFtQvx
70 lines
2.9 KiB
Bash
70 lines
2.9 KiB
Bash
#!/usr/bin/env bash
|
|
# deploy-client.sh <tag> — deploy the Flutter web app, desktop/mobile installers,
|
|
# and version.yaml. Does NOT restart the backend (version.yaml is read
|
|
# per-request) nor touch nginx / the marketing site. Target is EC2 by default;
|
|
# set DEPLOY_HOST/DEPLOY_USER/DEPLOY_SSH_KEY to retarget the Ali box (migration).
|
|
set -euo pipefail
|
|
|
|
# shellcheck source=scripts/ci/lib-forgejo.sh
|
|
. "$(dirname "$0")/lib-forgejo.sh"
|
|
|
|
TAG="$1"
|
|
TARGET_HOST="${DEPLOY_HOST:-$EC2_HOST}"
|
|
TARGET_USER="${DEPLOY_USER:-$EC2_USER}"
|
|
echo "==> deploy-client: tag=${TAG} host=${TARGET_HOST}"
|
|
|
|
if [ ! -f dist/web.tar.gz ] || [ ! -f dist/version.yaml ]; then
|
|
download_release_assets "$TAG"
|
|
fi
|
|
|
|
echo "==> deploy-client: dist/ contents:"
|
|
ls -lh dist/
|
|
|
|
# Prefer the version.yaml released for this tag (carries bumped build_number +
|
|
# changelog); fall back to the checkout copy only if the asset is absent.
|
|
VERSION_YAML="dist/version.yaml"
|
|
[ -f "$VERSION_YAML" ] || VERSION_YAML="backend/config/version.yaml"
|
|
|
|
rm -rf /tmp/jiu-web-new
|
|
mkdir -p /tmp/jiu-web-new
|
|
tar -xzf dist/web.tar.gz -C /tmp/jiu-web-new --strip-components=1
|
|
|
|
setup_ssh
|
|
echo "==> deploy-client: uploading files to ${TARGET_HOST}"
|
|
${SCP} "$VERSION_YAML" "${TARGET_USER}@${TARGET_HOST}:/tmp/version.yaml"
|
|
rsync -avz --delete -e "ssh -i ~/.ssh/ec2_deploy.pem -o StrictHostKeyChecking=no" \
|
|
/tmp/jiu-web-new/ "${TARGET_USER}@${TARGET_HOST}:/tmp/jiu-web-new/"
|
|
|
|
# Desktop / mobile installers (served from /downloads/ by nginx). Guarded —
|
|
# may be absent in a partial manual deploy.
|
|
[ -f dist/jiu-windows-x64-setup.exe ] && ${SCP} dist/jiu-windows-x64-setup.exe "${TARGET_USER}@${TARGET_HOST}:/tmp/jiu-windows-x64-setup.exe" || true
|
|
[ -f dist/jiu-macos-x64.zip ] && ${SCP} dist/jiu-macos-x64.zip "${TARGET_USER}@${TARGET_HOST}:/tmp/jiu-macos-x64.zip" || true
|
|
[ -f dist/jiu-android.apk ] && ${SCP} dist/jiu-android.apk "${TARGET_USER}@${TARGET_HOST}:/tmp/jiu-android.apk" || true
|
|
|
|
${SSH} "${TARGET_USER}@${TARGET_HOST}" << 'ENDSSH'
|
|
set -e
|
|
|
|
# Update version config (WorkingDirectory=/opt/jiu reads config/version.yaml).
|
|
# Backend re-reads it per request — no restart needed.
|
|
mkdir -p /opt/jiu/config
|
|
cp /tmp/version.yaml /opt/jiu/config/version.yaml
|
|
|
|
# Swap Flutter web app (atomic)
|
|
rm -rf /opt/jiu/web-old
|
|
mv /opt/jiu/web /opt/jiu/web-old 2>/dev/null || true
|
|
mv /tmp/jiu-web-new /opt/jiu/web
|
|
|
|
# Publish installers to the nginx-served downloads dir; keep only the latest.
|
|
mkdir -p /opt/jiu/downloads
|
|
rm -f /opt/jiu/downloads/jiu-windows-* /opt/jiu/downloads/jiu-macos-* /opt/jiu/downloads/jiu-android-* /opt/jiu/downloads/jiu-android.apk 2>/dev/null || true
|
|
[ -f /tmp/jiu-windows-x64-setup.exe ] && mv -f /tmp/jiu-windows-x64-setup.exe /opt/jiu/downloads/ || true
|
|
[ -f /tmp/jiu-macos-x64.zip ] && mv -f /tmp/jiu-macos-x64.zip /opt/jiu/downloads/ || true
|
|
[ -f /tmp/jiu-android.apk ] && mv -f /tmp/jiu-android.apk /opt/jiu/downloads/ || true
|
|
|
|
echo "Client deploy complete!"
|
|
ENDSSH
|
|
|
|
teardown_ssh
|
|
rm -rf /tmp/jiu-web-new
|
|
echo "==> deploy-client: done"
|