fastlane-plugin-amazon_app_submission 0.3.0 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f52eed564ae7f2ef5d42738c00c3f45a71e0438cb63b6bcad67b53f0c646562b
4
- data.tar.gz: 623727ff4a80c261d9ff34c28b012b2c2f067295eabdb3cf40ee2dbbc1f0e40c
3
+ metadata.gz: e0e6f5db2e79b36447f13ff25a3e8f8573cbdd273578ed7ede2f645f4a534b33
4
+ data.tar.gz: c76ce77ad9e439cf5d68a8b672c8e714488f5606f2cd27ff2958ba551a2d4e2a
5
5
  SHA512:
6
- metadata.gz: c9e84b1862121a03660d78b7fdcd5c0a45290982f5e5e8fd1a5b76bdfc37dfa199c9f03c9c7262cf262e6fdb7a0ac6b3cf6633244f93e937acde4494d8ccdfa9
7
- data.tar.gz: d345f6b63c462c4510edc2df6e9aa3957711abf93e83f58f022c8742117fe9bc6db8ebd920a94568dcbd3c9c7c461eb9e25a57ac3b5fa698cae8b5d2bf479140
6
+ metadata.gz: 3996ee47b85cb300b2d5ea07216960aa7fce672ff0dab042216018d83895b127f50b04bff9dcac283a2766a3ae3b17bd4ce475b21ba23a687d88f30313c06211
7
+ data.tar.gz: a9ebb48964cade0bfa36a415a888629ee51710575b99baf731bffffaab9e580ddf5f0ea6107c34803c1283473f6a1e6ceff15f940aabc90215df3f5201998bbf
data/README.md CHANGED
@@ -28,21 +28,23 @@ Call `amazon_app_submission` in your Fastfile.
28
28
  client_id: "<CLIENT_ID>",
29
29
  client_secret: "<CLIENT_SECRET>",
30
30
  app_id: "<APP_ID>",
31
- apk_path: "<APK_PATH>",
32
31
  # Optional
33
- changelogs_folder_path: "<CHANGELOG_PATH>",
32
+ apk_path: "<APK_PATH>",
33
+ upload_apk: true,
34
+ changelogs_path: "<CHANGELOG_PATH>",
34
35
  upload_changelogs: false,
35
36
  submit_for_review: false
36
37
  )
