Fastlane instructions

Posted by VanPEP on Thu, 10 Feb 2022 22:47:26 +0100

Android automatic packaging and release to fir Im (based on official tutorial)

Preamble

See some on the Internet fastlane Most of the tutorials are published in dandelion,I don't like dandelion very much. There were too many dandelion advertisements and there were too few downloads before,So according to the official course,Organize a release after many failures fir.im course,Welcome to correct😁
  1. Install fast track
    a. Ruby environment + Bundler(MacOS / Linux / Windows). If macOS is used, it is not recommended to directly use Ruby system. It is recommended to directly use brew for installation
    b. MacOS can use
    brew install fastlane

  2. Install fast track
    From the TerMinal CD to the project root directory / AS, click TerMinal and run it
    fastlane init
    You will be asked to confirm that you are ready to start, and then provide some information. Quick start:

  3. When asking, provide the package name of your application (such as io.fabric.yourapp) ※ it doesn't matter if you press this step carelessly. You can redefine it in Appfile, or it shouldn't be important for those who don't go to Google store in China (I understand that)

  4. When asked for the path to your json secret file, press Enter

  5. When the system asks you if you plan to upload information to Google Play through the fast channel, please answer "n" (we can set it later)
    this is it! fastlane will automatically generate the configuration for you based on the information provided.
    You can see the newly created/ fastlane directory, which contains the following files:
    • Appfile, which defines the global configuration information of the application
    • Fastfile, which defines the "channel" FASTLANE for the behavior of the drive
    (don't care about the actions folder, unless we want to customize actions)

  6. Configure fir Im (based on Github tutorial for Fir)

  7. Run in the project location where fastlane was initialized and configured in the previous step
    fastlane add_plugin fir_cli
    The gem of fir cli has been built in, and files can be directly uploaded to fir in fastlane im
    There will be more in the Pluginfile file

  8. Need in fir website Log in and get your own APIToken

  9. In the Fastfile file, you can see that

  10. Other types will not be considered for the time being. As an example, we can write the operation method of gofir. Note that the operation body should end and follow end

lane :gofir do
  puts "FastLane start goFir~~~"
end

Such a running body is written. How should we use it
Just run it on the command line where the current project is located
fastlane gofir
that will do
5. The running body has been written. Now let's start to write the real content in the running body

# Multi channel environment
    gradle(
            task: 'assemble',  # The gradle task stack doesn't need much explanation
            flavor: 'xinyixy_shaanxi', # This flavor refers to the configuration required for multi-channel packaging,
        Otherwise, the specific generated file will not be found,If there is no multi-channel demand, it can not be written
            build_type: 'Release'  # The compilation type does not need to be interpreted  
        )
# Single channel environment
  gradle(task: 'assemble', build_type: 'Release')
  1. Will you worry about how to write the version update instructions when releasing the application?
# So we can directly use the latest git submission record as the version description   
changelog_from_git_commits(commits_count: 1, merge_commit_filtering: "exclude_merges")
  1. release
                fir_cli api_token: "xxxxxxxxxxxxxxx", # APIToken I got in fir before
       			specify_file_path: lane_context[SharedValues::GRADLE_APK_OUTPUT_PATH], # Get the apk path generated after the current compilation
		        changelog: lane_context[SharedValues::FL_CHANGELOG]  # git latest submission log description
OK be accomplished~
  1. Take a look at the complete
fastlane_version "2.68.2"
default_platform :android
platform :android do
  
    lane :gofir do
    
        gradle(
            task: 'assemble',
            flavor: 'xinyixy_shaanxi',
            build_type: 'Release'
        )
    
    changelog_from_git_commits(commits_count: 1, merge_commit_filtering: "exclude_merges")
    
    fir_cli api_token: "a02bbab34ecb5e84f4bc8f55421d12de",
    specify_file_path: lane_context[SharedValues::GRADLE_APK_OUTPUT_PATH],
    changelog: lane_context[SharedValues::FL_CHANGELOG]
  end
  
  
end
  1. Concluding remarks
    In this way, the release to fir is completed. fastlane also supports the call script to call sh. in this way, we can also realize some functions we want through sh without writing action. For example, after the release is completed, send an email to the tester to inform the leader that the task is completed~

Topics: Android