Easy way to release Android Build to Slack and Play store using Fastlane

In this tutorial will see how to upload Android Build to Slack and Play store using Fastlane

What is fastlane?

fastlane is an open source platform continuous delivery tool aimed at simplifying Android and iOS deployment written in Ruby. It automate every aspect of your development and release workflow.

In this tutorial we will see how to setup fastlane and releasing Android builds to Play store(Alpha, Beta & Production). For internal development and testing purposes we will see how to upload to APK to Slack.

Our operating system is Ubuntu 14.04, For higher version of Ubuntu machines following ruby setup may change slightly.

1. Setup and install Ruby on your system

First we need to install ruby on your system

sudo apt-add-repository ppa:brightbox/ruby-ng

sudo apt-get install ruby2.4

sudo apt-get install yum

sudo apt-get install ruby-dev

sudo apt-get install ruby`ruby -e 'puts RUBY_VERSION[/\d+\.\d+/]'`-dev

2. Setup and install Fastlane on your system

After that you need to install fastlane

 sudo gem install fastlane -NV

Get into your terminal to your project’s directory and run below comment

fastlane init

Provide the package name for your application when asked (e.g. com.example.demofastlane)

Now fastlane will automatically generate a configuration for your based on the information provided on your project folder

3. Setup and collect your slack credentials

If you don’t have slack account please create account first. Login to slack account and create a new project choose your slack work space then create app in slack.

After a successful app creation you should see Incoming web hook option in Menu. Then activate Incoming web hook.

Click Add new web hook to work space button and choose your work space or user to upload the APK. After the work space is created you will get the Webhook URL like below

https://hooks.slack.com/services/xyxyxy/yyyyyy/xxxxxxxxxxxxxxxxx

Click OAuth & Permission option in Menu. You can get the OAuth access token here.

You should also provide permission for this account. Click Select Permission scopes you will see the some drop down details and you should select this option Upload and modify files as user.

After all process is completed click Save changes button.

Add Slack URL to fastfile.

fastfile code for Slack APK upload.

To upload APK to slack run this below line on terminal after get into the project directory.

fastlane slackbuild

Now build will be uploaded to Slack with messages.

4. Setup for Play store release

Create New Project on Google Play console.

Then create Service Account and Select a role and choose Service Accounts > Service Account User.

Check the Furnish a new private key checkbox, Select JSON as the Key type and create and download the JSON.

After you download the json file from developer play console, Now edit your fastlane/appfile located in your project and put the json path to your appfile and change package name also.

fastfile code for Play store release

To upload apk to playstore run this below line on terminal after get into the project directory.

fastlane deploy

Now APK will be uploaded to Play store. You can check it on Goolge Play Console.