|
| 1 | +on: |
| 2 | + workflow_call: |
| 3 | + |
| 4 | +jobs: |
| 5 | + build-android: |
| 6 | + if: ${{ github.event.inputs.upload_to_app_store != 'true' }} |
| 7 | + runs-on: ubuntu-latest |
| 8 | + |
| 9 | + steps: |
| 10 | + - name: Checkout |
| 11 | + uses: actions/checkout@v4 |
| 12 | + |
| 13 | + - name: Set up JDK |
| 14 | + uses: actions/setup-java@v4 |
| 15 | + with: |
| 16 | + distribution: "temurin" |
| 17 | + java-version: "17" |
| 18 | + |
| 19 | + - name: Accept Android SDK licenses |
| 20 | + run: yes | sudo "${ANDROID_HOME}/cmdline-tools/latest/bin/sdkmanager" --licenses |
| 21 | + |
| 22 | + - name: Install NDK 29 |
| 23 | + run: | |
| 24 | + yes | sudo "${ANDROID_HOME}/cmdline-tools/latest/bin/sdkmanager" --install "ndk;29.0.13846066" |
| 25 | +
|
| 26 | + - name: Force Gradle to use NDK 29 (absolute override) |
| 27 | + run: | |
| 28 | + echo "ndk.dir=${ANDROID_HOME}/ndk/29.0.13846066" >> android/local.properties |
| 29 | + echo "ndkVersion=29.0.13846066" >> android/local.properties |
| 30 | +
|
| 31 | + - name: Set up Flutter |
| 32 | + uses: subosito/flutter-action@v2 |
| 33 | + with: |
| 34 | + flutter-version: "3.35.2" |
| 35 | + channel: "stable" |
| 36 | + architecture: "x64" |
| 37 | + cache: false |
| 38 | + |
| 39 | + - name: Verify Flutter version |
| 40 | + run: | |
| 41 | + flutter --version |
| 42 | + dart --version |
| 43 | + flutter doctor --verbose |
| 44 | +
|
| 45 | + - name: Get dependencies |
| 46 | + run: flutter pub get |
| 47 | + |
| 48 | + - name: Get app version |
| 49 | + id: get_version |
| 50 | + uses: ./.github/actions/get-version |
| 51 | + |
| 52 | + - name: Clean Flutter & Gradle caches |
| 53 | + run: | |
| 54 | + flutter clean |
| 55 | + rm -rf ~/.gradle |
| 56 | + rm -rf android/.gradle |
| 57 | +
|
| 58 | + - name: Download Android Framework |
| 59 | + env: |
| 60 | + GITHUB_TOKEN: ${{ secrets.DXCORE_PRIVATE_ACCESS_TOKEN }} |
| 61 | + run: | |
| 62 | + mkdir -p android/app/libs |
| 63 | + curl -s -H "Authorization: token $GITHUB_TOKEN" \ |
| 64 | + https://api.github.com/repos/UnboundTechCo/DXcore-private/releases/latest | tee api.json |
| 65 | +
|
| 66 | + ASSET_ID=$(curl -s -H "Authorization: token $GITHUB_TOKEN" \ |
| 67 | + https://api.github.com/repos/UnboundTechCo/DXcore-private/releases/latest \ |
| 68 | + | jq -r '.assets[] | select(.name == "DXcore-android.zip") | .id') |
| 69 | + echo "Asset ID: $ASSET_ID" |
| 70 | + curl -L \ |
| 71 | + -H "Authorization: token $GITHUB_TOKEN" \ |
| 72 | + -H "Accept: application/octet-stream" \ |
| 73 | + "https://api.github.com/repos/UnboundTechCo/DXcore-private/releases/assets/$ASSET_ID" \ |
| 74 | + -o android/app/libs/DXcore-android.zip |
| 75 | + cd android/app/libs |
| 76 | + unzip -o DXcore-android.zip |
| 77 | + mv build/android/* . |
| 78 | + rm DXcore-android.zip |
| 79 | +
|
| 80 | + - name: Generate .env |
| 81 | + uses: ./.github/actions/create-env |
| 82 | + with: |
| 83 | + secret_blob: ${{ toJson(secrets) }} |
| 84 | + var_blob: ${{ toJson(vars) }} |
| 85 | + |
| 86 | + - name: Create key.properties for Android signing |
| 87 | + run: | |
| 88 | + echo "storePassword=${{ secrets.STORE_PASSWORD }}" > android/key.properties |
| 89 | + echo "keyPassword=${{ secrets.KEY_PASSWORD }}" >> android/key.properties |
| 90 | + echo "keyAlias=${{ secrets.KEY_ALIAS }}" >> android/key.properties |
| 91 | + echo "storeFile=keystore.jks" >> android/key.properties |
| 92 | +
|
| 93 | + - name: Decode and save Android keystore |
| 94 | + env: |
| 95 | + KEYSTORE_BASE64: ${{ secrets.KEYSTORE_BASE64 }} |
| 96 | + run: echo "$KEYSTORE_BASE64" | base64 -d > android/app/keystore.jks |
| 97 | + |
| 98 | + - name: Build APK & Bundle |
| 99 | + run: | |
| 100 | + chmod +x scripts/build_release.sh |
| 101 | + bash scripts/build_release.sh <<EOF |
| 102 | + 2 |
| 103 | + 4 |
| 104 | + 4 |
| 105 | + EOF |
| 106 | +
|
| 107 | + - name: Upload artifact |
| 108 | + uses: actions/upload-artifact@v4 |
| 109 | + with: |
| 110 | + name: android-release |
| 111 | + path: | |
| 112 | + build/app/outputs/flutter-apk/*.apk |
| 113 | + build/app/outputs/bundle/release/app-release.aab |
0 commit comments