#!/usr/bin/env bash # compile-macos.sh — build Flutter macOS desktop, package into dist/ set -euo pipefail 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-macos: version=${VER}" # Sync Flutter pubspec version (BSD sed on macOS) sed -i '' "s/^version:.*/version: ${VER}+1/" client/pubspec.yaml # Build Flutter macOS 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}" cd .. # Package .app bundle into zip mkdir -p dist python3 - <<'PYEOF' import zipfile, os src = os.path.join('client', 'build', 'macos', 'Build', 'Products', 'Release', 'jiu.app') dst = os.path.join('dist', 'jiu-macos-x64.zip') with zipfile.ZipFile(dst, 'w', zipfile.ZIP_DEFLATED) as zf: for root, dirs, files in os.walk(src): for fname in files: fp = os.path.join(root, fname) zf.write(fp, os.path.join('jiu.app', os.path.relpath(fp, src))) size = os.path.getsize(dst) print(f'Packaged {dst} ({size // 1024 // 1024} MB)') PYEOF echo "==> compile-macos: done — dist/ contents:" ls -lh dist/