In today’s article we are discussing about Automation. Who doesn’t love continuous integration, continuous delivery and continuous deployment? It’s just something Huawei Mobile Service (HMS) very well knows and hence provides AppGallery Connect (AGC) RESTful APIs for developers to automate and customizes services provided by AGC. In this regards, Publishing API is one of the most useful and robust API of AGC. It allows developers to upload, manage, update and release apps and relevant information without any manual work as such. However, in order to achieve this developers has to do backend development and call APIs provided by AGC. This is where Fastlane comes into play.
What is Fastlane?
Fastlane is an open source platform aimed at simplifying Android and iOS deployment. It facilitates developers to automate every aspect of app development and release workflow. Not only that Fastlane also handles all tedious tasks, like generating screenshots, dealing with code signing and releasing your application. Fastlane as of now doesn’t support automation for Huawei AGC. Although, thanks to our wonderful developer community, there is HMS AGC Fastlane plugin that we can use and achieve Fastlane functionalities.
- First we need to download Ruby from their official websites
- Then install bundler using following command: gem install bundler
- Navigate your terminal to your project's directory and run: bundle init
- Then add Fastlane to our bundler with this command: bundle add fastlane
- Finally run this command: bundle install
Setting up Fastlane
To initialize Fastlane in your project run this command: fastlane init
- You will be asked to provide package name of your app e.g: com.huawei.codelabkit
- Then provide path to json secret file or you may skip as well
- Lastly Answer 'n' when asked if you plan on uploading info to Google Play via fastlane
- We are all set with Fastlane. Fastlane has automatically created fastlane directory under your project, with the following files:
- Appfile which defines configuration information that is global to your app
- Fastfile which defines the "lanes" that drive the behavior of fastlane
- Now we will install Fastlane plugin for HMS AGC by using following command: fastlane add_plugin huawei_appgallery_connect
Sign in to AppGallery Connect and select Users and permissions and follow following steps:
- Go to Api Key > Connect API from the navigation tree on the left and click Create.
- Set Name to a customized client name, set Roles to the corresponding role, and click Confirm.
- After the client is successfully created, record the values of Client ID and Key in the client information list. Aftter this, we will configure Fastlane plugin using details from AGC configuration.
Configure Fastlane AGC Plugin
Go to Fastlane folder and open fastfile and put following details:
lane :deploy do huawei_appgallery_connect( client_id: "<CLIENT_ID>", # your client id from AGC client_secret: "<CLIENT_SECRET>", # your key from AGC app_id: "<APP_ID>", # your app id apk_path: "<APK_PATH>", # e.g "app/release/app-release.apk" # Optional, Parameter beyond this are optional submit_for_review: true, privacy_policy_url: "https://example.com", changelog_path: "<PATH_TO_CHANGELOG_FILE>", # release time to release app on specific date release_time: "2019-12-25T07:05:15+0000", # For phase wise release: set these parameters phase_wise_release: true, phase_release_start_time: "2019-12-25T07:05:15+0000", phase_release_end_time: "2019-12-28T07:05:15+0000", phase_release_percent: "10.00", phase_release_description: "<DESCRIPTION>" ) end
Finally, we all are set and ready to publish our app using Fastlane AGC plugin. In order to publish and release app use following command:
fastlane deploy # here deploy is the lane name as shown in fastfile above. It can be anything of your choice.
Once you receive success message in your terminal then go to AGC > Distribute > Version information and now you should have latest app publish and waiting for review.
That’s it. Now you just have to have wait for app to be available on app gallery after successful review.