Triple-T / gradle-play-publisher

GPP is Android's unofficial release automation Gradle Plugin. It can do anything from building, uploading, and then promoting your App Bundle or APK to publishing app listings and other metadata.
MIT License
4.13k stars 341 forks source link

For Pipeline use I want to to publish all flavours of one buildtype #932

Closed matecode closed 3 years ago

matecode commented 3 years ago

Problem description

I have a whitelabel app running with one dimension flavours in combination with buildtypes. I want to publish a dedicated buildtype, e.g buidltypes given:

dev, staging, release

where i have 3 pipelines in my CI system, so i want to call

publishDevApk publishStagingApk publishReleaseApk

Potential solutions/workarounds

please priovde a task wich "summarize" all publish_FLAVOR_BUILDTYPE tasks

Additional context

For me it is not possible to achieve this with playConfig

matecode commented 3 years ago

If someone is interested, at the moment i ended up with this (in android block). I'm not a gradle/groovy expert, hence i didn't get the change to kotlin for gradle yet. If anyone wants to suggest a better solution, feel free!

applicationVariants.all { variant ->

    //Find publishApk task for variant
    def publishApkVariantTaskName = "publish${variant.name.capitalize()}Apk"
    def publishApkVariantTask = project.tasks.findByName(publishApkVariantTaskName)

    if (publishApkVariantTask != null) {
        //Create publishTasks to publish buildTypes for ci pipelines
        def buildType = variant.buildType.name
        def publishApkBuildTypeTaskName = "publish${buildType.capitalize()}Apk"
        def publishApkBuildTypeTask = project.tasks.findByName(publishApkBuildTypeTaskName)
        if (publishApkBuildTypeTask == null) {
            publishApkBuildTypeTask = project.tasks.create(name: publishApkBuildTypeTaskName, group: "publishing")
        }
        publishApkBuildTypeTask.dependsOn(publishApkVariantTask)
    }
}
SUPERCILEX commented 3 years ago

I'll have to think about this a bit. Basically I'm worried about creating an insane amount of tasks.

matecode commented 3 years ago

Thank you for your reply @SUPERCILEX .

I just had the idea that maybe it could be an option on play block scope to activate the extra task, so everything stays for the normal use case as it is, but it is possible to "activate" the additional build type tasks

play {
    enableBuildTypeTasks.set(true)
}
SUPERCILEX commented 3 years ago

It looks like the Android plugin does this for their tasks, so we may as well.