Friends React Native and Fastlane

https://habrastorage.org/webt/n8/lo/r5/n8lor5lkvnqev0xktqwxayrv1t0.png


Those of you who have at least once been interested in such a topic have come across Fastlane more than once - an extremely useful utility that solves the problem of automating builds and publishing applications.


There are a large number of articles and videos that describe in detail the advantage of using automated assembly of the project and the contents of these articles in relation to React Native (however, to another cross-platform) is reduced to the following actions:


  1. Initialize Fastlane in iOS and Android folders
  2. Copy the platform-specific script types: clean, build,publish
  3. iOS Android
  4. !

, , - . ,


  1. ?
    , ( , , ..). Fastfile , DRY?
  2. ?
    Ruby, Fastlane , Fastlane . JS , Ruby, , , .
  3. ?
    , , , Android. iOS Fastlane , Android . Ruby , Ruby , , .
  4. ?
    . , - , .

- Ruby API, . Android :


#      
import "../../scripts/Fastfile.rb"

lane :publish do |options|
  #       
  self.runner.current_platform = :android

  assert_git()
  assert_environment(env: options[:env])
  assert_credentials()

  new_version=increment_version(type: options[:increment])
  version_description=set_version(version: new_version)

  build(env: options[:env])

  upload(track: options[:track])

  commit(text: 'Up version to ' + new_version)
  commit_tag(text: 'android/' + new_version)
  push_all()

  message(text: '   "'+ app_name + '"   Google Play.   ' + options[:track].upcase + ' ' + version_description + url)
end

, build, Fastfile.rb. - : .


Ruby, , . React Native JS , , , Ruby. JS ! ( )


(, ) Fastlane, JS, . :


https://habrastorage.org/webt/vq/bi/pp/vqbippe_pkcckg5utfsdseb948a.gif


, .


:


import { android, gradle, AndroidPlatform, ui, supply, Incrementer } from "@lamantin/fastpush"

const androidPlatform = new AndroidPlatform()

const [oldVersionCode, newVersionCode] = await androidPlatform.incrementVersionCode()
ui.success(`Success update build [${oldVersionCode}] -> [${newVersionCode}]`)

android([
  gradle("clean"),
  gradle("assemble", {
    build_type: "Release",
  }),
  supply({ track: "beta" }),
])

( ), :


  • TypeScript ,
  • JS
  • , ,
  • 1 , . ios android Fastlane
  • ,

, , . , CLI , , :


https://habrastorage.org/webt/mf/2q/yy/mf2qyyzncnmxlbijlkctcl8lzwu.png


Github , .




yarn add @lamantin/fastpush --dev
# 
npm install @lamantin/fastpush --save-dev

, , - :


import { publish } from '@lamantin/fastpush/build/src/cli/publish'
import { fastpush, FastpushResult } from '@lamantin/fastpush/build/src/cli/fastpush'
import { git } from '@lamantin/fastpush/build/src/utils'
import Telegram from 'our-own-app/Telegram'

//    
const options: FastpushResult = fastpush(process.argv)

//     (   CLI),     
publish(options, {
  // onPostPublish - ,       
  onPostPublish: async (platform, [prevVersion, version], [prevBuild, build]) => {
    const store = platform.type === 'ios' ? 'App Store ' : 'Google Play '
    const message = `App "My App Name"  sended to ${store}, track ${options.track.toUpperCase()}.\\n Version: ${tag}`
    Telegram.sendMessage(message)    
  }
})

fastpush, , JS options, . , publish . , ( , ).


Flutter?


React Native, Flutter ( ).




The project is in the process of being actively finished and welcomes your Pull Requests, Issues, or at least comments.
We hope that it will be useful to someone other than us or will encourage us to write more flexible solutions.


All Articles