feat(devops): 发版拆分为 client/site/server 三条独立流水线
将单一 CI/CD 流水线拆成三条互不影响的发布流水线,各有 tag 前缀、独立版本
序列与独立 CHANGELOG:
- client(client-v*):Flutter 全平台 + version.yaml 自更新清单
- site(site-v*):web/ Eleventy 营销站,不含 web 版 app
- server(server-v*):backend Go 服务 + 共享基建 nginx/systemd
新增 3 个 workflow(deploy-client/site/server.yml)替换 deploy.yml;CI 脚本
按 part 拆分为 compile-/release-/deploy-{client,site,server}.sh,抽出公共函数
lib-forgejo.sh;compile-{macos,android,ios,windows}.sh 改去 client-v 前缀;
manual.yml 按前缀路由回滚。
跨流水线解耦:version.yaml 归 client,后端每请求实时读取(不重启、不触发
server 流水线);官网下载页的版本徽章/下载链接/更新日志时间线运行时经
/api/v1/public/release 动态拉取(API 不可达回退构建时静态内容)。为此一次性
扩展后端 changelog 字段(version.go/public.go)与 download.njk 动态渲染。
CHANGELOG.md 重命名为 CHANGELOG-client.md,新增 CHANGELOG-site/server.md;
重写 /release 命令为 /release <part> [version];同步更新 CLAUDE.md 与部署文档。
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -6,7 +6,7 @@ set -euo pipefail
|
||||
. "$(dirname "$0")/_env.sh"
|
||||
|
||||
TAG="$1"
|
||||
VER="${TAG#v}"
|
||||
VER="${TAG#client-v}"
|
||||
|
||||
# versionCode 必须单调递增,否则 Android 无法覆盖升级安装。
|
||||
# 由版本号推导:major*10000 + minor*100 + patch(如 1.0.17 -> 10017)。
|
||||
@@ -43,7 +43,7 @@ cd client
|
||||
flutter build apk --release \
|
||||
"--dart-define=BASE_URL=https://jiu.51yanmei.com" \
|
||||
"--dart-define=PUBLIC_URL=https://jiu.51yanmei.com" \
|
||||
"--dart-define=APP_VERSION=${TAG}"
|
||||
"--dart-define=APP_VERSION=v${VER}"
|
||||
cd ..
|
||||
|
||||
# Locate the built APK (path differs across Flutter versions) and copy to dist/
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
#!/usr/bin/env bash
|
||||
# compile-backend.sh <tag> — build the Linux backend binary + shared-infra
|
||||
# configs.tar.gz into dist/. Server pipeline (server-v*). Does NOT touch
|
||||
# version.yaml (that is client-owned) nor any Flutter/web artifact.
|
||||
set -euo pipefail
|
||||
|
||||
# shellcheck source=scripts/ci/_env.sh
|
||||
. "$(dirname "$0")/_env.sh"
|
||||
|
||||
TAG="$1"
|
||||
echo "==> compile-backend: tag=${TAG}"
|
||||
|
||||
# Build Go backend (linux/amd64 for EC2)
|
||||
cd backend
|
||||
GOOS=linux GOARCH=amd64 CGO_ENABLED=0 go build -o jiu-server .
|
||||
cd ..
|
||||
|
||||
mkdir -p dist
|
||||
mv backend/jiu-server dist/jiu-server
|
||||
|
||||
# Shared infrastructure (nginx/systemd/env/compose). version.yaml is NOT here —
|
||||
# it belongs to the client pipeline.
|
||||
tar -czf dist/configs.tar.gz \
|
||||
deploy/nginx-jiu.conf \
|
||||
deploy/jiu.service \
|
||||
deploy/production.env.template \
|
||||
deploy/setup-ec2.sh \
|
||||
deploy/docker-compose.yml \
|
||||
deploy/docker-compose.jiu.yml
|
||||
|
||||
echo "==> compile-backend: done — dist/ contents:"
|
||||
ls -lh dist/
|
||||
@@ -0,0 +1,29 @@
|
||||
#!/usr/bin/env bash
|
||||
# compile-client-web.sh <tag> — build the Flutter Web app into dist/web.tar.gz.
|
||||
# Client pipeline (client-v*). Served at /app by nginx.
|
||||
set -euo pipefail
|
||||
|
||||
# shellcheck source=scripts/ci/_env.sh
|
||||
. "$(dirname "$0")/_env.sh"
|
||||
|
||||
TAG="$1"
|
||||
VER="${TAG#client-v}"
|
||||
|
||||
echo "==> compile-client-web: version=${VER}"
|
||||
|
||||
# Sync Flutter pubspec version (BSD sed on macOS)
|
||||
sed -i '' "s/^version:.*/version: ${VER}+1/" client/pubspec.yaml
|
||||
|
||||
cd client
|
||||
flutter build web --release \
|
||||
--base-href=/app/ \
|
||||
"--dart-define=BASE_URL=https://jiu.51yanmei.com" \
|
||||
"--dart-define=PUBLIC_URL=https://jiu.51yanmei.com" \
|
||||
"--dart-define=APP_VERSION=v${VER}"
|
||||
cd ..
|
||||
|
||||
mkdir -p dist
|
||||
tar -czf dist/web.tar.gz -C client/build web
|
||||
|
||||
echo "==> compile-client-web: done — dist/ contents:"
|
||||
ls -lh dist/
|
||||
@@ -17,7 +17,7 @@ set -euo pipefail
|
||||
. "$(dirname "$0")/_env.sh"
|
||||
|
||||
TAG="$1"
|
||||
VER="${TAG#v}"
|
||||
VER="${TAG#client-v}"
|
||||
|
||||
# CFBundleVersion(build 号)必须单调递增,否则 TestFlight 拒绝重复上传。
|
||||
MAJOR="$(echo "$VER" | cut -d. -f1)"
|
||||
@@ -105,7 +105,7 @@ flutter build ipa --release \
|
||||
--export-options-plist="$WORK/ExportOptions.plist" \
|
||||
"--dart-define=BASE_URL=https://jiu.51yanmei.com" \
|
||||
"--dart-define=PUBLIC_URL=https://jiu.51yanmei.com" \
|
||||
"--dart-define=APP_VERSION=${TAG}"
|
||||
"--dart-define=APP_VERSION=v${VER}"
|
||||
cd ..
|
||||
|
||||
IPA="$(ls client/build/ios/ipa/*.ipa | head -1)"
|
||||
|
||||
@@ -6,7 +6,7 @@ set -euo pipefail
|
||||
. "$(dirname "$0")/_env.sh"
|
||||
|
||||
TAG="$1"
|
||||
VER="${TAG#v}"
|
||||
VER="${TAG#client-v}"
|
||||
|
||||
echo "==> compile-macos: version=${VER}"
|
||||
|
||||
@@ -18,7 +18,7 @@ cd client
|
||||
flutter build macos --release \
|
||||
"--dart-define=BASE_URL=https://jiu.51yanmei.com" \
|
||||
"--dart-define=PUBLIC_URL=https://jiu.51yanmei.com" \
|
||||
"--dart-define=APP_VERSION=${TAG}"
|
||||
"--dart-define=APP_VERSION=v${VER}"
|
||||
cd ..
|
||||
|
||||
# Package .app bundle into zip
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
#!/usr/bin/env bash
|
||||
# compile-site.sh <tag> — build the Eleventy marketing site into
|
||||
# dist/marketing.tar.gz. Site pipeline (site-v*). Marketing pages only —
|
||||
# the web version of the app is built by compile-client-web.sh.
|
||||
set -euo pipefail
|
||||
|
||||
# shellcheck source=scripts/ci/_env.sh
|
||||
. "$(dirname "$0")/_env.sh"
|
||||
|
||||
TAG="$1"
|
||||
echo "==> compile-site: tag=${TAG}"
|
||||
|
||||
cd web
|
||||
npm ci --prefer-offline
|
||||
npm run build
|
||||
cd ..
|
||||
|
||||
mkdir -p dist
|
||||
tar -czf dist/marketing.tar.gz -C web/dist .
|
||||
|
||||
echo "==> compile-site: done — dist/ contents:"
|
||||
ls -lh dist/
|
||||
@@ -6,7 +6,7 @@ set -euo pipefail
|
||||
. "$(dirname "$0")/_env.sh"
|
||||
|
||||
TAG="$1"
|
||||
VER="${TAG#v}"
|
||||
VER="${TAG#client-v}"
|
||||
|
||||
echo "==> compile-windows: version=${VER}"
|
||||
|
||||
@@ -41,7 +41,7 @@ flutter create --platforms=windows . --project-name jiu_client
|
||||
flutter build windows --release \
|
||||
"--dart-define=BASE_URL=https://jiu.51yanmei.com" \
|
||||
"--dart-define=PUBLIC_URL=https://jiu.51yanmei.com" \
|
||||
"--dart-define=APP_VERSION=${TAG}"
|
||||
"--dart-define=APP_VERSION=v${VER}"
|
||||
popd > /dev/null
|
||||
|
||||
# Package the Release folder into a Windows installer with Inno Setup (ISCC).
|
||||
|
||||
@@ -1,43 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
# compile.sh <tag> — build backend + Flutter web, package into dist/
|
||||
set -euo pipefail
|
||||
|
||||
# shellcheck source=scripts/ci/_env.sh
|
||||
. "$(dirname "$0")/_env.sh"
|
||||
|
||||
TAG="$1"
|
||||
VER="${TAG#v}"
|
||||
|
||||
echo "==> compile: version=$VER"
|
||||
|
||||
# Sync Flutter pubspec version
|
||||
sed -i '' "s/^version:.*/version: ${VER}+1/" client/pubspec.yaml
|
||||
|
||||
# Build Go backend (linux/amd64 for EC2)
|
||||
cd backend
|
||||
GOOS=linux GOARCH=amd64 CGO_ENABLED=0 go build -o jiu-server .
|
||||
cd ..
|
||||
|
||||
# Build Flutter Web
|
||||
cd client
|
||||
flutter build web --release \
|
||||
--base-href=/app/ \
|
||||
"--dart-define=BASE_URL=https://jiu.51yanmei.com" \
|
||||
"--dart-define=PUBLIC_URL=https://jiu.51yanmei.com" \
|
||||
"--dart-define=APP_VERSION=${TAG}"
|
||||
cd ..
|
||||
|
||||
# Build marketing site
|
||||
cd web
|
||||
npm ci --prefer-offline
|
||||
npm run build
|
||||
cd ..
|
||||
|
||||
# Package artifacts
|
||||
mkdir -p dist
|
||||
mv backend/jiu-server dist/jiu-server
|
||||
tar -czf dist/web.tar.gz -C client/build web
|
||||
tar -czf dist/marketing.tar.gz -C web/dist .
|
||||
|
||||
echo "==> compile: done — dist/ contents:"
|
||||
ls -lh dist/
|
||||
@@ -0,0 +1,66 @@
|
||||
#!/usr/bin/env bash
|
||||
# deploy-client.sh <tag> — deploy the Flutter web app, desktop/mobile installers,
|
||||
# and version.yaml to EC2. Does NOT restart the backend (version.yaml is read
|
||||
# per-request) nor touch nginx / the marketing site.
|
||||
set -euo pipefail
|
||||
|
||||
# shellcheck source=scripts/ci/lib-forgejo.sh
|
||||
. "$(dirname "$0")/lib-forgejo.sh"
|
||||
|
||||
TAG="$1"
|
||||
echo "==> deploy-client: tag=${TAG}"
|
||||
|
||||
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 EC2"
|
||||
${SCP} "$VERSION_YAML" "${EC2_USER}@${EC2_HOST}:/tmp/version.yaml"
|
||||
rsync -avz --delete -e "ssh -i ~/.ssh/ec2_deploy.pem -o StrictHostKeyChecking=no" \
|
||||
/tmp/jiu-web-new/ "${EC2_USER}@${EC2_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 "${EC2_USER}@${EC2_HOST}:/tmp/jiu-windows-x64-setup.exe" || true
|
||||
[ -f dist/jiu-macos-x64.zip ] && ${SCP} dist/jiu-macos-x64.zip "${EC2_USER}@${EC2_HOST}:/tmp/jiu-macos-x64.zip" || true
|
||||
[ -f dist/jiu-android.apk ] && ${SCP} dist/jiu-android.apk "${EC2_USER}@${EC2_HOST}:/tmp/jiu-android.apk" || true
|
||||
|
||||
${SSH} "${EC2_USER}@${EC2_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"
|
||||
@@ -0,0 +1,60 @@
|
||||
#!/usr/bin/env bash
|
||||
# deploy-server.sh <tag> — deploy the backend binary + nginx config to EC2.
|
||||
# Two modes: uses dist/ built in the same job, or downloads the release assets
|
||||
# by tag (manual rollback). Does NOT touch the web app, marketing site, or
|
||||
# version.yaml.
|
||||
set -euo pipefail
|
||||
|
||||
# shellcheck source=scripts/ci/lib-forgejo.sh
|
||||
. "$(dirname "$0")/lib-forgejo.sh"
|
||||
|
||||
TAG="$1"
|
||||
echo "==> deploy-server: tag=${TAG}"
|
||||
|
||||
if [ ! -f dist/jiu-server ] || [ ! -f dist/configs.tar.gz ]; then
|
||||
download_release_assets "$TAG"
|
||||
fi
|
||||
|
||||
echo "==> deploy-server: dist/ contents:"
|
||||
ls -lh dist/
|
||||
|
||||
rm -rf /tmp/jiu-configs
|
||||
mkdir -p /tmp/jiu-configs
|
||||
tar -xzf dist/configs.tar.gz -C /tmp/jiu-configs
|
||||
|
||||
setup_ssh
|
||||
echo "==> deploy-server: uploading files to EC2"
|
||||
${SCP} dist/jiu-server "${EC2_USER}@${EC2_HOST}:/tmp/jiu-server"
|
||||
${SCP} /tmp/jiu-configs/deploy/nginx-jiu.conf "${EC2_USER}@${EC2_HOST}:/tmp/nginx-jiu.conf"
|
||||
|
||||
${SSH} "${EC2_USER}@${EC2_HOST}" << 'ENDSSH'
|
||||
set -e
|
||||
|
||||
# Replace backend binary
|
||||
sudo systemctl stop jiu
|
||||
cp /tmp/jiu-server /opt/jiu/backend/jiu-server
|
||||
chmod +x /opt/jiu/backend/jiu-server
|
||||
|
||||
# Start and health check
|
||||
sudo systemctl start jiu
|
||||
echo "Waiting for health check..."
|
||||
for i in $(seq 1 30); do
|
||||
if curl -f http://localhost:8080/health > /dev/null 2>&1; then
|
||||
echo "Health check passed"
|
||||
break
|
||||
fi
|
||||
sleep 2
|
||||
done
|
||||
curl -f http://localhost:8080/health > /dev/null || { echo "Health check failed!"; exit 1; }
|
||||
|
||||
# Update jiu nginx config in the pangolin-edge reverse proxy (host-bind-mounted
|
||||
# conf.d; reload nginx inside the container).
|
||||
cp /tmp/nginx-jiu.conf /home/ec2-user/pangolin/edge/conf.d/jiu.conf
|
||||
docker exec pangolin-edge nginx -t && docker exec pangolin-edge nginx -s reload
|
||||
|
||||
echo "Server deploy complete!"
|
||||
ENDSSH
|
||||
|
||||
teardown_ssh
|
||||
rm -rf /tmp/jiu-configs
|
||||
echo "==> deploy-server: done"
|
||||
@@ -0,0 +1,38 @@
|
||||
#!/usr/bin/env bash
|
||||
# deploy-site.sh <tag> — deploy the Eleventy marketing site to EC2
|
||||
# (/opt/jiu/marketing). Does NOT restart the backend or touch nginx.
|
||||
set -euo pipefail
|
||||
|
||||
# shellcheck source=scripts/ci/lib-forgejo.sh
|
||||
. "$(dirname "$0")/lib-forgejo.sh"
|
||||
|
||||
TAG="$1"
|
||||
echo "==> deploy-site: tag=${TAG}"
|
||||
|
||||
if [ ! -f dist/marketing.tar.gz ]; then
|
||||
download_release_assets "$TAG"
|
||||
fi
|
||||
|
||||
echo "==> deploy-site: dist/ contents:"
|
||||
ls -lh dist/
|
||||
|
||||
rm -rf /tmp/jiu-marketing-new
|
||||
mkdir -p /tmp/jiu-marketing-new
|
||||
tar -xzf dist/marketing.tar.gz -C /tmp/jiu-marketing-new
|
||||
|
||||
setup_ssh
|
||||
echo "==> deploy-site: uploading marketing site to EC2"
|
||||
rsync -avz --delete -e "ssh -i ~/.ssh/ec2_deploy.pem -o StrictHostKeyChecking=no" \
|
||||
/tmp/jiu-marketing-new/ "${EC2_USER}@${EC2_HOST}:/tmp/jiu-marketing-new/"
|
||||
|
||||
${SSH} "${EC2_USER}@${EC2_HOST}" << 'ENDSSH'
|
||||
set -e
|
||||
mkdir -p /opt/jiu/marketing
|
||||
rsync -a --delete /tmp/jiu-marketing-new/ /opt/jiu/marketing/
|
||||
rm -rf /tmp/jiu-marketing-new
|
||||
echo "Site deploy complete!"
|
||||
ENDSSH
|
||||
|
||||
teardown_ssh
|
||||
rm -rf /tmp/jiu-marketing-new
|
||||
echo "==> deploy-site: done"
|
||||
@@ -1,157 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
# deploy.sh <tag> — deploy release to EC2
|
||||
# Works in two modes:
|
||||
# 1. Automated (after compile.sh): uses dist/ built in the same job
|
||||
# 2. Manual/rollback: downloads assets from Forgejo Release by tag
|
||||
set -euo pipefail
|
||||
|
||||
TAG="$1"
|
||||
|
||||
echo "==> deploy: tag=${TAG}"
|
||||
|
||||
# Download from Forgejo if dist/ was not built in this job
|
||||
if [ ! -f dist/jiu-server ] || [ ! -f dist/web.tar.gz ] || [ ! -f dist/configs.tar.gz ] || [ ! -f dist/marketing.tar.gz ]; then
|
||||
echo "==> deploy: dist/ incomplete — downloading assets for ${TAG} from Forgejo"
|
||||
mkdir -p dist
|
||||
|
||||
curl -kf \
|
||||
-H "Authorization: token ${FORGEJO_TOKEN}" \
|
||||
"${FORGEJO_URL}/api/v1/repos/${GITEA_REPOSITORY}/releases/tags/${TAG}" \
|
||||
-o /tmp/release-info.json
|
||||
|
||||
python3 - <<'PYEOF'
|
||||
import json, urllib.request, ssl, os, sys
|
||||
|
||||
ctx = ssl.create_default_context()
|
||||
ctx.check_hostname = False
|
||||
ctx.verify_mode = ssl.CERT_NONE
|
||||
|
||||
with open('/tmp/release-info.json') as f:
|
||||
release = json.load(f)
|
||||
|
||||
token = os.environ['FORGEJO_TOKEN']
|
||||
forgejo_url = os.environ['FORGEJO_URL']
|
||||
repo = os.environ['GITEA_REPOSITORY']
|
||||
release_id = release['id']
|
||||
|
||||
for asset in release.get('assets', []):
|
||||
url = f"{forgejo_url}/api/v1/repos/{repo}/releases/{release_id}/assets/{asset['id']}"
|
||||
req = urllib.request.Request(url, headers={'Authorization': f'token {token}'})
|
||||
with urllib.request.urlopen(req, context=ctx) as resp:
|
||||
with open(f"dist/{asset['name']}", 'wb') as out:
|
||||
out.write(resp.read())
|
||||
print(f"Downloaded: {asset['name']}")
|
||||
PYEOF
|
||||
fi
|
||||
|
||||
echo "==> deploy: dist/ contents:"
|
||||
ls -lh dist/
|
||||
|
||||
# Extract configs (nginx, version.yaml, etc.)
|
||||
rm -rf /tmp/jiu-configs
|
||||
mkdir -p /tmp/jiu-configs
|
||||
tar -xzf dist/configs.tar.gz -C /tmp/jiu-configs
|
||||
|
||||
# Extract Flutter web build
|
||||
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
|
||||
|
||||
# Extract marketing site
|
||||
rm -rf /tmp/jiu-marketing-new
|
||||
mkdir -p /tmp/jiu-marketing-new
|
||||
tar -xzf dist/marketing.tar.gz -C /tmp/jiu-marketing-new
|
||||
|
||||
# Setup SSH
|
||||
mkdir -p ~/.ssh
|
||||
printf '%s' "${EC2_SSH_KEY}" > ~/.ssh/ec2_deploy.pem
|
||||
chmod 600 ~/.ssh/ec2_deploy.pem
|
||||
ssh-keyscan -H "${EC2_HOST}" >> ~/.ssh/known_hosts
|
||||
|
||||
SSH="ssh -i ~/.ssh/ec2_deploy.pem -o StrictHostKeyChecking=no"
|
||||
SCP="scp -O -i ~/.ssh/ec2_deploy.pem"
|
||||
|
||||
echo "==> deploy: uploading files to EC2"
|
||||
|
||||
# Upload backend binary
|
||||
${SCP} dist/jiu-server "${EC2_USER}@${EC2_HOST}:/tmp/jiu-server"
|
||||
|
||||
# Upload version.yaml
|
||||
${SCP} /tmp/jiu-configs/backend/config/version.yaml "${EC2_USER}@${EC2_HOST}:/tmp/version.yaml"
|
||||
|
||||
# Upload nginx config
|
||||
${SCP} /tmp/jiu-configs/deploy/nginx-jiu.conf "${EC2_USER}@${EC2_HOST}:/tmp/nginx-jiu.conf"
|
||||
|
||||
# Upload Flutter web
|
||||
rsync -avz --delete -e "ssh -i ~/.ssh/ec2_deploy.pem -o StrictHostKeyChecking=no" \
|
||||
/tmp/jiu-web-new/ "${EC2_USER}@${EC2_HOST}:/tmp/jiu-web-new/"
|
||||
|
||||
# Upload marketing site (built by compile.sh)
|
||||
rsync -avz --delete -e "ssh -i ~/.ssh/ec2_deploy.pem -o StrictHostKeyChecking=no" \
|
||||
/tmp/jiu-marketing-new/ "${EC2_USER}@${EC2_HOST}:/tmp/jiu-marketing-new/"
|
||||
|
||||
# Upload desktop client 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 "${EC2_USER}@${EC2_HOST}:/tmp/jiu-windows-x64-setup.exe" || true
|
||||
[ -f dist/jiu-macos-x64.zip ] && ${SCP} dist/jiu-macos-x64.zip "${EC2_USER}@${EC2_HOST}:/tmp/jiu-macos-x64.zip" || true
|
||||
[ -f dist/jiu-android.apk ] && ${SCP} dist/jiu-android.apk "${EC2_USER}@${EC2_HOST}:/tmp/jiu-android.apk" || true
|
||||
|
||||
echo "==> deploy: running remote deploy"
|
||||
|
||||
${SSH} "${EC2_USER}@${EC2_HOST}" << 'ENDSSH'
|
||||
set -e
|
||||
|
||||
# Replace backend binary
|
||||
sudo systemctl stop jiu
|
||||
cp /tmp/jiu-server /opt/jiu/backend/jiu-server
|
||||
chmod +x /opt/jiu/backend/jiu-server
|
||||
|
||||
# Update version config(WorkingDirectory=/opt/jiu,读 config/version.yaml)
|
||||
mkdir -p /opt/jiu/config
|
||||
cp /tmp/version.yaml /opt/jiu/config/version.yaml
|
||||
|
||||
# Start and health check
|
||||
sudo systemctl start jiu
|
||||
echo "Waiting for health check..."
|
||||
for i in $(seq 1 30); do
|
||||
if curl -f http://localhost:8080/health > /dev/null 2>&1; then
|
||||
echo "Health check passed"
|
||||
break
|
||||
fi
|
||||
sleep 2
|
||||
done
|
||||
curl -f http://localhost:8080/health > /dev/null || { echo "Health check failed!"; exit 1; }
|
||||
|
||||
# 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
|
||||
|
||||
# Update marketing site
|
||||
mkdir -p /opt/jiu/marketing
|
||||
rsync -a --delete /tmp/jiu-marketing-new/ /opt/jiu/marketing/
|
||||
rm -rf /tmp/jiu-marketing-new
|
||||
|
||||
# Publish desktop client installers to the nginx-served downloads dir.
|
||||
# Keep only the latest version: clear old installers, then drop in the new ones.
|
||||
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
|
||||
|
||||
# Update jiu nginx config in the pangolin-edge reverse proxy.
|
||||
# nginx now runs inside the `pangolin-edge` container (host networking), not on
|
||||
# the host. Its /etc/nginx/conf.d is bind-mounted from the host dir below, so we
|
||||
# write the config there and reload nginx *inside the container*.
|
||||
cp /tmp/nginx-jiu.conf /home/ec2-user/pangolin/edge/conf.d/jiu.conf
|
||||
docker exec pangolin-edge nginx -t && docker exec pangolin-edge nginx -s reload
|
||||
|
||||
echo "Deploy complete!"
|
||||
ENDSSH
|
||||
|
||||
# Cleanup SSH key
|
||||
rm -f ~/.ssh/ec2_deploy.pem
|
||||
rm -rf /tmp/jiu-configs /tmp/jiu-web-new
|
||||
|
||||
echo "==> deploy: done"
|
||||
@@ -0,0 +1,121 @@
|
||||
#!/usr/bin/env bash
|
||||
# lib-forgejo.sh — shared CI helpers for the three release pipelines
|
||||
# (client / site / server). `source` this from release-*.sh and deploy-*.sh.
|
||||
#
|
||||
# Provides:
|
||||
# ver_from_tag <tag> -> strips client-v|site-v|server-v|v prefix
|
||||
# extract_release_notes <file> -> prints the latest "## [x]" section body
|
||||
# create_release <tag> <body> -> POSTs a Forgejo Release, sets RELEASE_ID
|
||||
# upload_asset <file> -> uploads one asset (needs RELEASE_ID)
|
||||
# download_release_assets <tag> -> downloads all assets of a release into dist/
|
||||
# setup_ssh / teardown_ssh -> prepare/clean the EC2 deploy key (sets SSH/SCP)
|
||||
#
|
||||
# Requires env (where relevant): FORGEJO_URL, FORGEJO_TOKEN, GITEA_REPOSITORY,
|
||||
# EC2_SSH_KEY, EC2_HOST, EC2_USER.
|
||||
|
||||
# Strip the part-specific tag prefix, leaving a bare semver (1.2.3).
|
||||
ver_from_tag() {
|
||||
local tag="$1"
|
||||
tag="${tag#client-v}"
|
||||
tag="${tag#site-v}"
|
||||
tag="${tag#server-v}"
|
||||
tag="${tag#v}"
|
||||
printf '%s' "$tag"
|
||||
}
|
||||
|
||||
# Print the body (lines) of the most recent "## [ver] - date" section.
|
||||
extract_release_notes() {
|
||||
python3 - "$1" <<'PYEOF'
|
||||
import re, sys
|
||||
fn = sys.argv[1]
|
||||
try:
|
||||
with open(fn, encoding='utf-8') as f:
|
||||
content = f.read()
|
||||
parts = re.split(r'\n## ', '\n' + content)
|
||||
if len(parts) > 1:
|
||||
lines = parts[1].strip().split('\n')
|
||||
notes = []
|
||||
for line in lines[1:]:
|
||||
s = line.strip()
|
||||
if s.startswith('## '):
|
||||
break
|
||||
if s:
|
||||
notes.append(s)
|
||||
print('\n'.join(notes) if notes else lines[0])
|
||||
else:
|
||||
print('')
|
||||
except Exception:
|
||||
print('')
|
||||
PYEOF
|
||||
}
|
||||
|
||||
# create_release <tag> <body_json_string> — sets global RELEASE_ID on success.
|
||||
create_release() {
|
||||
local tag="$1" body="$2" http_code resp
|
||||
echo "==> release: creating Forgejo Release ${tag}"
|
||||
http_code=$(curl -k -w "%{http_code}" -o /tmp/release_resp.json \
|
||||
-X POST "${FORGEJO_URL}/api/v1/repos/${GITEA_REPOSITORY}/releases" \
|
||||
-H "Authorization: token ${FORGEJO_TOKEN}" \
|
||||
-H "Content-Type: application/json" \
|
||||
-d "{\"tag_name\":\"${tag}\",\"name\":\"Release ${tag}\",\"body\":${body},\"draft\":false,\"prerelease\":false}")
|
||||
resp=$(cat /tmp/release_resp.json)
|
||||
echo "==> release: API response (HTTP ${http_code}): ${resp}"
|
||||
if [ "$http_code" -lt 200 ] || [ "$http_code" -ge 300 ]; then
|
||||
echo "==> release: FAILED — HTTP ${http_code}" >&2
|
||||
return 1
|
||||
fi
|
||||
RELEASE_ID=$(python3 -c "import sys,json; print(json.load(sys.stdin)['id'])" <<< "${resp}")
|
||||
echo "==> release: release_id=${RELEASE_ID}"
|
||||
}
|
||||
|
||||
# upload_asset <file> — requires RELEASE_ID.
|
||||
upload_asset() {
|
||||
local file="$1" code
|
||||
code=$(curl -k -w "%{http_code}" -o /tmp/upload_resp.json \
|
||||
-X POST "${FORGEJO_URL}/api/v1/repos/${GITEA_REPOSITORY}/releases/${RELEASE_ID}/assets" \
|
||||
-H "Authorization: token ${FORGEJO_TOKEN}" \
|
||||
-F "attachment=@${file}")
|
||||
echo "==> release: uploaded ${file} (HTTP ${code}): $(cat /tmp/upload_resp.json)"
|
||||
if [ "$code" -lt 200 ] || [ "$code" -ge 300 ]; then return 1; fi
|
||||
}
|
||||
|
||||
# download_release_assets <tag> — pull every asset of the release into dist/.
|
||||
download_release_assets() {
|
||||
local tag="$1"
|
||||
echo "==> deploy: downloading assets for ${tag} from Forgejo"
|
||||
mkdir -p dist
|
||||
curl -kf -H "Authorization: token ${FORGEJO_TOKEN}" \
|
||||
"${FORGEJO_URL}/api/v1/repos/${GITEA_REPOSITORY}/releases/tags/${tag}" \
|
||||
-o /tmp/release-info.json
|
||||
python3 - <<'PYEOF'
|
||||
import json, urllib.request, ssl, os
|
||||
ctx = ssl.create_default_context()
|
||||
ctx.check_hostname = False
|
||||
ctx.verify_mode = ssl.CERT_NONE
|
||||
rel = json.load(open('/tmp/release-info.json'))
|
||||
token = os.environ['FORGEJO_TOKEN']
|
||||
url = os.environ['FORGEJO_URL']
|
||||
repo = os.environ['GITEA_REPOSITORY']
|
||||
rid = rel['id']
|
||||
for a in rel.get('assets', []):
|
||||
u = f"{url}/api/v1/repos/{repo}/releases/{rid}/assets/{a['id']}"
|
||||
req = urllib.request.Request(u, headers={'Authorization': f'token {token}'})
|
||||
with urllib.request.urlopen(req, context=ctx) as r, open(f"dist/{a['name']}", 'wb') as o:
|
||||
o.write(r.read())
|
||||
print('Downloaded:', a['name'])
|
||||
PYEOF
|
||||
}
|
||||
|
||||
# setup_ssh — write the EC2 deploy key and export SSH / SCP commands.
|
||||
setup_ssh() {
|
||||
mkdir -p ~/.ssh
|
||||
printf '%s' "${EC2_SSH_KEY}" > ~/.ssh/ec2_deploy.pem
|
||||
chmod 600 ~/.ssh/ec2_deploy.pem
|
||||
ssh-keyscan -H "${EC2_HOST}" >> ~/.ssh/known_hosts 2>/dev/null
|
||||
SSH="ssh -i ~/.ssh/ec2_deploy.pem -o StrictHostKeyChecking=no"
|
||||
SCP="scp -O -i ~/.ssh/ec2_deploy.pem"
|
||||
}
|
||||
|
||||
teardown_ssh() {
|
||||
rm -f ~/.ssh/ec2_deploy.pem
|
||||
}
|
||||
@@ -0,0 +1,119 @@
|
||||
#!/usr/bin/env bash
|
||||
# release-client.sh <tag> — client pipeline release.
|
||||
# 1. Update backend/config/version.yaml: version / build_number / release_notes
|
||||
# / macos+windows+android download URLs / changelog[] (latest 3 from
|
||||
# CHANGELOG-client.md).
|
||||
# 2. Create the Forgejo Release client-vX and upload the app artifacts +
|
||||
# version.yaml (so manual rollback can re-fetch the exact manifest).
|
||||
#
|
||||
# version.yaml is client-owned: the backend reads it per-request, so deploying
|
||||
# it does NOT require a backend restart or a server-pipeline run.
|
||||
set -euo pipefail
|
||||
|
||||
# shellcheck source=scripts/ci/lib-forgejo.sh
|
||||
. "$(dirname "$0")/lib-forgejo.sh"
|
||||
|
||||
TAG="$1"
|
||||
VER="$(ver_from_tag "$TAG")"
|
||||
echo "==> release-client: tag=${TAG} version=${VER}"
|
||||
|
||||
NOTES=$(extract_release_notes CHANGELOG-client.md)
|
||||
echo "==> release-client: release_notes=${NOTES}"
|
||||
|
||||
# --- Update version.yaml (scalars + download URLs) and append changelog[] ---
|
||||
python3 - "$VER" "$NOTES" "CHANGELOG-client.md" <<'PYEOF'
|
||||
import sys, re, json
|
||||
|
||||
ver = sys.argv[1]
|
||||
notes = sys.argv[2]
|
||||
changelog_file = sys.argv[3]
|
||||
|
||||
base = "https://jiu.51yanmei.com/downloads"
|
||||
mac_url = f"{base}/jiu-macos-x64.zip"
|
||||
win_url = f"{base}/jiu-windows-x64-setup.exe"
|
||||
android_url = f"{base}/jiu-android.apk"
|
||||
|
||||
# Read current version.yaml, dropping any existing trailing `changelog:` block
|
||||
# (changelog is always emitted last, so everything from it to EOF is regenerated).
|
||||
with open('backend/config/version.yaml', encoding='utf-8') as f:
|
||||
raw = f.read()
|
||||
raw = re.split(r'\nchangelog:', raw, maxsplit=1)[0].rstrip('\n') + '\n'
|
||||
|
||||
out = []
|
||||
for line in raw.splitlines(keepends=True):
|
||||
if line.startswith('version:'):
|
||||
out.append('version: "%s"\n' % ver)
|
||||
elif line.startswith('build_number:'):
|
||||
try:
|
||||
b = int(line.split(':', 1)[1].strip()) + 1
|
||||
except Exception:
|
||||
b = 1
|
||||
out.append('build_number: %d\n' % b)
|
||||
elif line.startswith('release_notes:'):
|
||||
safe = notes.replace('\\', '\\\\').replace('"', '\\"').replace('\n', ';')
|
||||
out.append('release_notes: "%s"\n' % safe)
|
||||
elif line.startswith(' macos:'):
|
||||
out.append(' macos: "%s"\n' % mac_url)
|
||||
elif line.startswith(' windows:'):
|
||||
out.append(' windows: "%s"\n' % win_url)
|
||||
elif line.startswith(' android:'):
|
||||
out.append(' android: "%s"\n' % android_url)
|
||||
else:
|
||||
out.append(line)
|
||||
|
||||
# Parse CHANGELOG-client.md -> latest 3 entries (same shape as web/_data/changelog.js)
|
||||
versions = []
|
||||
cur = None
|
||||
sec = None
|
||||
for line in open(changelog_file, encoding='utf-8'):
|
||||
line = line.rstrip('\n')
|
||||
m = re.match(r'^## \[([^\]]+)\] - (\d{4}-\d{2}-\d{2})', line)
|
||||
if m:
|
||||
if cur:
|
||||
versions.append(cur)
|
||||
if len(versions) >= 3:
|
||||
cur = None
|
||||
break
|
||||
cur = {'version': m.group(1), 'date': m.group(2), 'intro': '', 'sections': []}
|
||||
sec = None
|
||||
continue
|
||||
ms = re.match(r'^### (.+)', line)
|
||||
if ms and cur is not None:
|
||||
sec = {'type': ms.group(1).strip(), 'items': []}
|
||||
cur['sections'].append(sec)
|
||||
continue
|
||||
mi = re.match(r'^- (.+)', line)
|
||||
if mi and cur is not None and sec is not None:
|
||||
sec['items'].append(mi.group(1).strip())
|
||||
continue
|
||||
if line.strip() and cur is not None and sec is None and not line.startswith('#'):
|
||||
cur['intro'] = (cur['intro'] + ' ' + line.strip()).strip()
|
||||
if cur is not None and len(versions) < 3:
|
||||
versions.append(cur)
|
||||
|
||||
# Append changelog as a JSON array (valid YAML flow style — no pyyaml needed).
|
||||
text = ''.join(out).rstrip('\n') + '\n'
|
||||
text += 'changelog: ' + json.dumps(versions, ensure_ascii=False) + '\n'
|
||||
with open('backend/config/version.yaml', 'w', encoding='utf-8') as f:
|
||||
f.write(text)
|
||||
print('version.yaml updated to', ver, '|', len(versions), 'changelog entries')
|
||||
PYEOF
|
||||
|
||||
# Stage version.yaml as a release asset so manual rollback can re-fetch it.
|
||||
mkdir -p dist
|
||||
cp backend/config/version.yaml dist/version.yaml
|
||||
|
||||
BODY=$(python3 - "$TAG" "$NOTES" <<'PYEOF'
|
||||
import sys, json
|
||||
print(json.dumps('## ' + sys.argv[1] + '\n\n' + sys.argv[2]))
|
||||
PYEOF
|
||||
)
|
||||
|
||||
create_release "$TAG" "$BODY"
|
||||
upload_asset dist/web.tar.gz
|
||||
upload_asset dist/version.yaml
|
||||
[ -f dist/jiu-macos-x64.zip ] && upload_asset dist/jiu-macos-x64.zip || true
|
||||
[ -f dist/jiu-windows-x64-setup.exe ] && upload_asset dist/jiu-windows-x64-setup.exe || true
|
||||
[ -f dist/jiu-android.apk ] && upload_asset dist/jiu-android.apk || true
|
||||
|
||||
echo "==> release-client: done — Release ${TAG} created"
|
||||
@@ -0,0 +1,25 @@
|
||||
#!/usr/bin/env bash
|
||||
# release-server.sh <tag> — create the Forgejo Release for the backend pipeline
|
||||
# and upload jiu-server + configs.tar.gz.
|
||||
set -euo pipefail
|
||||
|
||||
# shellcheck source=scripts/ci/lib-forgejo.sh
|
||||
. "$(dirname "$0")/lib-forgejo.sh"
|
||||
|
||||
TAG="$1"
|
||||
echo "==> release-server: tag=${TAG}"
|
||||
|
||||
NOTES=$(extract_release_notes CHANGELOG-server.md)
|
||||
echo "==> release-server: release_notes=${NOTES}"
|
||||
|
||||
BODY=$(python3 - "$TAG" "$NOTES" <<'PYEOF'
|
||||
import sys, json
|
||||
print(json.dumps('## ' + sys.argv[1] + '\n\n' + sys.argv[2]))
|
||||
PYEOF
|
||||
)
|
||||
|
||||
create_release "$TAG" "$BODY"
|
||||
upload_asset dist/jiu-server
|
||||
upload_asset dist/configs.tar.gz
|
||||
|
||||
echo "==> release-server: done — Release ${TAG} created"
|
||||
@@ -0,0 +1,24 @@
|
||||
#!/usr/bin/env bash
|
||||
# release-site.sh <tag> — create the Forgejo Release for the marketing-site
|
||||
# pipeline and upload marketing.tar.gz.
|
||||
set -euo pipefail
|
||||
|
||||
# shellcheck source=scripts/ci/lib-forgejo.sh
|
||||
. "$(dirname "$0")/lib-forgejo.sh"
|
||||
|
||||
TAG="$1"
|
||||
echo "==> release-site: tag=${TAG}"
|
||||
|
||||
NOTES=$(extract_release_notes CHANGELOG-site.md)
|
||||
echo "==> release-site: release_notes=${NOTES}"
|
||||
|
||||
BODY=$(python3 - "$TAG" "$NOTES" <<'PYEOF'
|
||||
import sys, json
|
||||
print(json.dumps('## ' + sys.argv[1] + '\n\n' + sys.argv[2]))
|
||||
PYEOF
|
||||
)
|
||||
|
||||
create_release "$TAG" "$BODY"
|
||||
upload_asset dist/marketing.tar.gz
|
||||
|
||||
echo "==> release-site: done — Release ${TAG} created"
|
||||
@@ -1,141 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
# release.sh <tag> — update version.yaml, package configs, create Forgejo Release
|
||||
set -euo pipefail
|
||||
|
||||
TAG="$1"
|
||||
VER="${TAG#v}"
|
||||
|
||||
echo "==> release: tag=${TAG} version=${VER}"
|
||||
|
||||
# Extract release notes from CHANGELOG.md (first summary line of the latest section)
|
||||
RELEASE_NOTES=$(python3 - <<'PYEOF'
|
||||
import re, sys
|
||||
try:
|
||||
with open('CHANGELOG.md') as f:
|
||||
content = f.read()
|
||||
parts = re.split(r'\n## ', '\n' + content)
|
||||
if len(parts) > 1:
|
||||
section = parts[1]
|
||||
lines = section.strip().split('\n')
|
||||
notes = []
|
||||
for line in lines[1:]:
|
||||
stripped = line.strip()
|
||||
# 只在遇到同级 ## 时停止,### 子标题保留
|
||||
if stripped.startswith('## '):
|
||||
break
|
||||
if stripped:
|
||||
notes.append(stripped)
|
||||
print('\n'.join(notes) if notes else lines[0])
|
||||
else:
|
||||
print('')
|
||||
except Exception as e:
|
||||
print('', file=sys.stderr)
|
||||
print('')
|
||||
PYEOF
|
||||
)
|
||||
|
||||
echo "==> release: release_notes=${RELEASE_NOTES}"
|
||||
|
||||
# Update backend/config/version.yaml (version, build_number, release_notes, macos/windows URL)
|
||||
python3 - "${VER}" "${RELEASE_NOTES}" "${TAG}" "${FORGEJO_URL}" "${GITEA_REPOSITORY}" <<'PYEOF'
|
||||
import sys
|
||||
ver = sys.argv[1]
|
||||
notes = sys.argv[2]
|
||||
tag = sys.argv[3]
|
||||
furl = sys.argv[4].rstrip('/')
|
||||
repo = sys.argv[5]
|
||||
# Public download URLs are served by jiu.51yanmei.com (same-origin HTTPS via the
|
||||
# pangolin nginx /downloads/ location), NOT the LAN-only HTTP Forgejo instance —
|
||||
# otherwise the HTTPS download page hands the browser an http://192.168.x URL and
|
||||
# Chrome blocks it as insecure / it's unreachable from the public internet.
|
||||
base = "https://jiu.51yanmei.com/downloads"
|
||||
mac_url = f"{base}/jiu-macos-x64.zip"
|
||||
win_url = f"{base}/jiu-windows-x64-setup.exe"
|
||||
android_url = f"{base}/jiu-android.apk"
|
||||
|
||||
lines = []
|
||||
with open('backend/config/version.yaml') as f:
|
||||
for line in f:
|
||||
if line.startswith('version:'):
|
||||
lines.append('version: "' + ver + '"\n')
|
||||
elif line.startswith('build_number:'):
|
||||
try:
|
||||
build = int(line.split(':', 1)[1].strip()) + 1
|
||||
except Exception:
|
||||
build = 1
|
||||
lines.append('build_number: ' + str(build) + '\n')
|
||||
elif line.startswith('release_notes:'):
|
||||
lines.append('release_notes: "' + notes.replace('\\', '\\\\').replace('"', '\\"') + '"\n')
|
||||
elif line.startswith(' macos:'):
|
||||
lines.append(' macos: "' + mac_url + '"\n')
|
||||
elif line.startswith(' windows:'):
|
||||
lines.append(' windows: "' + win_url + '"\n')
|
||||
elif line.startswith(' android:'):
|
||||
lines.append(' android: "' + android_url + '"\n')
|
||||
else:
|
||||
lines.append(line)
|
||||
with open('backend/config/version.yaml', 'w') as f:
|
||||
f.writelines(lines)
|
||||
print('version.yaml updated to', ver, '| macos:', mac_url, '| windows:', win_url, '| android:', android_url)
|
||||
PYEOF
|
||||
|
||||
# Package configs.tar.gz (includes updated version.yaml)
|
||||
tar -czf dist/configs.tar.gz \
|
||||
deploy/nginx-jiu.conf \
|
||||
deploy/jiu.service \
|
||||
deploy/production.env.template \
|
||||
deploy/setup-ec2.sh \
|
||||
deploy/docker-compose.yml \
|
||||
deploy/docker-compose.jiu.yml \
|
||||
backend/config/version.yaml
|
||||
|
||||
echo "==> release: creating Forgejo Release ${TAG}"
|
||||
|
||||
# Build release body from CHANGELOG excerpt
|
||||
BODY=$(python3 - "${TAG}" "${RELEASE_NOTES}" <<'PYEOF'
|
||||
import sys, json
|
||||
tag = sys.argv[1]
|
||||
notes = sys.argv[2]
|
||||
body = '## ' + tag + '\n\n' + notes
|
||||
print(json.dumps(body))
|
||||
PYEOF
|
||||
)
|
||||
|
||||
HTTP_CODE=$(curl -k -w "%{http_code}" -o /tmp/release_resp.json \
|
||||
-X POST "${FORGEJO_URL}/api/v1/repos/${GITEA_REPOSITORY}/releases" \
|
||||
-H "Authorization: token ${FORGEJO_TOKEN}" \
|
||||
-H "Content-Type: application/json" \
|
||||
-d "{\"tag_name\":\"${TAG}\",\"name\":\"Release ${TAG}\",\"body\":${BODY},\"draft\":false,\"prerelease\":false}")
|
||||
|
||||
RESP=$(cat /tmp/release_resp.json)
|
||||
echo "==> release: API response (HTTP ${HTTP_CODE}): ${RESP}"
|
||||
|
||||
if [ "$HTTP_CODE" -lt 200 ] || [ "$HTTP_CODE" -ge 300 ]; then
|
||||
echo "==> release: FAILED — HTTP ${HTTP_CODE}"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
RELEASE_ID=$(python3 -c "import sys,json; print(json.load(sys.stdin)['id'])" <<< "${RESP}")
|
||||
echo "==> release: release_id=${RELEASE_ID}"
|
||||
|
||||
# Upload assets
|
||||
upload_asset() {
|
||||
local file="$1"
|
||||
local code
|
||||
code=$(curl -k -w "%{http_code}" -o /tmp/upload_resp.json \
|
||||
-X POST "${FORGEJO_URL}/api/v1/repos/${GITEA_REPOSITORY}/releases/${RELEASE_ID}/assets" \
|
||||
-H "Authorization: token ${FORGEJO_TOKEN}" \
|
||||
-F "attachment=@${file}")
|
||||
echo "==> release: uploaded ${file} (HTTP ${code}): $(cat /tmp/upload_resp.json)"
|
||||
if [ "$code" -lt 200 ] || [ "$code" -ge 300 ]; then exit 1; fi
|
||||
}
|
||||
|
||||
upload_asset dist/jiu-server
|
||||
upload_asset dist/web.tar.gz
|
||||
upload_asset dist/marketing.tar.gz
|
||||
upload_asset dist/configs.tar.gz
|
||||
upload_asset dist/jiu-macos-x64.zip
|
||||
upload_asset dist/jiu-windows-x64-setup.exe
|
||||
upload_asset dist/jiu-android.apk
|
||||
|
||||
echo "==> release: done — Release ${TAG} created"
|
||||
+26
-9
@@ -1,5 +1,8 @@
|
||||
#!/usr/bin/env bash
|
||||
# test.sh — run backend and frontend checks
|
||||
# test.sh [part] — run gate checks for a pipeline part.
|
||||
# server -> go test
|
||||
# client -> flutter analyze
|
||||
# (none) -> both (backwards compatible)
|
||||
set -euo pipefail
|
||||
|
||||
export PATH="/opt/homebrew/bin:$PATH"
|
||||
@@ -7,14 +10,28 @@ export GOPROXY="${GOPROXY:-https://goproxy.cn,direct}"
|
||||
export PUB_HOSTED_URL="${PUB_HOSTED_URL:-https://pub.flutter-io.cn}"
|
||||
export FLUTTER_STORAGE_BASE_URL="${FLUTTER_STORAGE_BASE_URL:-https://storage.flutter-io.cn}"
|
||||
|
||||
echo "==> test: go test"
|
||||
cd backend
|
||||
go test ./...
|
||||
cd ..
|
||||
PART="${1:-all}"
|
||||
|
||||
echo "==> test: flutter analyze"
|
||||
cd client
|
||||
flutter analyze --no-fatal-infos --no-fatal-warnings
|
||||
cd ..
|
||||
run_server() {
|
||||
echo "==> test: go test"
|
||||
cd backend
|
||||
go test ./...
|
||||
cd ..
|
||||
}
|
||||
|
||||
run_client() {
|
||||
echo "==> test: flutter analyze"
|
||||
cd client
|
||||
flutter analyze --no-fatal-infos --no-fatal-warnings
|
||||
cd ..
|
||||
}
|
||||
|
||||
case "$PART" in
|
||||
server) run_server ;;
|
||||
client) run_client ;;
|
||||
site) echo "==> test: site has no test gate (build is the gate)" ;;
|
||||
all) run_server; run_client ;;
|
||||
*) echo "unknown part: $PART" >&2; exit 1 ;;
|
||||
esac
|
||||
|
||||
echo "==> test: done"
|
||||
|
||||
Reference in New Issue
Block a user