37
38
  ```
38
39
 
39
- | param | default value | optional | description
40
+ | param | default value | optional | description
40
41
  |:----------|:-----------:|:-----------:|:-----------:|
41
- client_id | - | false | getting client id from Amazon developer console dashboard
42
- client_secret | - | false | getting client secret from Amazon developer console dashboard
43
- app_id | - | false | getting app id from Amazon developer console dashboard
44
- apk_path | - | false | link where you storing the release apk
45
- changelogs_folder_path | "" | true | setting the folder path where you have the change logs with different file for each language, if language file not found it will use default.txt
42
+ client_id | - | false | getting client id from Amazon developer console dashboard
43
+ client_secret | - | false | getting client secret from Amazon developer console dashboard
44
+ app_id | - | false | getting app id from Amazon developer console dashboard
45
+ apk_path | - | true | link where you storing the release apk
46
+ upload_apk | true | true | set this to false to not upload an apk. can be used to only upload changelogs
47
+ changelogs_path | "" | true | setting the folder path where you have the change logs with different file for each language, if language file not found it will use default.txt
46
48
  upload_changelogs | false | true | updating the change logs for the upcoming version
47
49
  submit_for_review | false | true | submit the uploaded APK to the store
48
50
 
@@ -60,9 +62,9 @@ Spanish | es-ES.txt
60
62
  Spanish-Mexican | es-MX.txt
61
63
  Other | default.txt
62
64
 
63
- ## Testing
65
+ ## Testing
64
66
 
65
- For testing the plugin locally you have to get `client_id`, `client_secret`, `app_id` and `apk_path` in fastlane/Fastfile
67
+ For testing the plugin locally you have to get `client_id`, `client_secret`, `app_id` and `apk_path` in fastlane/Fastfile
66
68
  please check Usage step to see how you can get them.
67
69
 
68
70
  Then call `bundle exec fastlane test` in your terminal
@@ -11,49 +11,58 @@ module Fastlane
11
11
 
12
12
  if token.nil?
13
13
  UI.message("Cannot retrieve token, please check your client ID and client secret")
14
- end
14
+ end
15
15
 
16
16
  UI.message("Getting current edit")
17
17
  current_edit_id, edit_eTag = Helper::AmazonAppSubmissionHelper.open_edit(token, params[:app_id])
18
-
18
+
19
19
  if current_edit_id.nil?
20
20
  UI.message("Current edit not found, creating a new edit")
21
21
  Helper::AmazonAppSubmissionHelper.create_new_edit(token, params[:app_id])
22
22
  current_edit_id, edit_eTag = Helper::AmazonAppSubmissionHelper.open_edit(token, params[:app_id])
23
23
  end
24
-
25
- UI.message("Get current apk id")
26
- current_apk_id = Helper::AmazonAppSubmissionHelper.get_current_apk_id(token, params[:app_id], current_edit_id)
27
24
 
28
- UI.message("Get current apk ETag")
29
- current_apk_eTag = Helper::AmazonAppSubmissionHelper.get_current_apk_etag(token, params[:app_id], current_edit_id, current_apk_id)
25
+ if current_edit_id.nil?
26
+ UI.error("Creating new edit failed!")
27
+ return
28
+ end
29
+
30
+ if params[:upload_apk]
31
+ UI.message("Get current apk id")
32
+ current_apk_id = Helper::AmazonAppSubmissionHelper.get_current_apk_id(token, params[:app_id], current_edit_id)
30
33
 
31
- UI.message("Replacing the apk with ETag #{current_apk_eTag}")
32
- replace_apk_response_code, replace_apk_response = Helper::AmazonAppSubmissionHelper.replaceExistingApk(token, params[:app_id], current_edit_id, current_apk_id, current_apk_eTag, params[:apk_path])
34
+ UI.message("Get current apk ETag")
35
+ current_apk_eTag = Helper::AmazonAppSubmissionHelper.get_current_apk_etag(token, params[:app_id], current_edit_id, current_apk_id)
36
+
37
+ UI.message("Replacing the apk with apk from #{params[:apk_path]}")
38
+ replace_apk_response_code, replace_apk_response = Helper::AmazonAppSubmissionHelper.replaceExistingApk(token, params[:app_id], current_edit_id, current_apk_id, current_apk_eTag, params[:apk_path])
39
+ end
33
40
 
34
41
  if params[:upload_changelogs]
35
42
  UI.message("Updating the changelogs")
36
43
  Helper::AmazonAppSubmissionHelper.update_listings( token, params[:app_id],current_edit_id, params[:changelogs_path], params[:changelogs_path])
37
44
  end
38
-
39
- if replace_apk_response_code == '200'
40
- if params[:submit_for_review]
41
- UI.message("Submitting to Amazon app store")
42
- Helper::AmazonAppSubmissionHelper.commit_edit(token, params[:app_id], current_edit_id, edit_eTag)
43
- end
44
- else
45
- UI.message("Amazon app submission failed at replacing the apk error code #{replace_apk_response_code} and error respones #{replace_apk_response}")
46
- return
45
+
46
+ if params[:upload_apk]
47
+ if replace_apk_response_code == '200'
48
+ if params[:submit_for_review]
49
+ UI.message("Submitting to Amazon app store")
50
+ Helper::AmazonAppSubmissionHelper.commit_edit(token, params[:app_id], current_edit_id, edit_eTag)
51
+ end
52
+ else
53
+ UI.message("Amazon app submission failed at replacing the apk error code #{replace_apk_response_code} and error respones #{replace_apk_response}")
54
+ return
55
+ end
47
56
  end
48
57
  UI.message("Amazon app submission finished successfully!")
49
58
  end
50
59
 
51
60
  def self.description
52
- "fast-lane plugin for Amazon App Submissions"
61
+ "Fastlane plugin for Amazon App Submissions"
53
62
  end
54
63
 
55
64
  def self.authors
56
- ["mohammedhemaid"]
65
+ ["mohammedhemaid", "saschagraeff"]
57
66
  end
58
67
 
59
68
  def self.return_value
@@ -62,7 +71,7 @@ module Fastlane
62
71
 
63
72
  def self.details
64
73
  # Optional:
65
- "fast-lane plugin for Amazon App Submissions"
74
+ "Fastlane plugin for Amazon App Submissions"
66
75
  end
67
76
 
68
77
  def self.available_options
@@ -72,7 +81,7 @@ module Fastlane
72
81
  description: "Amazon App Submission Client ID",
73
82
  optional: false,
74
83
  type: String),
75
-
84
+
76
85
  FastlaneCore::ConfigItem.new(key: :client_secret,
77
86
  env_name: "AMAZON_APP_SUBMISSION_CLIENT_SECRET",
78
87
  description: "Amazon App Submission Client Secret",
@@ -85,10 +94,18 @@ module Fastlane
85
94
  optional: false,
86
95
  type: String),
87
96
 
97
+ FastlaneCore::ConfigItem.new(key: :upload_apk,
98
+ env_name: "AMAZON_APP_SUBMISSION_UPLOAD_APK",
99
+ description: "Amazon App Submission upload apk file",
100
+ default_value: true,
101
+ optional: true,
102
+ type: Boolean),
103
+
88
104
  FastlaneCore::ConfigItem.new(key: :apk_path,
89
105
  env_name: "AMAZON_APP_SUBMISSION_APK_PATH",
90
106
  description: "Amazon App Submission APK Path",
91
- optional: false,
107
+ default_value: "",
108
+ optional: true,
92
109
  type: String),
93
110
 
94
111
  FastlaneCore::ConfigItem.new(key: :changelogs_path,
@@ -100,17 +117,17 @@ module Fastlane
100
117
 
101
118
  FastlaneCore::ConfigItem.new(key: :upload_changelogs,
102
119
  env_name: "AMAZON_APP_SUBMISSION_SKIP_UPLOAD_CHANGELOGS",
103
- description: "Amazon App Submission skip upload changelogs",
120
+ description: "Amazon App Submission upload changelogs",
104
121
  default_value: false,
105
122
  optional: true,
106
- type: Boolean),
123
+ type: Boolean),
107
124
 
108
125
  FastlaneCore::ConfigItem.new(key: :submit_for_review,
109
126
  env_name: "AMAZON_APP_SUBMISSION_SUBMIT_FOR_REVIEW",
110
127
  description: "Amazon App Submission submit for review",
111
128
  default_value: false,
112
129
  optional: true,
113
- type: Boolean)
130
+ type: Boolean)
114
131
 
115
132
  # FastlaneCore::ConfigItem.new(key: :your_option,
116
133
  # env_name: "AMAZON_APP_SUBMISSION_YOUR_OPTION",
@@ -23,12 +23,16 @@ module Fastlane
23
23
  res = http.request(req)
24
24
  result_json = JSON.parse(res.body)
25
25
  auth_token = "Bearer #{result_json['access_token']}"
26
-
26
+
27
+ if result_json['error'] == 'invalid_scope'
28
+ UI.message("It seems that the provided security profile is not attached to the App Submission API")
29
+ end
30
+
27
31
  return auth_token
28
32
  end
29
33
 
30
34
  def self.create_new_edit(token, app_id)
31
-
35
+
32
36
  create_edit_path = "/v1/applications/#{app_id}/edits"
33
37
  create_edit_url = BASE_URL + create_edit_path
34
38
 
@@ -43,12 +47,12 @@ module Fastlane
43
47
 
44
48
  res = http.request(req)
45
49
  current_edit = JSON.parse(res.body)
46
-
50
+
47
51
  return current_edit['id']
48
52
  end
49
-
53
+
50
54
  def self.open_edit(token, app_id)
51
-
55
+
52
56
  get_edit_path = "/v1/applications/#{app_id}/edits"
53
57
  get_edit_url = BASE_URL + get_edit_path
54
58
 
@@ -82,11 +86,11 @@ module Fastlane
82
86
  )
83
87
 
84
88
  res = http.request(req)
85
- if !res.body.nil?
86
- apks = JSON.parse(res.body)
87
- firstAPK = apks[0]
88
- apk_id = firstAPK['id']
89
- return apk_id
89
+ if !res.body.nil?
90
+ apks = JSON.parse(res.body)
91
+ firstAPK = apks.kind_of?(Array) ? apks[0] : apks
92
+ apk_id = firstAPK['id']
93
+ return apk_id
90
94
  end
91
95
  end
92
96
 
@@ -112,7 +116,7 @@ module Fastlane
112
116
 
113
117
  replace_apk_path = "/v1/applications/#{app_id}/edits/#{edit_id}/apks/#{apk_id}/replace"
114
118
  local_apk = File.open(apk_path, "r").read
115
-
119
+
116
120
  apk_uri = URI.parse(apk_path)
117
121
  apk_name = apk_uri.path.split('/').last
118
122
 
@@ -143,7 +147,7 @@ module Fastlane
143
147
 
144
148
  def self.delete_apk(token, app_id, edit_id, apk_id, eTag)
145
149
 
146
- delete_apk_path = "/v1/applications/#{app_id}/edits/#{edit_id}/apks/#{apk_id}"
150
+ delete_apk_path = "/v1/applications/#{app_id}/edits/#{edit_id}/apks/#{apk_id}"
147
151
  delete_apk_url = BASE_URL + delete_apk_path
148
152
 
149
153
  uri = URI(delete_apk_url)
@@ -162,7 +166,7 @@ module Fastlane
162
166
 
163
167
  def self.uploadNewApk(token, app_id, edit_id, apk_path)
164
168
 
165
- add_apk_path = "/v1/applications/#{app_id}/edits/#{edit_id}/apks/upload"
169
+ add_apk_path = "/v1/applications/#{app_id}/edits/#{edit_id}/apks/upload"
166
170
  add_apk_url = BASE_URL + add_apk_path
167
171
  local_apk = File.open(apk_path, 'r').read
168
172
 
@@ -203,7 +207,7 @@ module Fastlane
203
207
  listings_response['listings'].each do |lang, listing|
204
208
  lang_path = "/v1/applications/#{app_id}/edits/#{edit_id}/listings/#{lang}"
205
209
  lang_url = BASE_URL + lang_path
206
-
210
+
207
211
  uri = URI(lang_url)
208
212
  http = Net::HTTP.new(uri.host, uri.port)
209
213
  http.use_ssl = true
@@ -225,7 +229,7 @@ module Fastlane
225
229
 
226
230
  update_listings_path = "/v1/applications/#{app_id}/edits/#{edit_id}/listings/#{lang}"
227
231
  update_listings_url = BASE_URL + update_listings_path
228
-
232
+
229
233
  uri = URI(update_listings_url)
230
234
  http = Net::HTTP.new(uri.host, uri.port)
231
235
  http.use_ssl = true
@@ -235,7 +239,7 @@ module Fastlane
235
239
  'Content-Type' => 'application/json',
236
240
  'If-Match' => etag
237
241
  )
238
-
242
+
239
243
  req.body = listing.to_json
240
244
  res = http.request(req)
241
245
  listings_response = JSON.parse(res.body)
@@ -264,7 +268,7 @@ module Fastlane
264
268
 
265
269
  def self.commit_edit(token, app_id, edit_id, eTag)
266
270
 
267
- commit_edit_path = "/v1/applications/#{app_id}/edits/#{edit_id}/commit"
271
+ commit_edit_path = "/v1/applications/#{app_id}/edits/#{edit_id}/commit"
268
272
  commit_edit_url = BASE_URL + commit_edit_path
269
273
 
270
274
  uri = URI(commit_edit_url)
@@ -1,5 +1,5 @@
1
1
  module Fastlane
2
2
  module AmazonAppSubmission
3
- VERSION = "0.3.0"
3
+ VERSION = "0.4.0"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fastlane-plugin-amazon_app_submission
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - mohammedhemaid
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-06-13 00:00:00.000000000 Z
11
+ date: 2022-09-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler