Class: Fastlane::SetupAndroid

Inherits:
Setup
  • Object
show all
Defined in:
fastlane/lib/fastlane/setup/setup_android.rb

Instance Attribute Summary collapse

Attributes inherited from Setup

#appfile_content, #fastfile_content, #had_multiple_projects_to_choose_from, #is_swift_fastfile, #lane_to_mention, #platform, #preferred_setup_method, #project_path, #user

Instance Method Summary collapse

Methods inherited from Setup

#add_or_update_gemfile, #append_lane, #append_team, #appfile_template_content, #continue_with_enter, #ensure_gemfile_valid!, #explain_concepts, #fastfile_template_content, #gemfile_exists?, #gemfile_path, #initialize, #setup_gemfile!, setup_swift_support, #show_analytics_note, start, #suggest_next_steps, #welcome_to_fastlane, #write_fastfile!

Constructor Details

This class inherits a constructor from Fastlane::Setup

Instance Attribute Details

#json_key_fileObject

Returns the value of attribute json_key_file.



3
4
5
# File 'fastlane/lib/fastlane/setup/setup_android.rb', line 3

def json_key_file
  @json_key_file
end

#package_nameObject

Returns the value of attribute package_name.



4
5
6
# File 'fastlane/lib/fastlane/setup/setup_android.rb', line 4

def package_name
  @package_name
end

Instance Method Details

#fetch_information_for_appfileObject



52
53
54
55
56
57
58
59
60
61
62
63
64
65
# File 'fastlane/lib/fastlane/setup/setup_android.rb', line 52

def fetch_information_for_appfile
  UI.message('')
  UI.message("To avoid re-entering your package name and issuer every time you run fastlane, we'll store those in a so-called Appfile.")

  self.package_name = UI.input("Package Name (com.krausefx.app): ")
  puts("")
  puts("To automatically upload builds and metadata to Google Play, fastlane needs a service account json secret file".yellow)
  puts("Follow the Setup Guide on how to get the Json file: https://docs.fastlane.tools/actions/supply/".yellow)
  puts("Feel free to press Enter at any time in order to skip providing pieces of information when asked")
  self.json_key_file = UI.input("Path to the json secret file: ")

  self.appfile_content.gsub!("[[JSON_KEY_FILE]]", self.json_key_file)
  self.appfile_content.gsub!("[[PACKAGE_NAME]]", self.package_name)
end

#finish_upObject



91
92
93
94
95
# File 'fastlane/lib/fastlane/setup/setup_android.rb', line 91

def finish_up
  self.fastfile_content.gsub!(":ios", ":android")

  super
end

#init_supplyObject



67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
# File 'fastlane/lib/fastlane/setup/setup_android.rb', line 67

def init_supply
  UI.message("")
  question = "Do you plan on uploading metadata, screenshots, and builds to Google Play using fastlane?".yellow
  UI.message(question)
  UI.message("We will now download your existing metadata and screenshots into the `fastlane` folder so fastlane can manage it")
  if UI.confirm("Download existing metadata and setup metadata management?")
    begin
      require 'supply'
      require 'supply/setup'
      supply_config = {
        json_key: self.json_key_file,
        package_name: self.package_name
      }
      Supply.config = FastlaneCore::Configuration.create(Supply::Options.available_options, supply_config)
      Supply::Setup.new.perform_download
    rescue => ex
      UI.error(ex.to_s)
      UI.error("Setting up `supply` (metadata management action) failed, but don't worry, you can try setting it up again using `fastlane supply init` whenever you want.")
    end
  else
    UI.success("You can run `fastlane supply init` to set up metadata management at a later point.")
  end
end

#setup_androidObject



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# File 'fastlane/lib/fastlane/setup/setup_android.rb', line 6

def setup_android
  self.platform = :android
  self.is_swift_fastfile = false

  welcome_to_fastlane

  self.fastfile_content = fastfile_template_content
  self.appfile_content = appfile_template_content

  fetch_information_for_appfile

  FastlaneCore::FastlaneFolder.create_folder!

  init_supply

  self.append_lane([
                     "desc \"Runs all the tests\"",
                     "lane :test do",
                     "  gradle(task: \"test\")",
                     "end"
                   ])

  self.append_lane([
                     "desc \"Submit a new Beta Build to Crashlytics Beta\"",
                     "lane :beta do",
                     "  gradle(task: \"clean assembleRelease\")",
                     "  crashlytics",
                     "",
                     "  # sh \"your_script.sh\"",
                     "  # You can also use other beta testing services here",
                     "end"
                   ])

  self.append_lane([
                     "desc \"Deploy a new version to the Google Play\"",
                     "lane :deploy do",
                     "  gradle(task: \"clean assembleRelease\")",
                     "  upload_to_play_store",
                     "end"
                   ])

  self.lane_to_mention = "test"

  finish_up
end