name: Android Release Build on: release: types: [published] workflow_dispatch: inputs: cold_build: description: Build without restoring Gradle caches or reusing task outputs type: boolean default: true permissions: contents: read jobs: build: name: Build ${{ matrix.channel }} release runs-on: ubuntu-latest strategy: fail-fast: false max-parallel: 3 matrix: include: - channel: default variant: Default - channel: samsung variant: Samsung - channel: meitu variant: Meitu steps: - uses: actions/checkout@v4 - name: Set up Amazon Corretto 21 uses: actions/setup-java@v5 with: java-version: '21' distribution: 'corretto' - name: Set up Gradle uses: gradle/actions/setup-gradle@v5 with: cache-disabled: ${{ github.event_name == 'workflow_dispatch' && inputs.cold_build }} - name: Grant execute permission for gradlew run: chmod +x gradlew - name: Create local.properties env: BUILT_IN_API_KEY: ${{ secrets.BUILT_IN_API_KEY }} BUILT_IN_API_KEY_GOOGLE: ${{ secrets.BUILT_IN_API_KEY_GOOGLE }} run: | { printf 'BUILT_IN_API_KEY=%s\n' "$BUILT_IN_API_KEY" printf 'BUILT_IN_API_KEY_GOOGLE=%s\n' "$BUILT_IN_API_KEY_GOOGLE" } > local.properties - name: Decode Keystore env: RELEASE_KEYSTORE: ${{ secrets.RELEASE_KEYSTORE }} run: printf '%s' "$RELEASE_KEYSTORE" | base64 --decode > app/release.keystore - name: Build release APK env: BUILD_VARIANT: ${{ matrix.variant }} COLD_BUILD: ${{ github.event_name == 'workflow_dispatch' && inputs.cold_build }} ORG_GRADLE_PROJECT_RELEASE_STORE_FILE: release.keystore ORG_GRADLE_PROJECT_RELEASE_STORE_PASSWORD: ${{ secrets.RELEASE_STORE_PASSWORD }} ORG_GRADLE_PROJECT_RELEASE_KEY_ALIAS: ${{ secrets.RELEASE_KEY_ALIAS }} ORG_GRADLE_PROJECT_RELEASE_KEY_PASSWORD: ${{ secrets.RELEASE_KEY_PASSWORD }} run: | build_cache_option=--build-cache if [[ "$COLD_BUILD" == true ]]; then build_cache_option=--no-build-cache fi ./gradlew ":app:assemble${BUILD_VARIANT}Release" "$build_cache_option" \ --console=plain --profile \ -Dcom.android.tools.r8.printtimes=true \ -Pkotlin.build.report.output=file \ -Pkotlin.build.report.include_compiler_arguments=false - name: Save build performance reports if: always() uses: actions/upload-artifact@v4 with: name: build-reports-${{ matrix.channel }} path: | build/reports/profile/ build/reports/kotlin-build/ app/build/reports/kotlin-build/ retention-days: 7 - name: Save release APK uses: actions/upload-artifact@v4 with: name: release-apk-${{ matrix.channel }} path: app/build/outputs/apk/${{ matrix.channel }}/release/*.apk if-no-files-found: error compression-level: 0 retention-days: 7 publish: name: Publish all release APKs needs: build if: github.event_name == 'release' && startsWith(github.ref, 'refs/tags/') runs-on: ubuntu-latest permissions: contents: write steps: - name: Download release APKs uses: actions/download-artifact@v4 with: pattern: release-apk-* path: release-apks merge-multiple: true - name: Upload Release APKs to GitHub Release uses: softprops/action-gh-release@v2 with: tag_name: ${{ github.event.release.tag_name }} fail_on_unmatched_files: true files: | release-apks/app-default-release.apk release-apks/app-samsung-release.apk release-apks/app-meitu-release.apk env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}