React Native Android fastlane Deployment
React Native Android fastlane Deployment

React Native Android fastlane Deployment

Created
Apr 8, 2022 8:13 AM
Department
Engineering
Category
Deployment
Technology
JavaScriptReact
Tags
Date
URL

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

  1. Open the Android fastlane
  2. Click the Settings menu entry, followed by API access
  3. image
  4. Click the CREATE SERVICE ACCOUNT button
  5. image
  6. Follow the Google Developers Console link in the dialog, which opens a new tab/window:
  7. Click the CREATE SERVICE ACCOUNT button at the top of the Google Developers Console
  8. image
  9. Provide a Service account name
  10. image
  11. Click Select a role and choose Service Accounts > Service Account User
  12. image
    image
  13. Check the Furnish a new private key checkbox
  14. image
  15. Make sure JSON is selected as the Key type
  16. image
    image
  17. Click SAVE to close the dialog
  18. Make a note of the file name of the JSON file downloaded to your computer
  19. Back on the Google Play Console, click DONE to close the dialog
  20. Click on Grant Access for the newly added service account
  21. image
  22. 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.)
  23. image
  24. Click ADD USER to close the dialog

Setting up Fastlane

Navigate your terminal to your project’s directory and run

image
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:

  1. Provide the package name for your application
  2. Press enter when asked for the path to your JSON secret file
  3. 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 app
  • Fastfile 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