Files
jiu/scripts/ci/compile-backend.sh
T
wangjia 54451f0e52 feat(deploy): gencode 纳入 server 发版产物 + EC2 生码封装
server 流水线编译并发布 jiu-gencode 二进制(回滚路径随 release 资产
自动下载),部署到 /opt/jiu/backend/,对旧版回滚做存在性判断优雅跳过。
新增 deploy/jiu-gencode.sh 封装自动读 production.env,线上生码从此
一条 ssh 即可,无需本地交叉编译 + scp。

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Y2Wdwo7SmgBJU37cBrkhPK
2026-06-19 14:04:14 +08:00

38 lines
1.2 KiB
Bash

#!/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 .
# Platform code-minting CLI (gencode) ships alongside the server so codes can be
# minted on EC2 without cross-compiling/scp each time.
GOOS=linux GOARCH=amd64 CGO_ENABLED=0 go build -o jiu-gencode ./cmd/gencode
cd ..
mkdir -p dist
mv backend/jiu-server dist/jiu-server
mv backend/jiu-gencode dist/jiu-gencode
# 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 \
deploy/jiu-gencode.sh
echo "==> compile-backend: done — dist/ contents:"
ls -lh dist/