How To Build, Sign And Publish Android Application Using Github Actions

The main goal of this article is to provide a complete implementation of a Github Workflow capable of securely building, signing, and publishing Android apps.

Follow these steps to create the Github Workflow:

1. Generate a new signing keystore

2. Add the following secrets to your Github repository (you’ll need to convert keystore.jks to base64 string)

In Repository Settings Add The Following Secrets To Security -> Secrets and variables -> Actions -> Repository secrets

3. Add a new signing configuration to your app’s build.gradle file. Note that rootProject.name is defined in the settings.gradle file.

android {
    // ...

    defaultConfig {
        // ...
        versionName "1.1"
        // ...
    }

    signingConfigs {
        release {
            storeFile = file("keystore/android_keystore.jks")
            storePassword System.getenv("SIGNING_STORE_PASSWORD")
            keyAlias System.getenv("SIGNING_KEY_ALIAS")
            keyPassword System.getenv("SIGNING_KEY_PASSWORD")
        }
    }

    buildTypes {
        // ...
        release {
            // ...
            applicationVariants.all { variant ->
                variant.outputs.all {
                    outputFileName = "${rootProject.name}_${versionName}.apk"
                }
            }
            signingConfig signingConfigs.release
        }
    }
}

4. Add Github Workflow to your repository in the .github/workflows folder. Here <<application name>> and <<project name>> are placeholders for rootProject.name and your Github repository’s name respectively.

Click Here