React Native Fastlane deployment for Android
system prerequisites
Using RubyGems -> sudo gem install fastlane -NV
Alternatively using -> Homebrew brew cask install fastlane
Steps to generate JSON secret
- Open the Android fastlane
- Click the Settings menu entry, followed by API access
- Click the CREATE SERVICE ACCOUNT button
- Follow the Google Developers Console link in the dialog, which opens a new tab/window:
- Click the CREATE SERVICE ACCOUNT button at the top of the Google Developers Console
- Provide a
Service account name
- Click Select a role and choose Service Accounts > Service Account User
- Check the Furnish a new private key checkbox
- Make sure JSON is selected as the
Key type
- Click SAVE to close the dialog
- Make a note of the file name of the JSON file downloaded to your computer
- Back on the Google Play Console, click DONE to close the dialog
- Click on Grant Access for the newly added service account
- Choose Release Manager (or alternatively Project Lead) from the
Role
dropdown. (Note that choosing Release Manager grants access to the production track and all other tracks. Choosing Project Lead grants access to update all tracks except the production track.) - Click ADD USER to close the dialog
Setting up Fastlane
Navigate your terminal to your project’s directory and run
fastlane init
You’ll be asked to confirm that you’re ready to begin, and then for a few pieces of information. To get started quickly:
- Provide the package name for your application
- Press enter when asked for the path to your JSON secret file
- Answer ‘n’ when asked if you plan on uploading info to Google Play via fastlane (we can set this up later)
That’s it! fastlane will automatically generate a configuration for you based on the information provided.
You can see the newly created ./fastlane
directory, with the following files:
Appfile
which defines configuration information that is global to your appFastfile
which defines the “lanes” that drive the behavior of fastlane
default_platform(:android)
platform :android do
lane :beta do
path = '../app/build.gradle'
re = /versionCode\s+(\d+)/
s = File.read(path)
versionCode = s[re, 1].to_i
s[re, 1] = (versionCode + 1).to_s
f = File.new(path, 'w')
f.write(s)
f.close
releaseFilePath = File.join(Dir.pwd, "../app/", "YOUR_KEY_STORE_FILE_NAME")
gradle(task: 'clean')
gradle(
task: 'bundle',
build_type: 'Release',
print_command: false,
properties: {
"android.injected.signing.store.file" => releaseFilePath,
"android.injected.signing.store.password" => "STORE_PASSWORD",
"android.injected.signing.key.alias" => "MY_KEY_ASIAS",
"android.injected.signing.key.password" => "SIGNING_PASSWORD",
})
upload_to_play_store(
track: 'internal'
)
end
end
Let’s Deploy
fastlane beta
React native awesome boilerplate Link
For more details visit fastlane