#!/usr/bin/env bash # compile.sh — build backend + Flutter web, package into dist/ set -euo pipefail export PATH="/opt/homebrew/bin:$PATH" 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}" 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 .. # Package artifacts mkdir -p dist mv backend/jiu-server dist/jiu-server tar -czf dist/web.tar.gz -C client/build web echo "==> compile: done — dist/ contents:" ls -lh dist/