Setup Supply
Fastlane uses tool called supply
to deploy your binaries to the Play Store. So you have to set up supply
to allow its access to your Play Store account. To do that, you need to follow this steps.
Sign APK
Before releasing your app to Play Store you need to digitally sign your APK. This is a required step since every APK needs to contain a certificate in order to verify its authenticity when the app is installed.
To build sign apk you have to create your Keystore following this. Then add code below to your build.gradle
file. And also add your keystore file to your app level directory.
As you can see our releaseKeyAlias
, releaseKeyPassword
, releaseKeyStore
, releaseStorePassword
is stored in keystore.properties
file. So let’s create keystore.properties
file in your root project.
Since we have to push code to our repos and let CircleCI build our app, storing keystore file and keystore.properties
in our project is not the best way.
Note: We still can use this option to build sign apk locally but make sure you have ignore keystore and keystore.properties file to push to your repository.
Now we still need to find a way to properly get the keystore file in CircleCI. Let’s give a look at some of our options.
- Add your keystore file to your repo. This is the easiest way, but not the best way if you have an open source project.
- Add your keystore file somewhere in the cloud and download it. This approach works, but we have to download the key every time we need to deploy a new release apk.
- Converted your keystore file to base64, add it as environment variable and decode it in CircleCI. With this approach, we have our key encoded in the CircleCI server and we only need to decode for release new app.
Following the third option you firstly need to convert your keystore to base64. To do that, you can simply run $ base64 your_key_store
After that you need to add the encoded key to CircleCI environment variable named KEYSTORE
.
So it’s time to implement the command to decode the key. Do you remember that we have a references name *create_keystore_properties
and *decode_android_key
? We use these references to create keystore.properties
file and decode keystore file.
What we are doing here is to decode the KEYSTORE
environment variable and output the result to two keystore file to root project and app directory. The > /dev/null
is just there to avoid outputting the result to console.
Have you noticed that we have $RELEASE_KEY_ALIAS
, $RELEASE_KEY_PASSWORD
, $RELEASE_KEYSTORE
, $RELEASE_STORE_PASSWORD
, it’s all about CircleCI environment variables.
Do you still remember when you configured the supply
tool, you created a file ( .json
) with the credentials to access the Google Play Store. In CircleCI you need to add the content of that file to an environment variable called GOOGLE_PLAY_KEY
and create a reference that will create that file for you.
Note: Don’t forget to change the file name in the code above to the file name that you have in your
Appfile
.