From 414372d176ef978bda2f90c8f31f5f68ba4d5ee1 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 0d0d605ef..05397d70e 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 949637a27..477ef603a 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 a17dbb08b..5d297dc80 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -1,3 +1,4 @@ +import com.android.build.api.variant.FilterConfiguration import org.jetbrains.kotlin.gradle.dsl.JvmTarget import org.jetbrains.kotlin.gradle.tasks.KotlinCompile import org.jetbrains.kotlin.konan.properties.Properties @@ -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 = "keyboard-$versionCode" + archivesName = "keyboard-$baseVersionCode" } android { @@ -35,7 +39,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 multiDexEnabled = true vectorDrawables.useSupportLibrary = true ksp { @@ -91,6 +95,15 @@ android { register("gplay") } + splits { + abi { + isEnable = abiSplits + reset() + include(*abiCodes.keys.toTypedArray()) + isUniversalApk = true + } + } + sourceSets { getByName("main").java.directories.add("src/main/kotlin") } @@ -133,6 +146,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("keyboard-$versionCode-foss${abiSuffix}-release${unsignedSuffix}.apk") + } + } + } +} + detekt { baseline = file("detekt-baseline.xml") config.setFrom("$rootDir/detekt.yml")