Build Release APK #248
Workflow file for this run
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 Release APK | |
| on: | |
| workflow_dispatch: | |
| push: | |
| tags: | |
| - "v*.*.*" | |
| paths-ignore: | |
| - "README.md" | |
| - "wiki/**" | |
| - "public/**" | |
| - "scripts/**" | |
| - ".vscode" | |
| - ".idea" | |
| - "e2e/**" | |
| pull_request: | |
| branches: | |
| - master | |
| - main | |
| paths-ignore: | |
| - "README.md" | |
| - "wiki/**" | |
| - "public/**" | |
| - ".scripts/**" | |
| - ".vscode" | |
| - ".idea" | |
| - "e2e/**" | |
| jobs: | |
| build: | |
| name: Build release APK | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v5 | |
| - uses: pnpm/action-setup@v4 | |
| with: | |
| version: 10 | |
| - uses: actions/setup-node@v6 | |
| with: | |
| node-version: 22.x | |
| cache: pnpm | |
| - name: Set Up JDK | |
| uses: actions/setup-java@v5 | |
| with: | |
| distribution: "zulu" # See 'Supported distributions' for available options | |
| java-version: "17" | |
| - name: Setup Gradle # fix `incompatible version of Kotlin. The binary version of its metadata is 1.9.0, expected version is 1.7.1.` or `Task :react-native-gesture-handler:generateReleaseBuildConfig: This version (1.3.2) of the Compose Compiler requires Kotlin version 1.7.20 but you appear to be using Kotlin version 1.9.25 which is not known to be compatible. Please fix your configuration` | |
| uses: gradle/actions/setup-gradle@v4 | |
| with: | |
| gradle-version: 8.10.2 # use the gradle version I saw on eas build's console, which might match the kotlin version?. Create an EAS build, and look at its "Run gradlew" step for text like `Welcome to Gradle 8.10.2!` | |
| - name: Set Build Tools Version | |
| run: | | |
| echo "BUILD_TOOLS_VERSION=$(ls /usr/local/lib/android/sdk/build-tools/ | sort -V | tail -n 1)" >> $GITHUB_ENV | |
| - name: Get pnpm store directory | |
| shell: bash | |
| run: | | |
| echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV | |
| - uses: actions/cache@v5 | |
| name: Setup pnpm cache | |
| with: | |
| path: ${{ env.STORE_PATH }} | |
| key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }} | |
| restore-keys: | | |
| ${{ runner.os }}-pnpm-store- | |
| - name: Install dependencies | |
| run: pnpm install | |
| - name: Type check and lint | |
| run: | | |
| pnpm run check | |
| pnpm run lint | |
| ## configure cash for gradle : will help to reduce build time | |
| - uses: actions/cache@v5 | |
| name: Cache Gradle Wrapper and Dependencies | |
| with: | |
| path: | | |
| ~/.gradle/caches | |
| ~/.gradle/wrapper | |
| key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }} | |
| restore-keys: | | |
| ${{ runner.os }}-gradle- | |
| - name: Build tw plugins & scripts | |
| run: | | |
| pnpm run build:plugin | |
| pnpm run build:tw-assets | |
| - name: Build by eject eas and not remove debug signing key for apk | |
| run: pnpm exec expo prebuild -p android --clean | |
| - name: Save AndroidManifest (release prebuild) | |
| run: | | |
| mkdir -p /tmp/apk-artifacts | |
| cp android/app/src/main/AndroidManifest.xml /tmp/apk-artifacts/AndroidManifest-release.xml | |
| # Don't need this, because we already remove expo-application that blocks f-droid https://github.com/tiddly-gittly/TidGi-Mobile/issues/6 | |
| # - name: Remove prorietary bits (for fix f-droid) | |
| # run: npx zx scripts/fit-f-droid.mjs | |
| - name: Build APK | |
| run: | | |
| cd android | |
| ./gradlew clean | |
| ./gradlew assembleRelease --no-daemon --warning-mode all | |
| ## sign generated apk | |
| - name: Sign APK | |
| uses: r0adkll/sign-android-release@v1 | |
| if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository | |
| with: | |
| releaseDirectory: android/app/build/outputs/apk/release | |
| signingKeyBase64: ${{ secrets.ANDROID_SIGNING_KEY }} | |
| alias: ${{ secrets.ANDROID_ALIAS }} | |
| keyStorePassword: ${{ secrets.ANDROID_KEY_STORE_PASSWORD }} | |
| keyPassword: ${{ secrets.ANDROID_KEY_PASSWORD }} | |
| env: | |
| BUILD_TOOLS_VERSION: ${{ env.BUILD_TOOLS_VERSION }} | |
| - name: Upload release APK artifact | |
| uses: actions/upload-artifact@v5 | |
| with: | |
| name: release-apk-${{ github.run_number }}-${{ github.sha }} | |
| path: | | |
| android/app/build/outputs/apk/release/app-release-signed.apk | |
| android/app/build/outputs/apk/release/app-release.apk | |
| /tmp/apk-artifacts/AndroidManifest-release.xml | |
| if-no-files-found: ignore | |
| - name: Create Release (release APK) | |
| uses: softprops/action-gh-release@v1 | |
| if: startsWith(github.ref, 'refs/tags/') | |
| with: | |
| draft: true | |
| generate_release_notes: true | |
| files: | | |
| android/app/build/outputs/apk/release/app-release-signed.apk | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |