Class: Fastlane::Actions::CreateAppOnManagedPlayStoreAction

Inherits:
Fastlane::Action show all
Defined in:
fastlane/lib/fastlane/actions/create_app_on_managed_play_store.rb

Constant Summary

Constants inherited from Fastlane::Action

Fastlane::Action::AVAILABLE_CATEGORIES, Fastlane::Action::RETURN_TYPES

Class Method Summary collapse

Methods inherited from Fastlane::Action

action_name, author, deprecated_notes, lane_context, method_missing, other_action, output, return_type, sample_return_value, shell_out_should_use_bundle_exec?, step_text

Class Method Details

.authorsObject



28
29
30
# File 'fastlane/lib/fastlane/actions/create_app_on_managed_play_store.rb', line 28

def self.authors
  ["janpio"]
end

.available_optionsObject



52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
# File 'fastlane/lib/fastlane/actions/create_app_on_managed_play_store.rb', line 52

def self.available_options
  [
    # Authorization
    FastlaneCore::ConfigItem.new(key: :json_key,
                                 env_name: "SUPPLY_JSON_KEY",
                                 short_option: "-j",
                                 conflicting_options: [:json_key_data],
                                 optional: true, # optional until it is possible specify either json_key OR json_key_data are required
                                 description: "The path to a file containing service account JSON, used to authenticate with Google",
                                 code_gen_sensitive: true,
                                 default_value: CredentialsManager::AppfileConfig.try_fetch_value(:json_key_file),
                                 default_value_dynamic: true,
                                 verify_block: proc do |value|
                                   UI.user_error!("Could not find service account json file at path '#{File.expand_path(value)}'") unless File.exist?(File.expand_path(value))
                                   UI.user_error!("'#{value}' doesn't seem to be a JSON file") unless FastlaneCore::Helper.json_file?(File.expand_path(value))
                                 end),
    FastlaneCore::ConfigItem.new(key: :json_key_data,
                                 env_name: "SUPPLY_JSON_KEY_DATA",
                                 short_option: "-c",
                                 conflicting_options: [:json_key],
                                 optional: true,
                                 description: "The raw service account JSON data used to authenticate with Google",
                                 code_gen_sensitive: true,
                                 default_value: CredentialsManager::AppfileConfig.try_fetch_value(:json_key_data_raw),
                                 default_value_dynamic: true,
                                 verify_block: proc do |value|
                                   begin
                                     JSON.parse(value)
                                   rescue JSON::ParserError
                                     UI.user_error!("Could not parse service account json: JSON::ParseError")
                                   end
                                 end),
    FastlaneCore::ConfigItem.new(key: :developer_account_id,
                                 short_option: "-k",
                                 env_name: "SUPPLY_DEVELOPER_ACCOUNT_ID",
                                 description: "The ID of your Google Play Console account. Can be obtained from the URL when you log in (`https://play.google.com/apps/publish/?account=...` or when you 'Obtain private app publishing rights' (https://developers.google.com/android/work/play/custom-app-api/get-started#retrieve_the_developer_account_id)",
                                 code_gen_sensitive: true,
                                 default_value: CredentialsManager::AppfileConfig.try_fetch_value(:developer_account_id),
                                 default_value_dynamic: true),
    # APK
    FastlaneCore::ConfigItem.new(key: :apk,
                                 env_name: "SUPPLY_APK",
                                 description: "Path to the APK file to upload",
                                 short_option: "-b",
                                 code_gen_sensitive: true,
                                 default_value: Dir["*.apk"].last || Dir[File.join("app", "build", "outputs", "apk", "app-release.apk")].last,
                                 default_value_dynamic: true,
                                 verify_block: proc do |value|
                                   UI.user_error!("No value found for 'apk'") if value.to_s.length == 0
                                   UI.user_error!("Could not find apk file at path '#{value}'") unless File.exist?(value)
                                   UI.user_error!("apk file is not an apk") unless value.end_with?('.apk')
                                 end),
    # Title
    FastlaneCore::ConfigItem.new(key: :app_title,
                                 env_name: "SUPPLY_APP_TITLE",
                                 short_option: "-q",
                                 description: "App Title"),
    # Language
    FastlaneCore::ConfigItem.new(key: :language,
                                 short_option: "-m",
                                 env_name: "SUPPLY_LANGUAGE",
                                 description: "Default app language (e.g. 'en_US')",
                                 default_value: "en_US",
                                 verify_block: proc do |language|
                                   unless Supply::Languages::ALL_LANGUAGES.include?(language)
                                     UI.user_error!("Please enter one of the available languages: #{Supply::Languages::ALL_LANGUAGES}")
                                   end
                                 end),
    # Google Play API
    FastlaneCore::ConfigItem.new(key: :root_url,
                                 env_name: "SUPPLY_ROOT_URL",
                                 description: "Root URL for the Google Play API. The provided URL will be used for API calls in place of https://www.googleapis.com/",
                                 optional: true,
                                 verify_block: proc do |value|
                                   UI.user_error!("Could not parse URL '#{value}'") unless value =~ URI.regexp
                                 end),
    FastlaneCore::ConfigItem.new(key: :timeout,
                                 env_name: "SUPPLY_TIMEOUT",
                                 optional: true,
                                 description: "Timeout for read, open, and send (in seconds)",
                                 type: Integer,
                                 default_value: 300)
  ]
end

.categoryObject



141
142
143
# File 'fastlane/lib/fastlane/actions/create_app_on_managed_play_store.rb', line 141

def self.category
  :misc
end

.descriptionObject



24
25
26
# File 'fastlane/lib/fastlane/actions/create_app_on_managed_play_store.rb', line 24

def self.description
  "Create Managed Google Play Apps"
end

.detailsObject



36
37
38
# File 'fastlane/lib/fastlane/actions/create_app_on_managed_play_store.rb', line 36

def self.details
  "Create new apps on Managed Google Play."
end

.example_codeObject



40
41
42
43
44
45
46
47
48
49
50
# File 'fastlane/lib/fastlane/actions/create_app_on_managed_play_store.rb', line 40

def self.example_code
  [
    "create_app_on_managed_play_store(
      json_key: 'path/to/you/json/key/file',
      developer_account_id: 'developer_account_id', # obtained using the `get_managed_play_store_publishing_rights` action (or looking at the Play Console url)
      app_title: 'Your app title',
      language: 'en_US', # primary app language in BCP 47 format
      apk: '/files/app-release.apk'
    )"
  ]
end

.is_supported?(platform) ⇒ Boolean

Returns:



137
138
139
# File 'fastlane/lib/fastlane/actions/create_app_on_managed_play_store.rb', line 137

def self.is_supported?(platform)
  [:android].include?(platform)
end

.return_valueObject



32
33
34
# File 'fastlane/lib/fastlane/actions/create_app_on_managed_play_store.rb', line 32

def self.return_value
  # If your method provides a return value, you can describe here what it does
end

.run(params) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'fastlane/lib/fastlane/actions/create_app_on_managed_play_store.rb', line 7

def self.run(params)
  client = PlaycustomappClient.make_from_config(params: params)

  FastlaneCore::PrintTable.print_values(
    config: params,
    mask_keys: [:json_key_data],
    title: "Summary for create_app_on_managed_play_store"
  )

  client.create_app(
    app_title: params[:app_title],
    language_code: params[:language],
    developer_account: params[:developer_account_id],
    apk_path: params[:apk]
  )
end