Build Android APK #4
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: Build Android APK | |
| # 仅人工触发。本地与 CI 跑同一个 android/Dockerfile + run_build.sh:默认官方源(GH runner 海外直连最快), | |
| # 勾选 use_cn_mirror 才传 GD3_CN_MIRROR=1 用国内镜像(自托管/CN runner 才划算)。 | |
| # 配齐 keystore secret 则出签名 release APK,否则回退 debug。产物传 workflow artifact。 | |
| on: | |
| workflow_dispatch: | |
| inputs: | |
| use_cn_mirror: | |
| description: '用国内镜像源构建(自托管/CN runner 才需要;GH 海外 runner 留空更快)' | |
| type: boolean | |
| default: false | |
| permissions: | |
| contents: read | |
| jobs: | |
| build-android: | |
| runs-on: ubuntu-latest | |
| timeout-minutes: 90 | |
| env: | |
| GD3_CN_MIRROR: ${{ inputs.use_cn_mirror && '1' || '' }} | |
| GD3_KEYSTORE_PASS: ${{ secrets.ANDROID_KEYSTORE_PASSWORD }} | |
| GD3_KEY_ALIAS: ${{ secrets.ANDROID_KEY_ALIAS }} | |
| ANDROID_KEYSTORE_BASE64: ${{ secrets.ANDROID_KEYSTORE_BASE64 }} | |
| steps: | |
| - uses: actions/checkout@v4 | |
| # 构建需 ~12-15GB(镜像 5GB + NDK + .buildozer + gradle),清掉预装 SDK 腾出 ~20GB。 | |
| - name: Free disk space | |
| run: | | |
| sudo rm -rf /usr/share/dotnet /opt/ghc /usr/local/lib/android \ | |
| /usr/local/share/boost /usr/local/share/powershell /opt/hostedtoolcache/CodeQL \ | |
| "${AGENT_TOOLSDIRECTORY:-/opt/hostedtoolcache}" || true | |
| sudo docker image prune -af || true | |
| df -h / | |
| - name: Build APK (image + container) | |
| working-directory: android | |
| run: | | |
| if [ -n "$ANDROID_KEYSTORE_BASE64" ]; then | |
| echo "$ANDROID_KEYSTORE_BASE64" | base64 -d > "$RUNNER_TEMP/release.jks" | |
| export GD3_KEYSTORE="$RUNNER_TEMP/release.jks" | |
| echo "[ci] keystore 就绪,签名为 release" | |
| else | |
| echo "[ci] 无 keystore secret,出 debug APK" | |
| fi | |
| bash run_build.sh | |
| - name: Show APK info | |
| if: always() | |
| working-directory: android | |
| run: ls -la dist/ 2>/dev/null || echo "no dist/" | |
| - name: Upload APK | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: ghost-downloader-android | |
| path: android/dist/*.apk | |
| if-no-files-found: error | |
| retention-days: 14 |