|
1 | 1 | #!/bin/bash |
2 | 2 | set -e |
3 | 3 |
|
4 | | -# Cross-platform build script |
| 4 | +# ========================================= |
| 5 | +# Cross-platform Flutter build script (macOS friendly) |
| 6 | +# ========================================= |
5 | 7 | # Environment variables passed from workflow: |
6 | 8 | # - COMMIT_TAG: Short commit SHA (e.g., abc123) |
7 | 9 | # - ENV_TAG: Environment tag (prod/dev) |
8 | 10 | # - MOVING_TAG: Moving tag (latest/dev) |
| 11 | +# ========================================= |
9 | 12 |
|
10 | | -# Navigate to app directory |
| 13 | +echo "🏗️ Starting build process..." |
11 | 14 | cd ../../app |
12 | 15 |
|
13 | | -# Install Flutter if not present |
| 16 | +# --- Ensure Homebrew is available --- |
| 17 | +if ! command -v brew &> /dev/null; then |
| 18 | + echo "🍺 Homebrew not found. Installing..." |
| 19 | + /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" |
| 20 | + echo 'eval "$(/opt/homebrew/bin/brew shellenv)"' >> ~/.zprofile |
| 21 | + eval "$(/opt/homebrew/bin/brew shellenv)" |
| 22 | +fi |
| 23 | + |
| 24 | +# --- Ensure Node.js & npm --- |
| 25 | +if ! command -v npm &> /dev/null; then |
| 26 | + echo "📦 Installing Node.js..." |
| 27 | + brew install node |
| 28 | +else |
| 29 | + echo "📦 Node.js already installed." |
| 30 | +fi |
| 31 | + |
| 32 | +# --- Ensure Flutter --- |
14 | 33 | if ! command -v flutter &> /dev/null; then |
| 34 | + echo "🕊️ Installing Flutter..." |
15 | 35 | git clone -q https://github.com/flutter/flutter.git -b stable /opt/flutter |
16 | 36 | export PATH="$PATH:/opt/flutter/bin" |
| 37 | +else |
| 38 | + echo "🕊️ Flutter already installed." |
17 | 39 | fi |
18 | 40 |
|
19 | | -# Get Flutter dependencies |
20 | | -flutter pub get > /dev/null 2>&1 |
21 | | - |
22 | | -# Build for Android (APK) |
23 | | -flutter build apk --release > /dev/null 2>&1 |
| 41 | +# --- Run API update script (requires npm setup) --- |
| 42 | +echo "🔧 Running Dart API updater..." |
| 43 | +dart run ./tools/update_api.dart |
24 | 44 |
|
25 | | -# Build for iOS (if on macOS - will skip on Linux runners) |
26 | | -# if [[ "$OSTYPE" == "darwin"* ]]; then |
27 | | -# flutter build ios --release --no-codesign > /dev/null 2>&1 |
28 | | -# fi |
| 45 | +# --- Flutter build steps --- |
| 46 | +cd lam7a |
| 47 | +echo "📦 Fetching dependencies..." |
| 48 | +flutter pub get |
| 49 | +flutter pub run build_runner build --delete-conflicting-outputs |
29 | 50 |
|
30 | | -# Build for Web |
31 | | -flutter build web --release > /dev/null 2>&1 |
| 51 | +echo "📱 Building Android APK..." |
| 52 | +flutter build apk --release |
32 | 53 |
|
33 | | -echo "Build completed successfully!" |
34 | | -echo "Android APK: build/app/outputs/flutter-apk/app-release.apk" |
35 | | -echo "Web build: build/web/" |
| 54 | +# --- macOS-specific: build iOS if available --- |
| 55 | +if [[ "$OSTYPE" == "darwin"* ]]; then |
| 56 | + echo "🍎 Building iOS app..." |
| 57 | + |
| 58 | + # Build the iOS app (no code signing, suitable for CI) |
| 59 | + flutter build ipa --release --no-codesign |
| 60 | + |
| 61 | + # The .ipa file will be located under: |
| 62 | + # build/ios/ipa/ |
| 63 | + echo "✅ iOS IPA built successfully!" |
| 64 | + echo "📦 Path: build/ios/ipa/app-release.ipa" |
| 65 | +fi |
0 commit comments