Class: Fastlane::Actions::GetManagedPlayStorePublishingRightsAction

Inherits:
Fastlane::Action
  • Object
show all
Defined in:
fastlane/lib/fastlane/actions/get_managed_play_store_publishing_rights.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



47
48
49
# File 'fastlane/lib/fastlane/actions/get_managed_play_store_publishing_rights.rb', line 47

def self.authors
  ["janpio"]
end

.available_optionsObject



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
# File 'fastlane/lib/fastlane/actions/get_managed_play_store_publishing_rights.rb', line 74

def self.available_options
  [
    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
    )

  ]
end

.categoryObject



117
118
119
# File 'fastlane/lib/fastlane/actions/get_managed_play_store_publishing_rights.rb', line 117

def self.category
  :misc
end

.descriptionObject



43
44
45
# File 'fastlane/lib/fastlane/actions/get_managed_play_store_publishing_rights.rb', line 43

def self.description
  "Obtain publishing rights for custom apps on Managed Google Play Store"
end

.detailsObject



55
56
57
58
59
60
61
62
# File 'fastlane/lib/fastlane/actions/get_managed_play_store_publishing_rights.rb', line 55

def self.details
  [
    'If you haven\'t done so before, start by following the first two steps of Googles ["Get started with custom app publishing"](https://developers.google.com/android/work/play/custom-app-api/get-started) -> ["Preliminary setup"](https://developers.google.com/android/work/play/custom-app-api/get-started#preliminary_setup) instructions:',
    '"[Enable the Google Play Custom App Publishing API](https://developers.google.com/android/work/play/custom-app-api/get-started#enable_the_google_play_custom_app_publishing_api)" and "[Create a service account](https://developers.google.com/android/work/play/custom-app-api/get-started#create_a_service_account)".',
    'You need the "service account\'s private key file" to continue.',
    'Run the action and supply the "private key file" to it as the `json_key` parameter. The command will output a URL to visit. After logging in you are redirected to a page that outputs your "Developer Account ID" - take note of that, you will need it to be able to use [`create_app_on_managed_play_store`](https://docs.fastlane.tools/actions/create_app_on_managed_play_store/).'
  ].join("\n")
end

.example_codeObject



64
65
66
67
68
69
70
71
72
# File 'fastlane/lib/fastlane/actions/get_managed_play_store_publishing_rights.rb', line 64

def self.example_code
  [
    'get_managed_play_store_publishing_rights(
      json_key: "path/to/your/json/key/file"
    )
    # it is probably easier to execute this action directly in the command line:
    # $ fastlane run get_managed_play_store_publishing_rights'
  ]
end

.is_supported?(platform) ⇒ Boolean

Returns:



113
114
115
# File 'fastlane/lib/fastlane/actions/get_managed_play_store_publishing_rights.rb', line 113

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

.return_valueObject



51
52
53
# File 'fastlane/lib/fastlane/actions/get_managed_play_store_publishing_rights.rb', line 51

def self.return_value
  "An URI to obtain publishing rights for custom apps on Managed Play Store"
end

.run(params) ⇒ Object



4
5
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
# File 'fastlane/lib/fastlane/actions/get_managed_play_store_publishing_rights.rb', line 4

def self.run(params)
  unless params[:json_key] || params[:json_key_data]
    UI.important("To not be asked about this value, you can specify it using 'json_key'")
    json_key_path = UI.input("The service account json file used to authenticate with Google: ")
    json_key_path = File.expand_path(json_key_path)

    UI.user_error!("Could not find service account json file at path '#{json_key_path}'") unless File.exist?(json_key_path)
    params[:json_key] = json_key_path
  end

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

  if (keyfile = params[:json_key])
    json_key_data = File.open(keyfile, 'rb').read
  else
    json_key_data = params[:json_key_data]
  end

  # Login
  credentials = JSON.parse(json_key_data)
  callback_uri = 'https://fastlane.github.io/managed_google_play-callback/callback.html'
  require 'addressable/uri'
  continueUrl = Addressable::URI.encode(callback_uri)
  uri = "https://play.google.com/apps/publish/delegatePrivateApp?service_account=#{credentials['client_email']}&continueUrl=#{continueUrl}"

  UI.message("To obtain publishing rights for custom apps on Managed Play Store, open the following URL and log in:")
  UI.message("")
  UI.important(uri)
  UI.message("([Cmd/Ctrl] + [Left click] lets you open this URL in many consoles/terminals/shells)")
  UI.message("")
  UI.message("After successful login you will be redirected to a page which outputs some information that is required for usage of the `create_app_on_managed_play_store` action.")

  return uri
end