Skip to content

Commit ff29928

Browse files
committed
feature(cicd): create cross platform cicd
1 parent 23b2201 commit ff29928

2 files changed

Lines changed: 56 additions & 38 deletions

File tree

cross-platform/build.sh

Lines changed: 47 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,65 @@
11
#!/bin/bash
22
set -e
33

4-
# Cross-platform build script
4+
# =========================================
5+
# Cross-platform Flutter build script (macOS friendly)
6+
# =========================================
57
# Environment variables passed from workflow:
68
# - COMMIT_TAG: Short commit SHA (e.g., abc123)
79
# - ENV_TAG: Environment tag (prod/dev)
810
# - MOVING_TAG: Moving tag (latest/dev)
11+
# =========================================
912

10-
# Navigate to app directory
13+
echo "🏗️ Starting build process..."
1114
cd ../../app
1215

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 ---
1433
if ! command -v flutter &> /dev/null; then
34+
echo "🕊️ Installing Flutter..."
1535
git clone -q https://github.com/flutter/flutter.git -b stable /opt/flutter
1636
export PATH="$PATH:/opt/flutter/bin"
37+
else
38+
echo "🕊️ Flutter already installed."
1739
fi
1840

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
2444

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
2950

30-
# Build for Web
31-
flutter build web --release > /dev/null 2>&1
51+
echo "📱 Building Android APK..."
52+
flutter build apk --release
3253

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

cross-platform/deploy.sh

Lines changed: 9 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -47,26 +47,14 @@ else
4747
echo "⚠ Android APK not found"
4848
fi
4949

50-
# Upload Web build as artifact
51-
if [ -d "build/web" ]; then
52-
cd build/web
53-
zip -r "../../web-build-${RELEASE_TAG}.zip" . > /dev/null 2>&1
54-
cd ../..
55-
gh release upload "${RELEASE_TAG}" \
56-
"web-build-${RELEASE_TAG}.zip" \
57-
--repo "${OWNER_NAME}/${REPO_NAME}" \
58-
--clobber
59-
echo "✓ Web build uploaded"
50+
# --- Upload iOS IPA ---
51+
IPA_PATH="build/ios/ipa/app-release.ipa"
52+
if [ -f "$IPA_PATH" ]; then
53+
echo "🍎 Uploading iOS IPA..."
54+
gh release upload "${RELEASE_TAG}" "$IPA_PATH" \
55+
--repo "${OWNER_NAME}/${REPO_NAME}" --clobber
56+
echo "✅ iOS IPA uploaded."
6057
else
61-
echo "⚠ Web build not found"
58+
echo "⚠️ iOS IPA not found at $IPA_PATH"
59+
echo "💡 Make sure you ran: flutter build ipa --release --no-codesign"
6260
fi
63-
64-
echo "Deployment to GitHub Releases completed!"
65-
fi
66-
67-
# Example: Upload to Azure Blob Storage
68-
# az storage blob upload-batch \
69-
# --account-name ${AZURE_STORAGE_ACCOUNT} \
70-
# --destination ${AZURE_CONTAINER} \
71-
# --source build/web \
72-
# --overwrite

0 commit comments

Comments
 (0)