ci(global): add build_ios and build_android workflow #3
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Android Build Test | |
| on: | |
| push: | |
| branches: [main] | |
| pull_request: | |
| branches: [main] | |
| jobs: | |
| build-android: | |
| runs-on: ubuntu-latest | |
| timeout-minutes: 25 | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| - name: Set up Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: 20 | |
| cache: "pnpm" | |
| - name: Set up pnpm | |
| uses: pnpm/action-setup@v3 | |
| with: | |
| version: 9.14.4 | |
| - name: Install dependencies | |
| run: pnpm install --frozen-lockfile | |
| # ⚡️ 跳过 Expo 预编译(如果 android 文件夹已经存在) | |
| - name: Prebuild Android project | |
| run: pnpm expo prebuild --platform android --non-interactive --no-install | |
| env: | |
| EXPO_NO_DOCTOR: 1 | |
| # 🧠 缓存 Gradle 依赖(极大加速 Android 构建) | |
| - name: Cache Gradle | |
| uses: actions/cache@v3 | |
| with: | |
| path: | | |
| ~/.gradle/caches | |
| ~/.gradle/wrapper | |
| key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }} | |
| restore-keys: | | |
| ${{ runner.os }}-gradle- | |
| # ⚙️ 构建 Android Debug APK(最快) | |
| - name: Build Android Debug APK | |
| run: | | |
| cd android | |
| ./gradlew assembleDebug --no-daemon --parallel --build-cache --configure-on-demand | |
| env: | |
| CI: true | |
| - name: Notify on failure | |
| if: failure() | |
| run: echo "❌ Android build failed. Please check the logs above." |