|
| 1 | +name: Android CI |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: |
| 6 | + - master |
| 7 | + - main |
| 8 | + - "p/**" |
| 9 | + pull_request: |
| 10 | + branches: |
| 11 | + - master |
| 12 | + - main |
| 13 | + workflow_dispatch: |
| 14 | + inputs: |
| 15 | + branch: |
| 16 | + description: "Branch to build" |
| 17 | + required: true |
| 18 | + default: "master" |
| 19 | + type: string |
| 20 | + |
| 21 | +jobs: |
| 22 | + build: |
| 23 | + name: Build Debug |
| 24 | + runs-on: ubuntu-latest |
| 25 | + |
| 26 | + steps: |
| 27 | + - name: Checkout selected branch |
| 28 | + if: github.event_name == 'workflow_dispatch' |
| 29 | + uses: actions/checkout@v4 |
| 30 | + with: |
| 31 | + ref: ${{ inputs.branch }} |
| 32 | + submodules: recursive |
| 33 | + |
| 34 | + - name: Checkout |
| 35 | + if: github.event_name != 'workflow_dispatch' |
| 36 | + uses: actions/checkout@v4 |
| 37 | + with: |
| 38 | + submodules: recursive |
| 39 | + |
| 40 | + - name: Set up JDK |
| 41 | + uses: actions/setup-java@v4 |
| 42 | + with: |
| 43 | + distribution: temurin |
| 44 | + java-version: "17" |
| 45 | + |
| 46 | + - name: Set up Android SDK |
| 47 | + uses: android-actions/setup-android@v3 |
| 48 | + |
| 49 | + - name: Install Android NDK |
| 50 | + run: sdkmanager "ndk;27.0.12077973" |
| 51 | + |
| 52 | + - name: Set up Rust |
| 53 | + uses: dtolnay/rust-toolchain@stable |
| 54 | + with: |
| 55 | + targets: aarch64-linux-android |
| 56 | + |
| 57 | + - name: Install cargo-ndk |
| 58 | + run: cargo install cargo-ndk |
| 59 | + |
| 60 | + - name: Set Gradle permission |
| 61 | + run: chmod +x ./gradlew |
| 62 | + |
| 63 | + - name: Cache Gradle |
| 64 | + uses: gradle/actions/setup-gradle@v4 |
| 65 | + |
| 66 | + - name: Cache Cargo |
| 67 | + uses: Swatinem/rust-cache@v2 |
| 68 | + with: |
| 69 | + workspaces: | |
| 70 | + sdk |
| 71 | + GuiXu-Rust |
| 72 | +
|
| 73 | + - name: Build debug APK |
| 74 | + run: ./gradlew :app:assembleDebug --stacktrace |
| 75 | + |
| 76 | + - name: Upload debug APK |
| 77 | + uses: actions/upload-artifact@v4 |
| 78 | + with: |
| 79 | + name: AHUTong-debug-apk |
| 80 | + path: app/build/outputs/apk/debug/*.apk |
| 81 | + if-no-files-found: error |
0 commit comments