Publish your Lightbuild app

To publish your app on Google Play, you build a release version of the app as an Android App Bundle, sign it with your upload key, and upload it to the Play Console. This page shows you how to configure release signing in a Lightbuild project and build a signed app bundle with the Lightbuild CLI.

Create an upload key

Google Play uses Play App Signing to sign the APKs that it delivers to users, and you sign the app bundles that you upload with an upload key. If you don't have an upload key yet, create one with keytool, which is included with the JDK:

keytool -genkey -v -keystore upload-keystore.jks -keyalg RSA -keysize 2048 -validity 10000 -alias upload

The command prompts you for passwords for the keystore and the key, and then creates a keystore file named upload-keystore.jks in the current directory. Store the keystore in a secure location outside your project, and don't check it in to version control. For more information, see Sign your app.

Configure release signing

In your app module's lightbuild.yaml file, add a signing block to the release profile in packaging. Instead of writing your passwords in the file, reference environment variables with the ${NAME} syntax:

android:
  packaging:
    release:
      signing:
        storeFile: "${RELEASE_STORE_FILE}"
        storePassword: "${RELEASE_STORE_PASSWORD}"
        keyAlias: "${RELEASE_KEY_ALIAS}"
        keyPassword: "${RELEASE_KEY_PASSWORD}"

When you build, Lightbuild reads each value from its environment variable, so your passwords aren't stored in your project's files. For more information about these settings, see Packaging in the Lightbuild configuration reference.

Set the environment variables

Before you build, set the environment variables in the terminal where you run the Lightbuild CLI. For example, on macOS or Linux:

export RELEASE_STORE_FILE="$HOME/keystores/upload-keystore.jks"
export RELEASE_STORE_PASSWORD="KEYSTORE_PASSWORD"
export RELEASE_KEY_ALIAS="upload"
export RELEASE_KEY_PASSWORD="KEY_PASSWORD"

On Windows, in PowerShell:

$env:RELEASE_STORE_FILE = "$HOME\keystores\upload-keystore.jks"
$env:RELEASE_STORE_PASSWORD = "KEYSTORE_PASSWORD"
$env:RELEASE_KEY_ALIAS = "upload"
$env:RELEASE_KEY_PASSWORD = "KEY_PASSWORD"

Replace KEYSTORE_PASSWORD and KEY_PASSWORD with your passwords. In a CI system, store the passwords as secrets, and expose them to your build as environment variables.

Build a signed app bundle

Before each release, increase the versionCode setting in your app module's lightbuild.yaml file, and update versionName if needed. Google Play requires a higher version code for each upload. For more information, see Version your app.

To build the signed release app bundle, run:

lightbuild build app:app-release.aab

Lightbuild writes the bundle to app/build/app-release.aab. To see where each of the app module's targets writes its output, run lightbuild query app/... --output=files.

Upload your app to Google Play

Upload the signed app bundle to the Play Console. To test your app before you release it to users, upload it to an internal testing track first. For more information, see Upload your app to the Play Console.