fastlane-plugin-managed_google_play 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/LICENSE +21 -0
- data/README.md +107 -0
- data/lib/fastlane/plugin/managed_google_play.rb +104 -0
- data/lib/fastlane/plugin/managed_google_play/actions/create_app_on_managed_play_store.rb +194 -0
- data/lib/fastlane/plugin/managed_google_play/actions/get_managed_play_store_publishing_rights.rb +98 -0
- data/lib/fastlane/plugin/managed_google_play/actions/managed_google_play_action.rb +95 -0
- data/lib/fastlane/plugin/managed_google_play/helper/managed_google_play_helper.rb +16 -0
- data/lib/fastlane/plugin/managed_google_play/version.rb +5 -0
- metadata +177 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 2464af7721d3cd41b0a41d144721eff1e6576523
|
4
|
+
data.tar.gz: c378ffbaf1c1b5de839e5204cbcb57756377d0fc
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 51306fa67077cb5fd6c1eafed325922c1119fc73667105de6b1db5c2f0f09e6bc3d0deec4621b01ecaa83e4aec6ae25e2ca56d4981b2f858b1f2b157a790dec7
|
7
|
+
data.tar.gz: 3cf5b49e23e9d8c9fb3d287d063ee278c79c1ebcb2800a3cc87971d1ec23d96b35c14a6449f4b823c2de155bbaf3ab4174f2ec1138a6477404cedbdf82bfb1a2
|
data/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2018 Jan Piotrowski <piotrowski+github@gmail.com>
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
+
SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,107 @@
|
|
1
|
+
# managed_google_play plugin
|
2
|
+
|
3
|
+
[![fastlane Plugin Badge](https://rawcdn.githack.com/fastlane/fastlane/master/fastlane/assets/plugin-badge.svg)](https://rubygems.org/gems/fastlane-plugin-managed_google_play)
|
4
|
+
|
5
|
+
This [_fastlane_](https://github.com/fastlane/fastlane) plugin enables you to create Android apps on Managed Google Play.
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
Add this plugin to your project by running:
|
10
|
+
|
11
|
+
```bash
|
12
|
+
fastlane add_plugin managed_google_play
|
13
|
+
```
|
14
|
+
|
15
|
+
## About managed_google_play
|
16
|
+
|
17
|
+
The plugin `fastlane-plugin_managed_google_play` offers two actions to first enable custom apps for a user account (needed once) and then create such apps. Here is how to use it:
|
18
|
+
|
19
|
+
0. 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.
|
20
|
+
|
21
|
+
1. **Enable account to create and publish custom apps**
|
22
|
+
|
23
|
+
Manually run the `get_managed_play_store_publishing_rights` action on the command line in your project:
|
24
|
+
|
25
|
+
```shell
|
26
|
+
fastlane run get_managed_play_store_publishing_rights
|
27
|
+
```
|
28
|
+
|
29
|
+
It will ask for the `json_key` which you answer by pasting the full path of the private key file. 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 shortly.
|
30
|
+
|
31
|
+
Note: If your account is already enabled to create custom apps, you can of course skip this step. It only has to executed once for your account to be able to upload custom apps.
|
32
|
+
|
33
|
+
2. **Create custom app on Managed Play Store**
|
34
|
+
|
35
|
+
Now you can run the `create_app_on_managed_play_store` action.
|
36
|
+
|
37
|
+
```shell
|
38
|
+
fastlane run create_app_on_managed_play_store
|
39
|
+
```
|
40
|
+
|
41
|
+
This action will ask for the following parameters:
|
42
|
+
|
43
|
+
- `json_key` = Same file as before
|
44
|
+
- `developer_account_id` = Use the one you received in the previous step
|
45
|
+
- `app_title` = Your app's title
|
46
|
+
- `language` = Primary language in BCP 47 format, e.g. `en_US`
|
47
|
+
- `apk` = Path of your `.apk` file
|
48
|
+
|
49
|
+
Of course you can also create a lane using the action (if you will do it more than once for example), that could look like this:
|
50
|
+
|
51
|
+
```ruby
|
52
|
+
app_title = 'Your app title'
|
53
|
+
language = 'en_US'
|
54
|
+
apk = '/files/app-release.apk'
|
55
|
+
create_app_on_managed_play_store(
|
56
|
+
json_key: ENV['JSON_KEY_FILE'],
|
57
|
+
developer_account_id: ENV['DEVELOPER_ACCOUNT_ID'],
|
58
|
+
app_title: app_title,
|
59
|
+
language: language,
|
60
|
+
apk: apk
|
61
|
+
)
|
62
|
+
```
|
63
|
+
|
64
|
+
When the action is finished your app is created in the Google Play Console.
|
65
|
+
|
66
|
+
## Actions
|
67
|
+
|
68
|
+
### `get_managed_play_store_publishing_rights`
|
69
|
+
|
70
|
+
TODO document parameters
|
71
|
+
|
72
|
+
### `create_app_on_managed_play_store`
|
73
|
+
|
74
|
+
TODO document parameters
|
75
|
+
|
76
|
+
## Example
|
77
|
+
|
78
|
+
Check out the [example `Fastfile`](fastlane/Fastfile) to see how to use this plugin. Try it by cloning the repo, running `fastlane install_plugins` and `bundle exec fastlane test`.
|
79
|
+
|
80
|
+
## Run tests for this plugin
|
81
|
+
|
82
|
+
To run both the tests, and code style validation, run
|
83
|
+
|
84
|
+
```
|
85
|
+
rake
|
86
|
+
```
|
87
|
+
|
88
|
+
To automatically fix many of the styling issues, use
|
89
|
+
```
|
90
|
+
rubocop -a
|
91
|
+
```
|
92
|
+
|
93
|
+
## Issues and Feedback
|
94
|
+
|
95
|
+
For any other issues and feedback about this plugin, please submit it to this repository.
|
96
|
+
|
97
|
+
## Troubleshooting
|
98
|
+
|
99
|
+
If you have trouble using plugins, check out the [Plugins Troubleshooting](https://docs.fastlane.tools/plugins/plugins-troubleshooting/) guide.
|
100
|
+
|
101
|
+
## Using _fastlane_ Plugins
|
102
|
+
|
103
|
+
For more information about how the `fastlane` plugin system works, check out the [Plugins documentation](https://docs.fastlane.tools/plugins/create-plugin/).
|
104
|
+
|
105
|
+
## About _fastlane_
|
106
|
+
|
107
|
+
_fastlane_ is the easiest way to automate beta deployments and releases for your iOS and Android apps. To learn more, check out [fastlane.tools](https://fastlane.tools).
|
@@ -0,0 +1,104 @@
|
|
1
|
+
require 'fastlane/plugin/managed_google_play/version'
|
2
|
+
|
3
|
+
module Fastlane
|
4
|
+
module ManagedGooglePlay
|
5
|
+
# Return all .rb files inside the "actions" and "helper" directory
|
6
|
+
def self.all_classes
|
7
|
+
Dir[File.expand_path('**/{actions,helper}/*.rb', File.dirname(__FILE__))]
|
8
|
+
end
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
# By default we want to import all available actions and helpers
|
13
|
+
# A plugin can contain any number of actions and plugins
|
14
|
+
Fastlane::ManagedGooglePlay.all_classes.each do |current|
|
15
|
+
require current
|
16
|
+
end
|
17
|
+
|
18
|
+
# https://support.google.com/googleplay/android-developer/answer/3125566?hl=en => Add your own text translations & localized graphic assets => See available languages => replace `-` with `_`
|
19
|
+
# %w => https://stackoverflow.com/a/1274703/252627
|
20
|
+
class AvailableLanguages
|
21
|
+
def self.all_languages
|
22
|
+
%w[
|
23
|
+
af
|
24
|
+
am
|
25
|
+
ar
|
26
|
+
az_AZ
|
27
|
+
be
|
28
|
+
bg
|
29
|
+
bn_BD
|
30
|
+
ca
|
31
|
+
cs_CZ
|
32
|
+
da_DK
|
33
|
+
de_DE
|
34
|
+
el_GR
|
35
|
+
en_AU
|
36
|
+
en_CA
|
37
|
+
en_GB
|
38
|
+
en_IN
|
39
|
+
en_SG
|
40
|
+
en_US
|
41
|
+
en_ZA
|
42
|
+
es_419
|
43
|
+
es_ES
|
44
|
+
es_US
|
45
|
+
et
|
46
|
+
eu_ES
|
47
|
+
fa
|
48
|
+
fi_FI
|
49
|
+
fil
|
50
|
+
fr_CA
|
51
|
+
fr_FR
|
52
|
+
gl_ES
|
53
|
+
hi_IN
|
54
|
+
hr
|
55
|
+
hu_HU
|
56
|
+
hy_AM
|
57
|
+
id
|
58
|
+
is_IS
|
59
|
+
it_IT
|
60
|
+
iw_IL
|
61
|
+
ja_JP
|
62
|
+
ka_GE
|
63
|
+
km_KH
|
64
|
+
kn_IN
|
65
|
+
ko_KR
|
66
|
+
ky_KG
|
67
|
+
lo_LA
|
68
|
+
lt
|
69
|
+
lv
|
70
|
+
mk_MK
|
71
|
+
ml_IN
|
72
|
+
mn_MN
|
73
|
+
mr_IN
|
74
|
+
ms
|
75
|
+
ms_MY
|
76
|
+
my_MM
|
77
|
+
ne_NP
|
78
|
+
nl_NL
|
79
|
+
no_NO
|
80
|
+
pl_PL
|
81
|
+
pt_BR
|
82
|
+
pt_PT
|
83
|
+
rm
|
84
|
+
ro
|
85
|
+
ru_RU
|
86
|
+
si_LK
|
87
|
+
sk
|
88
|
+
sl
|
89
|
+
sr
|
90
|
+
sv_SE
|
91
|
+
sw
|
92
|
+
ta_IN
|
93
|
+
te_IN
|
94
|
+
th
|
95
|
+
tr_TR
|
96
|
+
uk
|
97
|
+
vi
|
98
|
+
zh_CN
|
99
|
+
zh_HK
|
100
|
+
zh_TW
|
101
|
+
zu
|
102
|
+
]
|
103
|
+
end
|
104
|
+
end
|
@@ -0,0 +1,194 @@
|
|
1
|
+
require 'fastlane/action'
|
2
|
+
require_relative '../helper/managed_google_play_helper'
|
3
|
+
|
4
|
+
module Fastlane
|
5
|
+
module Actions
|
6
|
+
class CreateAppOnManagedPlayStoreAction < Action
|
7
|
+
def self.run(params)
|
8
|
+
unless params[:json_key] || params[:json_key_data]
|
9
|
+
UI.important("To not be asked about this value, you can specify it using 'json_key'")
|
10
|
+
params[:json_key] = UI.input("The service account json file used to authenticate with Google: ")
|
11
|
+
end
|
12
|
+
|
13
|
+
FastlaneCore::PrintTable.print_values(
|
14
|
+
config: params,
|
15
|
+
mask_keys: [:json_key_data],
|
16
|
+
title: "Summary for CreateAppOnManagedPlayStoreAction" # TODO
|
17
|
+
)
|
18
|
+
|
19
|
+
require "google/apis/playcustomapp_v1"
|
20
|
+
|
21
|
+
# Auth Info
|
22
|
+
@keyfile = params[:json_key] # TODO json_key_data as alternative
|
23
|
+
@developer_account = params[:developer_account_id]
|
24
|
+
|
25
|
+
# App Info
|
26
|
+
@apk_path = params[:apk]
|
27
|
+
@app_title = params[:app_title]
|
28
|
+
@language_code = params[:language]
|
29
|
+
|
30
|
+
# login
|
31
|
+
scope = 'https://www.googleapis.com/auth/androidpublisher'
|
32
|
+
credentials = JSON.parse(File.open(@keyfile, 'rb').read)
|
33
|
+
auth_client = Signet::OAuth2::Client.new(
|
34
|
+
token_credential_uri: 'https://oauth2.googleapis.com/token',
|
35
|
+
audience: 'https://oauth2.googleapis.com/token',
|
36
|
+
scope: scope,
|
37
|
+
issuer: credentials['client_id'],
|
38
|
+
signing_key: OpenSSL::PKey::RSA.new(credentials['private_key'], nil)
|
39
|
+
)
|
40
|
+
UI.message('auth_client: ' + auth_client.inspect)
|
41
|
+
auth_client.fetch_access_token!
|
42
|
+
|
43
|
+
# service
|
44
|
+
play_custom_apps = Google::Apis::PlaycustomappV1::PlaycustomappService.new
|
45
|
+
play_custom_apps.authorization = auth_client
|
46
|
+
UI.message('play_custom_apps with auth: ' + play_custom_apps.inspect)
|
47
|
+
|
48
|
+
# app
|
49
|
+
custom_app = Google::Apis::PlaycustomappV1::CustomApp.new(title: @app_title, language_code: @language_code)
|
50
|
+
UI.message('custom_app: ' + custom_app.inspect)
|
51
|
+
|
52
|
+
# create app
|
53
|
+
returned = play_custom_apps.create_account_custom_app(
|
54
|
+
@developer_account,
|
55
|
+
custom_app,
|
56
|
+
upload_source: @apk_path
|
57
|
+
) do |created_app, error|
|
58
|
+
if error.nil?
|
59
|
+
puts("Success: #{created_app}.")
|
60
|
+
UI.success(created_app)
|
61
|
+
UI.success(created_app.inspect)
|
62
|
+
else
|
63
|
+
puts("Error: #{error}")
|
64
|
+
UI.error(error.inspect)
|
65
|
+
end
|
66
|
+
end
|
67
|
+
UI.message('returned: ' + returned.inspect)
|
68
|
+
end
|
69
|
+
|
70
|
+
def self.description
|
71
|
+
"Create Managed Google Play Apps"
|
72
|
+
end
|
73
|
+
|
74
|
+
def self.authors
|
75
|
+
["Jan Piotrowski"]
|
76
|
+
end
|
77
|
+
|
78
|
+
def self.return_value
|
79
|
+
# If your method provides a return value, you can describe here what it does
|
80
|
+
end
|
81
|
+
|
82
|
+
def self.details
|
83
|
+
# Optional:
|
84
|
+
"none yet"
|
85
|
+
end
|
86
|
+
|
87
|
+
def self.available_options
|
88
|
+
[
|
89
|
+
FastlaneCore::ConfigItem.new(
|
90
|
+
key: :json_key,
|
91
|
+
env_name: "SUPPLY_JSON_KEY", # TODO
|
92
|
+
short_option: "-j",
|
93
|
+
conflicting_options: [:json_key_data],
|
94
|
+
optional: true, # this shouldn't be optional but is until I find out how json_key OR json_key_data can be required
|
95
|
+
description: "The path to a file containing service account JSON, used to authenticate with Google",
|
96
|
+
code_gen_sensitive: true,
|
97
|
+
default_value: CredentialsManager::AppfileConfig.try_fetch_value(:json_key_file),
|
98
|
+
default_value_dynamic: true,
|
99
|
+
verify_block: proc do |value|
|
100
|
+
UI.user_error!("'#{value}' doesn't seem to be a JSON file") unless FastlaneCore::Helper.json_file?(File.expand_path(value))
|
101
|
+
UI.user_error!("Could not find service account json file at path '#{File.expand_path(value)}'") unless File.exist?(File.expand_path(value))
|
102
|
+
end
|
103
|
+
),
|
104
|
+
FastlaneCore::ConfigItem.new(
|
105
|
+
key: :json_key_data,
|
106
|
+
env_name: "SUPPLY_JSON_KEY_DATA", # TODO
|
107
|
+
short_option: "-c",
|
108
|
+
conflicting_options: [:json_key],
|
109
|
+
optional: true,
|
110
|
+
description: "The raw service account JSON data used to authenticate with Google",
|
111
|
+
code_gen_sensitive: true,
|
112
|
+
default_value: CredentialsManager::AppfileConfig.try_fetch_value(:json_key_data_raw),
|
113
|
+
default_value_dynamic: true,
|
114
|
+
verify_block: proc do |value|
|
115
|
+
begin
|
116
|
+
JSON.parse(value)
|
117
|
+
rescue JSON::ParserError
|
118
|
+
UI.user_error!("Could not parse service account json: JSON::ParseError")
|
119
|
+
end
|
120
|
+
end
|
121
|
+
),
|
122
|
+
# developer_account
|
123
|
+
FastlaneCore::ConfigItem.new(key: :developer_account_id,
|
124
|
+
short_option: "-k",
|
125
|
+
env_name: "PRODUCE_ITC_TEAM_ID", # TODO
|
126
|
+
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)",
|
127
|
+
optional: false,
|
128
|
+
is_string: false, # as we also allow integers, which we convert to strings anyway
|
129
|
+
code_gen_sensitive: true,
|
130
|
+
default_value: CredentialsManager::AppfileConfig.try_fetch_value(:developer_account_id),
|
131
|
+
default_value_dynamic: true,
|
132
|
+
verify_block: proc do |value|
|
133
|
+
raise UI.error("No Developer Account ID given, pass using `developer_account_id: 123456789`") if value.to_s.empty?
|
134
|
+
end),
|
135
|
+
FastlaneCore::ConfigItem.new(
|
136
|
+
key: :apk,
|
137
|
+
env_name: "SUPPLY_APK", # TODO
|
138
|
+
description: "Path to the APK file to upload",
|
139
|
+
short_option: "-b",
|
140
|
+
conflicting_options: [:apk_paths, :aab],
|
141
|
+
code_gen_sensitive: true,
|
142
|
+
default_value: Dir["*.apk"].last || Dir[File.join("app", "build", "outputs", "apk", "app-Release.apk")].last,
|
143
|
+
default_value_dynamic: true,
|
144
|
+
optional: true,
|
145
|
+
verify_block: proc do |value|
|
146
|
+
UI.user_error!("Could not find apk file at path '#{value}'") unless File.exist?(value)
|
147
|
+
UI.user_error!("apk file is not an apk") unless value.end_with?('.apk')
|
148
|
+
end
|
149
|
+
),
|
150
|
+
# title
|
151
|
+
FastlaneCore::ConfigItem.new(key: :app_title,
|
152
|
+
env_name: "PRODUCE_APP_NAME", # TODO
|
153
|
+
short_option: "-q",
|
154
|
+
description: "App Title",
|
155
|
+
optional: false,
|
156
|
+
verify_block: proc do |value|
|
157
|
+
raise UI.error("No App Title given, pass using `app_title: 'Title'`") if value.to_s.empty?
|
158
|
+
end),
|
159
|
+
# language
|
160
|
+
FastlaneCore::ConfigItem.new(key: :language,
|
161
|
+
short_option: "-m",
|
162
|
+
env_name: "PRODUCE_LANGUAGE", # TODO
|
163
|
+
description: "Default app language (e.g. 'en_US')",
|
164
|
+
default_value: "en_US",
|
165
|
+
optional: false,
|
166
|
+
verify_block: proc do |language|
|
167
|
+
unless AvailableLanguages.all_languages.include?(language)
|
168
|
+
UI.user_error!("Please enter one of available languages: #{AvailableLanguages.all_languages}")
|
169
|
+
end
|
170
|
+
end),
|
171
|
+
# copied from https://github.com/fastlane/fastlane/blob/2fec459d6f44a41eac1b086e8c181bd1669f7f5c/supply/lib/supply/options.rb#L193-L199
|
172
|
+
FastlaneCore::ConfigItem.new(key: :root_url,
|
173
|
+
env_name: "SUPPLY_ROOT_URL", # TODO
|
174
|
+
description: "Root URL for the Google Play API. The provided URL will be used for API calls in place of https://www.googleapis.com/", # TODO check if default is true
|
175
|
+
optional: true,
|
176
|
+
verify_block: proc do |value|
|
177
|
+
UI.user_error!("Could not parse URL '#{value}'") unless value =~ URI.regexp
|
178
|
+
end),
|
179
|
+
# copied from https://github.com/fastlane/fastlane/blob/2fec459d6f44a41eac1b086e8c181bd1669f7f5c/supply/lib/supply/options.rb#L206-L211
|
180
|
+
FastlaneCore::ConfigItem.new(key: :timeout,
|
181
|
+
env_name: "SUPPLY_TIMEOUT", # TODO
|
182
|
+
optional: true,
|
183
|
+
description: "Timeout for read, open, and send (in seconds)",
|
184
|
+
type: Integer,
|
185
|
+
default_value: 300)
|
186
|
+
]
|
187
|
+
end
|
188
|
+
|
189
|
+
def self.is_supported?(platform)
|
190
|
+
[:android].include?(platform)
|
191
|
+
end
|
192
|
+
end
|
193
|
+
end
|
194
|
+
end
|
data/lib/fastlane/plugin/managed_google_play/actions/get_managed_play_store_publishing_rights.rb
ADDED
@@ -0,0 +1,98 @@
|
|
1
|
+
require 'fastlane/action'
|
2
|
+
require_relative '../helper/managed_google_play_helper'
|
3
|
+
|
4
|
+
module Fastlane
|
5
|
+
module Actions
|
6
|
+
class GetManagedPlayStorePublishingRightsAction < Action
|
7
|
+
def self.run(params)
|
8
|
+
unless params[:json_key] || params[:json_key_data]
|
9
|
+
UI.important("To not be asked about this value, you can specify it using 'json_key'")
|
10
|
+
params[:json_key] = UI.input("The service account json file used to authenticate with Google: ")
|
11
|
+
end
|
12
|
+
|
13
|
+
FastlaneCore::PrintTable.print_values(
|
14
|
+
config: params,
|
15
|
+
mask_keys: [:json_key_data],
|
16
|
+
title: "Summary for GetManagedPlayStorePublishingRights" # TODO
|
17
|
+
)
|
18
|
+
|
19
|
+
@keyfile = params[:json_key] # TODO: json_key_data as alternative
|
20
|
+
|
21
|
+
# login
|
22
|
+
credentials = JSON.parse(File.open(@keyfile, 'rb').read)
|
23
|
+
# puts 'credentials: '+credentials.inspect
|
24
|
+
# puts 'email: ' + credentials['client_email']
|
25
|
+
|
26
|
+
callback_uri = 'https://janpio.github.io/fastlane-plugin-managed_google_play/callback.html'
|
27
|
+
uri = "https://play.google.com/apps/publish/delegatePrivateApp?service_account=#{credentials['client_email']}&continueUrl=#{URI.escape(callback_uri)}"
|
28
|
+
|
29
|
+
UI.message("To obtain publishing rights for custom apps on Managed Play Store, open the following URL and log in:")
|
30
|
+
UI.message("")
|
31
|
+
UI.important(uri)
|
32
|
+
UI.message("([Cmd/Ctrl] + [Left click] lets you open this URL in many consoles/terminals/shells)")
|
33
|
+
UI.message("")
|
34
|
+
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.")
|
35
|
+
end
|
36
|
+
|
37
|
+
def self.description
|
38
|
+
"Obtain publishing rights for custom apps on Managed Google Play Store"
|
39
|
+
end
|
40
|
+
|
41
|
+
def self.authors
|
42
|
+
["Jan Piotrowski"]
|
43
|
+
end
|
44
|
+
|
45
|
+
def self.return_value
|
46
|
+
# If your method provides a return value, you can describe here what it does
|
47
|
+
end
|
48
|
+
|
49
|
+
def self.details
|
50
|
+
# Optional:
|
51
|
+
"none yet"
|
52
|
+
end
|
53
|
+
|
54
|
+
def self.available_options
|
55
|
+
[
|
56
|
+
FastlaneCore::ConfigItem.new(
|
57
|
+
key: :json_key,
|
58
|
+
env_name: "SUPPLY_JSON_KEY", # TODO
|
59
|
+
short_option: "-j",
|
60
|
+
conflicting_options: [:json_key_data],
|
61
|
+
optional: true, # this shouldn't be optional but is until I find out how json_key OR json_key_data can be required
|
62
|
+
description: "The path to a file containing service account JSON, used to authenticate with Google",
|
63
|
+
code_gen_sensitive: true,
|
64
|
+
default_value: CredentialsManager::AppfileConfig.try_fetch_value(:json_key_file),
|
65
|
+
default_value_dynamic: true,
|
66
|
+
verify_block: proc do |value|
|
67
|
+
UI.user_error!("'#{value}' doesn't seem to be a JSON file") unless FastlaneCore::Helper.json_file?(File.expand_path(value))
|
68
|
+
UI.user_error!("Could not find service account json file at path '#{File.expand_path(value)}'") unless File.exist?(File.expand_path(value))
|
69
|
+
end
|
70
|
+
),
|
71
|
+
FastlaneCore::ConfigItem.new(
|
72
|
+
key: :json_key_data,
|
73
|
+
env_name: "SUPPLY_JSON_KEY_DATA", # TODO
|
74
|
+
short_option: "-c",
|
75
|
+
conflicting_options: [:json_key],
|
76
|
+
optional: true,
|
77
|
+
description: "The raw service account JSON data used to authenticate with Google",
|
78
|
+
code_gen_sensitive: true,
|
79
|
+
default_value: CredentialsManager::AppfileConfig.try_fetch_value(:json_key_data_raw),
|
80
|
+
default_value_dynamic: true,
|
81
|
+
verify_block: proc do |value|
|
82
|
+
begin
|
83
|
+
JSON.parse(value)
|
84
|
+
rescue JSON::ParserError
|
85
|
+
UI.user_error!("Could not parse service account json: JSON::ParseError")
|
86
|
+
end
|
87
|
+
end
|
88
|
+
)
|
89
|
+
|
90
|
+
]
|
91
|
+
end
|
92
|
+
|
93
|
+
def self.is_supported?(platform)
|
94
|
+
[:android].include?(platform)
|
95
|
+
end
|
96
|
+
end
|
97
|
+
end
|
98
|
+
end
|
@@ -0,0 +1,95 @@
|
|
1
|
+
require 'fastlane/action'
|
2
|
+
require_relative '../helper/managed_google_play_helper'
|
3
|
+
|
4
|
+
module Fastlane
|
5
|
+
module Actions
|
6
|
+
class ManagedGooglePlayAction < Action
|
7
|
+
def self.run(params)
|
8
|
+
require "google/apis/playcustomapp_v1"
|
9
|
+
|
10
|
+
# Auth Info
|
11
|
+
@keyfile = ENV['KEYFILE_PATH']
|
12
|
+
@developer_account = ENV['DEVELOPER_ACCOUNT']
|
13
|
+
|
14
|
+
# App Info
|
15
|
+
@apk_path = "artifacts/app-release.apk"
|
16
|
+
@app_title = "App title!"
|
17
|
+
@language_code = "en_US"
|
18
|
+
|
19
|
+
# login
|
20
|
+
scope = 'https://www.googleapis.com/auth/androidpublisher'
|
21
|
+
credentials = JSON.parse(File.open(@keyfile, 'rb').read)
|
22
|
+
auth_client = Signet::OAuth2::Client.new(
|
23
|
+
token_credential_uri: 'https://oauth2.googleapis.com/token',
|
24
|
+
audience: 'https://oauth2.googleapis.com/token',
|
25
|
+
scope: scope,
|
26
|
+
issuer: credentials['client_id'],
|
27
|
+
signing_key: OpenSSL::PKey::RSA.new(credentials['private_key'], nil)
|
28
|
+
)
|
29
|
+
UI.message('auth_client: ' + auth_client.inspect)
|
30
|
+
auth_client.fetch_access_token!
|
31
|
+
|
32
|
+
# service
|
33
|
+
play_custom_apps = Google::Apis::PlaycustomappV1::PlaycustomappService.new
|
34
|
+
play_custom_apps.authorization = auth_client
|
35
|
+
UI.message('play_custom_apps with auth: ' + play_custom_apps.inspect)
|
36
|
+
|
37
|
+
# app
|
38
|
+
custom_app = Google::Apis::PlaycustomappV1::CustomApp.new(title: @app_title, language_code: @language_code)
|
39
|
+
UI.message('custom_app: ' + custom_app.inspect)
|
40
|
+
|
41
|
+
# create app
|
42
|
+
returned = play_custom_apps.create_account_custom_app(
|
43
|
+
@developer_account,
|
44
|
+
custom_app,
|
45
|
+
upload_source: nil # ,
|
46
|
+
# upload_source: @apk_path,
|
47
|
+
) do |created_app, error|
|
48
|
+
if error.nil?
|
49
|
+
puts("Success: #{created_app}.")
|
50
|
+
UI.success(created_app)
|
51
|
+
else
|
52
|
+
puts("Error: #{error}")
|
53
|
+
UI.error(error.inspect)
|
54
|
+
end
|
55
|
+
end
|
56
|
+
UI.message('returned: ' + returned.inspect)
|
57
|
+
end
|
58
|
+
|
59
|
+
def self.description
|
60
|
+
"Create Managed Google Play Apps"
|
61
|
+
end
|
62
|
+
|
63
|
+
def self.authors
|
64
|
+
["Jan Piotrowski"]
|
65
|
+
end
|
66
|
+
|
67
|
+
def self.return_value
|
68
|
+
# If your method provides a return value, you can describe here what it does
|
69
|
+
end
|
70
|
+
|
71
|
+
def self.details
|
72
|
+
# Optional:
|
73
|
+
"none yet"
|
74
|
+
end
|
75
|
+
|
76
|
+
def self.available_options
|
77
|
+
[
|
78
|
+
# FastlaneCore::ConfigItem.new(key: :your_option,
|
79
|
+
# env_name: "MANAGED_GOOGLE_PLAY_YOUR_OPTION",
|
80
|
+
# description: "A description of your option",
|
81
|
+
# optional: false,
|
82
|
+
# type: String)
|
83
|
+
]
|
84
|
+
end
|
85
|
+
|
86
|
+
def self.is_supported?(platform)
|
87
|
+
# Adjust this if your plugin only works for a particular platform (iOS vs. Android, for example)
|
88
|
+
# See: https://docs.fastlane.tools/advanced/#control-configuration-by-lane-and-by-platform
|
89
|
+
#
|
90
|
+
# [:ios, :mac, :android].include?(platform)
|
91
|
+
true
|
92
|
+
end
|
93
|
+
end
|
94
|
+
end
|
95
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
require 'fastlane_core/ui/ui'
|
2
|
+
|
3
|
+
module Fastlane
|
4
|
+
UI = FastlaneCore::UI unless Fastlane.const_defined?("UI")
|
5
|
+
|
6
|
+
module Helper
|
7
|
+
class ManagedGooglePlayHelper
|
8
|
+
# class methods that you define here become available in your action
|
9
|
+
# as `Helper::ManagedGooglePlayHelper.your_method`
|
10
|
+
#
|
11
|
+
def self.show_message
|
12
|
+
UI.message("Hello from the managed_google_play plugin helper!")
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
metadata
ADDED
@@ -0,0 +1,177 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: fastlane-plugin-managed_google_play
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Jan Piotrowski
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2018-08-27 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: pry
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: bundler
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rspec
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rspec_junit_formatter
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rake
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: rubocop
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - '='
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: 0.49.1
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - '='
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: 0.49.1
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: rubocop-require_tools
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - ">="
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0'
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - ">="
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0'
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: simplecov
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - ">="
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '0'
|
118
|
+
type: :development
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - ">="
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '0'
|
125
|
+
- !ruby/object:Gem::Dependency
|
126
|
+
name: fastlane
|
127
|
+
requirement: !ruby/object:Gem::Requirement
|
128
|
+
requirements:
|
129
|
+
- - ">="
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
version: 2.102.0
|
132
|
+
type: :development
|
133
|
+
prerelease: false
|
134
|
+
version_requirements: !ruby/object:Gem::Requirement
|
135
|
+
requirements:
|
136
|
+
- - ">="
|
137
|
+
- !ruby/object:Gem::Version
|
138
|
+
version: 2.102.0
|
139
|
+
description:
|
140
|
+
email: piotrowski+github@gmail.com
|
141
|
+
executables: []
|
142
|
+
extensions: []
|
143
|
+
extra_rdoc_files: []
|
144
|
+
files:
|
145
|
+
- LICENSE
|
146
|
+
- README.md
|
147
|
+
- lib/fastlane/plugin/managed_google_play.rb
|
148
|
+
- lib/fastlane/plugin/managed_google_play/actions/create_app_on_managed_play_store.rb
|
149
|
+
- lib/fastlane/plugin/managed_google_play/actions/get_managed_play_store_publishing_rights.rb
|
150
|
+
- lib/fastlane/plugin/managed_google_play/actions/managed_google_play_action.rb
|
151
|
+
- lib/fastlane/plugin/managed_google_play/helper/managed_google_play_helper.rb
|
152
|
+
- lib/fastlane/plugin/managed_google_play/version.rb
|
153
|
+
homepage: https://github.com/janpio/fastlane-plugin-managed_google_play
|
154
|
+
licenses:
|
155
|
+
- MIT
|
156
|
+
metadata: {}
|
157
|
+
post_install_message:
|
158
|
+
rdoc_options: []
|
159
|
+
require_paths:
|
160
|
+
- lib
|
161
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
162
|
+
requirements:
|
163
|
+
- - ">="
|
164
|
+
- !ruby/object:Gem::Version
|
165
|
+
version: '0'
|
166
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
167
|
+
requirements:
|
168
|
+
- - ">="
|
169
|
+
- !ruby/object:Gem::Version
|
170
|
+
version: '0'
|
171
|
+
requirements: []
|
172
|
+
rubyforge_project:
|
173
|
+
rubygems_version: 2.6.14.1
|
174
|
+
signing_key:
|
175
|
+
specification_version: 4
|
176
|
+
summary: Create Managed Google Play Apps
|
177
|
+
test_files: []
|