From 524a7932154884cfdd10572161330409eedf349d Mon Sep 17 00:00:00 2001 From: Naveen Singh Date: Fri, 23 Oct 2026 17:58:15 +0530 Subject: [PATCH] ci: setup abi splits in github releases --- .github/workflows/prepare-release-pr.yml | 2 ++ .github/workflows/release.yml | 1 + app/build.gradle.kts | 37 ++++++++++++++++++++++-- 3 files changed, 37 insertions(+), 3 deletions(-) diff --git a/.github/workflows/prepare-release-pr.yml b/.github/workflows/prepare-release-pr.yml index 0d0d605e..05397d70 100644 --- a/.github/workflows/prepare-release-pr.yml +++ b/.github/workflows/prepare-release-pr.yml @@ -12,4 +12,6 @@ on: jobs: call-release-pr: uses: FossifyOrg/.github/.github/workflows/prepare-release-pr.yml@main + with: + abi_apks: true secrets: inherit diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 949637a2..477ef603 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -11,6 +11,7 @@ jobs: name: Release uses: FossifyOrg/.github/.github/workflows/release.yml@main with: + abi_apks: true track: ${{ vars.GPLAY_TRACK || 'beta' }} rollout: ${{ vars.GPLAY_ROLLOUT || '0.05' }} validate_only: ${{ vars.GPLAY_DRY_RUN == 'true' }} diff --git a/app/build.gradle.kts b/app/build.gradle.kts index 13eecb80..a370cc25 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -1,3 +1,4 @@ +import com.android.build.api.variant.FilterConfiguration import java.io.FileInputStream import org.jetbrains.kotlin.gradle.dsl.JvmTarget import org.jetbrains.kotlin.gradle.tasks.KotlinCompile @@ -22,9 +23,12 @@ fun hasSigningVars(): Boolean { providers.environmentVariable("SIGNING_STORE_PASSWORD").orNull != null } +val baseVersionCode = project.property("VERSION_CODE").toString().toInt() +val abiCodes = mapOf("armeabi-v7a" to 1, "arm64-v8a" to 2, "x86" to 3, "x86_64" to 4) +val abiSplits = providers.gradleProperty("ABI_SPLITS").map(String::toBoolean).getOrElse(false) + base { - val versionCode = project.property("VERSION_CODE").toString().toInt() - archivesName = "documents-$versionCode" + archivesName = "documents-$baseVersionCode" } android { @@ -36,7 +40,7 @@ android { minSdk = project.libs.versions.app.build.minimumSDK.get().toInt() targetSdk = project.libs.versions.app.build.targetSDK.get().toInt() versionName = project.property("VERSION_NAME").toString() - versionCode = project.property("VERSION_CODE").toString().toInt() + versionCode = baseVersionCode } signingConfigs { @@ -93,6 +97,15 @@ android { register("gplay") } + splits { + abi { + isEnable = abiSplits + reset() + include(*abiCodes.keys.toTypedArray()) + isUniversalApk = true + } + } + compileOptions { val currentJavaVersionFromLibs = JavaVersion.valueOf(libs.versions.app.build.javaVersion.get()) sourceCompatibility = currentJavaVersionFromLibs @@ -128,6 +141,24 @@ android { } } +if (abiSplits) { + androidComponents { + onVariants(selector().withBuildType("release").withFlavor("variants" to "foss")) { variant -> + variant.outputs.forEach { output -> + val abi = output.filters.find { + it.filterType == FilterConfiguration.FilterType.ABI + }?.identifier + val versionCode = baseVersionCode + (abiCodes[abi] ?: 0) + val abiSuffix = abi?.let { "-$it" }.orEmpty() + val unsignedSuffix = + if (output.outputFileName.get().endsWith("-unsigned.apk")) "-unsigned" else "" + output.versionCode.set(versionCode) + output.outputFileName.set("documents-$versionCode-foss${abiSuffix}-release${unsignedSuffix}.apk") + } + } + } +} + detekt { config.setFrom("$rootDir/detekt.yml") buildUponDefaultConfig = true