You are currently viewing Using Fastlane to Release the Badge Magic Android App on Playstore and F-droid

Using Fastlane to Release the Badge Magic Android App on Playstore and F-droid


fastlane is the easiest way to automate beta deployments and releases for Android apps. We are going to see how we used fastlane in fossasia/badge-magic-android to automate almost everything inside our project.


Fastlane Configuration

In Badge Magic, fastlane is integrated to deploy apps on Playstore as well as F Droid. This is a very straightforward method to manage both things from a single perspective.

This is the hierarchy of the fastlane folder and it specifies the following:

  • Metadata:

This folder holds the information regarding the project and every other resource such as images, changelogs, descriptions.

Every time we publish anything using the fastlane command, it checks the files and uploads the changes on every build.

  • AppFile:
json_key_file("./scripts/fastlane.json") # Path to the json secret file - Follow https://docs.fastlane.tools/actions/supply/#setup to get one
package_name("org.fossasia.badgemagic") # e.g. com.krausefx.app

AppFile is responsible for specifying the path of the google json and the package name of the project.

  • Fastfile: 

This is by far the most important file which handles almost everything with respect to scripting. Let’s have a look in more detail.


Fastfile

Fastfile contains all the code required to run lanes and define the tasks that need to be performed.

In this file, we first define the platform we are going to work on. In our case it is android, therefore: 

default_platform(:android)

Let’s create a lane which builds the aab package for our deployment. We can specify the gradle task with the type which needs to be performed when we run a specific lane.

lane :buildAAB do
    gradle(task: "bundle",build_type: "Release")
end

Let’s create another lane which uploads the aab package from our build directly to the play store server. 

lane :uploadToPlaystore do
    upload_to_play_store(track:"alpha",aab:"apk/badge-magic-master-app.aab")
end

This uploads the aab present in the specified directory to the playstore. So finally our final Fastfile looks like this:

default_platform(:android)
platform :android do
    lane :buildAAB do
        gradle(task: "bundle",build_type: "Release")
    end
    lane :uploadToPlaystore do
        upload_to_play_store(track: "alpha",aab:"apk/badge-magic-master-app.aab")
    end
end

Conclusion

Fastlane is amazing and it automates almost everything for you. Fastfile is written in ruby and you can code lane dependencies, condition builds and anything you can think of when it comes to build automation.

Using fastlane we integrated 2 app stores without any hassle or code duplication.

Ressources

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.