diff --git a/.github/workflows/android-build.yml b/.github/workflows/android-build.yml index 7a437a25..57229d2a 100644 --- a/.github/workflows/android-build.yml +++ b/.github/workflows/android-build.yml @@ -3,21 +3,44 @@ 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 - permissions: - contents: write + 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 JDK 17 - uses: actions/setup-java@v4 + - name: Set up Amazon Corretto 21 + uses: actions/setup-java@v5 with: - java-version: '17' - distribution: 'temurin' - cache: gradle + 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 @@ -33,23 +56,72 @@ jobs: } > local.properties - name: Decode Keystore - run: echo "${{ secrets.RELEASE_KEYSTORE }}" | base64 --decode > app/release.keystore + env: + RELEASE_KEYSTORE: ${{ secrets.RELEASE_KEYSTORE }} + run: printf '%s' "$RELEASE_KEYSTORE" | base64 --decode > app/release.keystore - - name: Build Release APKs + - 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: | - ./gradlew assembleDefaultRelease assembleSamsungRelease assembleMeituRelease \ - -PRELEASE_STORE_FILE=release.keystore \ - -PRELEASE_STORE_PASSWORD=${{ secrets.RELEASE_STORE_PASSWORD }} \ - -PRELEASE_KEY_ALIAS=${{ secrets.RELEASE_KEY_ALIAS }} \ - -PRELEASE_KEY_PASSWORD=${{ secrets.RELEASE_KEY_PASSWORD }} + 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 - if: startsWith(github.ref, 'refs/tags/') with: + tag_name: ${{ github.event.release.tag_name }} + fail_on_unmatched_files: true files: | - app/build/outputs/apk/default/release/*.apk - app/build/outputs/apk/samsung/release/*.apk - app/build/outputs/apk/meitu/release/*.apk + release-apks/app-default-release.apk + release-apks/app-samsung-release.apk + release-apks/app-meitu-release.apk env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/app/build.gradle.kts b/app/build.gradle.kts index c6ee05fe..aa2b38d1 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -38,6 +38,8 @@ android { externalNativeBuild { cmake { arguments += "-DCMAKE_SHARED_LINKER_FLAGS=-Wl,-z,max-page-size=16384" + // Build the JNI library and its dependencies, excluding libjpeg tools/tests. + targets += "my-native-lib" } } @@ -84,6 +86,11 @@ android { } } + lint { + // Keep fatal lint analysis off the Release packaging path. + checkReleaseBuilds = false + } + flavorDimensions += "channel" productFlavors { create("dev") { @@ -204,10 +211,10 @@ dependencies { implementation("com.google.mediapipe:tasks-vision:1.0.0") // Bugly for default flavor - "defaultImplementation"("com.tencent.bugly:crashreport:latest.release") - "samsungImplementation"("com.tencent.bugly:crashreport:latest.release") - "meituImplementation"("com.tencent.bugly:crashreport:latest.release") - "devImplementation"("com.tencent.bugly:crashreport:latest.release") + "defaultImplementation"(libs.bugly.crashreport) + "samsungImplementation"(libs.bugly.crashreport) + "meituImplementation"(libs.bugly.crashreport) + "devImplementation"(libs.bugly.crashreport) // Billing for google flavor "googleImplementation"(libs.google.billing) diff --git a/app/src/main/cpp/CMakeLists.txt b/app/src/main/cpp/CMakeLists.txt index 745b1b88..8450ec45 100644 --- a/app/src/main/cpp/CMakeLists.txt +++ b/app/src/main/cpp/CMakeLists.txt @@ -42,7 +42,6 @@ configure_file( set_source_files_properties( "${MGC_DENOISE_ASM}" PROPERTIES - GENERATED TRUE OBJECT_DEPENDS "${MGC_DENOISE_CAPSULE}" ) @@ -77,7 +76,6 @@ configure_file( set_source_files_properties( "${MGC_DEMOIRE_ASM}" PROPERTIES - GENERATED TRUE OBJECT_DEPENDS "${MGC_DEMOIRE_CAPSULE}" ) @@ -112,7 +110,6 @@ configure_file( set_source_files_properties( "${MGC_SABRE_ASM}" PROPERTIES - GENERATED TRUE OBJECT_DEPENDS "${MGC_SABRE_CAPSULE}" ) @@ -151,10 +148,20 @@ configure_file( set_source_files_properties( "${MGC_SPATIAL_RGB_ASM}" PROPERTIES - GENERATED TRUE OBJECT_DEPENDS "${MGC_SPATIAL_RGB_CAPSULE}" ) +# These are configure-time outputs, so do not mark them GENERATED: Ninja clean +# would delete them without a build-time command to recreate them. Track them +# as configure dependencies so a missing output also causes CMake to regenerate it. +set_property( + DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS + "${MGC_DENOISE_ASM}" + "${MGC_DEMOIRE_ASM}" + "${MGC_SABRE_ASM}" + "${MGC_SPATIAL_RGB_ASM}" +) + # 4. 添加头文件路径 include_directories(${CMAKE_CURRENT_SOURCE_DIR}/LibRaw) include_directories(${CMAKE_CURRENT_SOURCE_DIR}/libjpeg-turbo/src) diff --git a/gradle.properties b/gradle.properties index 546891c8..72183eaa 100644 --- a/gradle.properties +++ b/gradle.properties @@ -6,8 +6,11 @@ # http://www.gradle.org/docs/current/userguide/build_environment.html # Specifies the JVM arguments used for the daemon process. # The setting is particularly useful for tweaking memory settings. -org.gradle.jvmargs=-Xmx4g -XX:MaxMetaspaceSize=1g -Dfile.encoding=UTF-8 +# Parallel GC improved clean Release/R8 throughput; see docs/build-performance.md. +org.gradle.jvmargs=-Xmx4g -XX:MaxMetaspaceSize=1g -XX:+UseParallelGC -Dfile.encoding=UTF-8 kotlin.daemon.jvmargs=-Xmx4g +# Reuse task outputs when returning to previously built inputs (including R8). +org.gradle.caching=true # When configured, Gradle will run in incubating parallel mode. # This option should only be used with decoupled projects. For more details, visit # https://developer.android.com/r/tools/gradle-multi-project-decoupled-projects @@ -21,4 +24,4 @@ kotlin.code.style=official # Enables namespacing of each library's R class so that its R class includes only the # resources declared in the library itself and none from the library's dependencies, # thereby reducing the size of the R class for that library -android.nonTransitiveRClass=true \ No newline at end of file +android.nonTransitiveRClass=true diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 80b72ac3..8fcfa477 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -1,5 +1,5 @@ [versions] -agp = "8.12.3" +agp = "8.13.2" kotlin = "2.3.0" coreKtx = "1.17.0" junit = "4.13.2" @@ -27,8 +27,10 @@ recyclerview = "1.4.0" splashscreen = "1.2.0" room = "2.7.2" ksp = "2.3.6" +bugly = "4.1.9.3" [libraries] +bugly-crashreport = { module = "com.tencent.bugly:crashreport", version.ref = "bugly" } androidx-recyclerview = { module = "androidx.recyclerview:recyclerview", version.ref = "recyclerview" } media3-exoplayer = { group = "androidx.media3", name = "media3-exoplayer", version.ref = "media3" } media3-ui = { group = "androidx.media3", name = "media3-ui", version.ref = "media3" }