diff --git a/buildSrc/src/main/kotlin/custom/Auth.kt b/buildSrc/src/main/kotlin/custom/Auth.kt index a37ab81c1..dc4b35931 100644 --- a/buildSrc/src/main/kotlin/custom/Auth.kt +++ b/buildSrc/src/main/kotlin/custom/Auth.kt @@ -82,13 +82,13 @@ class Transaction( FileContent("application/octet-stream", file) ).execute().prettyPrint() - fun attachExpansionTo(expansionCode: Int, versionCode: Int): ExpansionFile = + fun attachExpansionTo(versionCode: Int): ExpansionFile = publisher.edits().expansionfiles().update( packageName, editId, versionCode, "main", - ExpansionFile().apply { referencesVersion = expansionCode } + ExpansionFile().apply { referencesVersion = versionCode } ).execute().prettyPrint() fun uploadBundle(outputFile: File) { @@ -99,12 +99,12 @@ class Transaction( ).execute().prettyPrint() } - fun addToTrackInDraft(apkVariants: List): Track = + fun addToTrackInDraft(versionCode: Int, versionName: String?): Track = publisher.edits().tracks().update(packageName, editId, "alpha", Track().apply { releases = listOf(TrackRelease().apply { status = "draft" - name = apkVariants[0].versionName.toString() - versionCodes = apkVariants.map { it.versionCode.orNull?.toLong() ?: 0 } + name = versionName + versionCodes = listOf(versionCode.toLong()) }) track = "alpha" }).execute().prettyPrint() diff --git a/custom/build.gradle.kts b/custom/build.gradle.kts index 53f9dca51..5d3ba1422 100644 --- a/custom/build.gradle.kts +++ b/custom/build.gradle.kts @@ -75,19 +75,20 @@ fun ProductFlavor.createPublishBundleWithExpansionTask( println("packageName $packageName") createPublisher(File(rootDir, "playstore.json")) .transactionWithCommit(packageName) { - val versionCode = (7 * 1_000_000) + versionCode!! + val variants = + applicationVariants.releaseVariantsFor(this@createPublishBundleWithExpansionTask) val generatedBundleFile = File( - "$buildDir/outputs/bundle/${capitalizedName.toLowerCase()}Release" + - "/custom-/${capitalizedName.toLowerCase()}-/release.aab" + "$buildDir/outputs/bundle/${capitalizedName.toLowerCase()}" + + "Release/custom-${capitalizedName.toLowerCase()}-release.aab" ) if (generatedBundleFile.exists()) { uploadBundle(generatedBundleFile) - uploadExpansionTo(file, versionCode) - attachExpansionTo(versionCode, versionCode) - // addToTrackInDraft(versionCode) + uploadExpansionTo(file, variants[0].versionCode) + attachExpansionTo(variants[0].versionCode) + addToTrackInDraft(variants[0].versionCode, versionName) } else { - throw FileNotFoundException("Unable to generate aab file") + throw FileNotFoundException("Unable to find generated aab file") } } } @@ -96,7 +97,8 @@ fun ProductFlavor.createPublishBundleWithExpansionTask( fun DomainObjectSet.releaseVariantsFor(productFlavor: ProductFlavor) = find { it.name.equals("${productFlavor.name}Release", true) }!! - .outputs.filterIsInstance().sortedBy { it.versionCodeOverride } + .outputs.filterIsInstance() + .filter { it.baseName.contains("universal") }.sortedBy { it.versionCode } afterEvaluate { tasks.filter { it.name.contains("ReleaseBundleWithExpansionFile") }.forEach {