Class: Fastlane::Actions::HuaweiAppgalleryConnectAction

Inherits:
Action
  • Object
show all
Defined in:
lib/fastlane/plugin/huawei_appgallery_connect/actions/huawei_appgallery_connect_action.rb

Class Method Summary collapse

Class Method Details

.authorsObject



50
51
52
# File 'lib/fastlane/plugin/huawei_appgallery_connect/actions/huawei_appgallery_connect_action.rb', line 50

def self.authors
  ["Shreejan Shrestha"]
end

.available_optionsObject



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
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
# File 'lib/fastlane/plugin/huawei_appgallery_connect/actions/huawei_appgallery_connect_action.rb', line 63

def self.available_options
  [
    FastlaneCore::ConfigItem.new(key: :client_id,
                            env_name: "HUAWEI_APPGALLERY_CONNECT_CLIENT_ID",
                         description: "Huawei AppGallery Connect Client ID",
                            optional: false,
                                type: String),

    FastlaneCore::ConfigItem.new(key: :client_secret,
                               env_name: "HUAWEI_APPGALLERY_CONNECT_CLIENT_SECRET",
                               description: "Huawei AppGallery Connect Client Secret",
                               optional: false,
                               type: String),

    FastlaneCore::ConfigItem.new(key: :app_id,
                                 env_name: "HUAWEI_APPGALLERY_CONNECT_APP_ID",
                                 description: "Huawei AppGallery Connect App ID",
                                 optional: false,
                                 type: String),

    FastlaneCore::ConfigItem.new(key: :apk_path,
                                 env_name: "HUAWEI_APPGALLERY_CONNECT_APK_PATH",
                                 description: "Path to APK file for upload",
                                 optional: false,
                                 type: String),

    FastlaneCore::ConfigItem.new(key: :is_aab,
                                 env_name: "HUAWEI_APPGALLERY_CONNECT_IS_AAB",
                                 description: "Specify this to be true if you're uploading aab instead of apk",
                                 optional: true,
                                 type: Boolean),

    FastlaneCore::ConfigItem.new(key: :privacy_policy_url,
                                 env_name: "HUAWEI_APPGALLERY_CONNECT_PRIVACY_POLICY",
                                 description: "Privacy Policy URL",
                                 optional: true,
                                 type: String),

    FastlaneCore::ConfigItem.new(key: :changelog_path,
                                 env_name: "HUAWEI_APPGALLERY_CONNECT_CHANGELOG_PATH",
                                 description: "Path to Changelog file (Default empty)",
                                 optional: true,
                                 type: String),

    FastlaneCore::ConfigItem.new(key: :phase_wise_release,
                                 env_name: "HUAWEI_APPGALLERY_CONNECT_PHASE_WISE_RELEASE",
                                 description: "Phase wise release",
                                 optional: true,
                                 conflicting_options: [:release_time],
                                 type: Boolean),

    FastlaneCore::ConfigItem.new(key: :phase_release_start_time,
                                 env_name: "HUAWEI_APPGALLERY_CONNECT_PHASE_RELEASE_START_TIME",
                                 description: "Phase release start time in UTC format (yyyy-MM-dd'T'HH:mm:ssZZ)",
                                 optional: true,
                                 type: String),

    FastlaneCore::ConfigItem.new(key: :phase_release_end_time,
                                 env_name: "HUAWEI_APPGALLERY_CONNECT_PHASE_RELEASE_END_TIME",
                                 description: "Phase release end time in UTC format (yyyy-MM-dd'T'HH:mm:ssZZ)",
                                 optional: true,
                                 type: String),

    FastlaneCore::ConfigItem.new(key: :phase_release_percent,
                                 env_name: "HUAWEI_APPGALLERY_CONNECT_PHASE_RELEASE_PERCENT",
                                 description: "Percentage of phase release (0-100)",
                                 optional: true,
                                 type: String),

    FastlaneCore::ConfigItem.new(key: :phase_release_description,
                                 env_name: "HUAWEI_APPGALLERY_CONNECT_PHASE_RELEASE_DESCRIPTION",
                                 description: "Phase release description",
                                 optional: true,
                                 type: String),

    FastlaneCore::ConfigItem.new(key: :release_time,
                                 env_name: "HUAWEI_APPGALLERY_CONNECT_RELEASE_TIME",
                                 description: "Release time in UTC format for app release on a specific date (yyyy-MM-dd'T'HH:mm:ssZZ)",
                                 optional: true,
                                 conflicting_options: [:phase_wise_release],
                                 type: String),

    FastlaneCore::ConfigItem.new(key: :apk_lang,
                               env_name: "HUAWEI_APPGALLERY_CONNECT_APK_LANGUAGE",
                               description: "Language type. For details, please refer to https://developer.huawei.com/consumer/en/doc/development/AppGallery-connect-Guides/agcapi-reference-langtype",
                               optional: true,
                               type: String),

    FastlaneCore::ConfigItem.new(key: :submit_for_review,
                               env_name: "HUAWEI_APPGALLERY_SUBMIT_FOR_REVIEW",
                               description: "Should submit the app for review. The default value is true. If set false will only upload the app, and you can submit for review from the console",
                               optional: true,
                               type: Boolean),

    FastlaneCore::ConfigItem.new(key: :delay_before_submit_for_review,
                                 env_name: "HUAWEI_APPGALLERY_DELAY_BEFORE_REVIEW",
                                 description: "Delay before submitting the app for review. Default is 10 seconds. Change this to a higher value if you are having issues submitting the app for review",
                                 optional: true,
                                 type: Integer),

    FastlaneCore::ConfigItem.new(key: :package_ids,
                               env_name: "HUAWEI_APPGALLERY_PACKAGE_IDS",
                               description: "App Package IDs separated by commas",
                               optional: true,
                               type: String),

    # Open Testing Configuration
    FastlaneCore::ConfigItem.new(key: :use_testing_version,
                               env_name: "HUAWEI_APPGALLERY_USE_TESTING_VERSION",
                               description: "Enable open testing for the app",
                               optional: true,
                               default_value: false,
                               type: Boolean),

    FastlaneCore::ConfigItem.new(key: :skip_manual_review,
                               env_name: "HUAWEI_APPGALLERY_SKIP_MANUAL_REVIEW",
                               description: "Skip manual review for internal testing",
                               optional: true,
                               default_value: true,
                               type: Boolean),

    FastlaneCore::ConfigItem.new(key: :test_start_time,
                               env_name: "HUAWEI_APPGALLERY_TEST_START_TIME",
                               description: "Test start time in UTC format (yyyy-MM-dd'T'HH:mm:ssZZ). If not provided, defaults to 1 hour from now",
                               optional: true,
                               type: String),

    FastlaneCore::ConfigItem.new(key: :test_end_time,
                               env_name: "HUAWEI_APPGALLERY_TEST_END_TIME",
                               description: "Test end time in UTC format (yyyy-MM-dd'T'HH:mm:ssZZ). If not provided, defaults to 80 days from start time",
                               optional: true,
                               type: String),

    FastlaneCore::ConfigItem.new(key: :feedback_email,
                               env_name: "HUAWEI_APPGALLERY_FEEDBACK_EMAIL",
                               description: "Email address for test feedback",
                               optional: true,
                               type: String)
  ]
end

.descriptionObject



46
47
48
# File 'lib/fastlane/plugin/huawei_appgallery_connect/actions/huawei_appgallery_connect_action.rb', line 46

def self.description
  "Huawei AppGallery Connect Plugin"
end

.detailsObject



58
59
60
61
# File 'lib/fastlane/plugin/huawei_appgallery_connect/actions/huawei_appgallery_connect_action.rb', line 58

def self.details
  # Optional:
  "Fastlane plugin to upload Android app to Huawei AppGallery Connect"
end

.is_supported?(platform) ⇒ Boolean

Returns:

  • (Boolean)


204
205
206
207
# File 'lib/fastlane/plugin/huawei_appgallery_connect/actions/huawei_appgallery_connect_action.rb', line 204

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

.return_valueObject



54
55
56
# File 'lib/fastlane/plugin/huawei_appgallery_connect/actions/huawei_appgallery_connect_action.rb', line 54

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
23
24
25
26
27
# File 'lib/fastlane/plugin/huawei_appgallery_connect/actions/huawei_appgallery_connect_action.rb', line 7

def self.run(params)
  token = Helper::HuaweiAppgalleryConnectHelper.get_token(params[:client_id], params[:client_secret])

  if token.nil?
    UI.message("Cannot retrieve token, please check your client ID and client secret")
  else
    if params[:privacy_policy_url] != nil
      Helper::HuaweiAppgalleryConnectHelper.update_appinfo(params[:client_id], token, params[:app_id], params[:privacy_policy_url])
    end

    upload_app = Helper::HuaweiAppgalleryConnectHelper.upload_app(token, params[:client_id], params[:app_id], params[:apk_path], params[:is_aab])
    if params[:delay_before_submit_for_review] == nil
        UI.message("Waiting 10 seconds for upload to get processed...")
        sleep(10)
    else
       UI.message("Waiting #{params[:delay_before_submit_for_review]} seconds for upload to get processed...")
       sleep(params[:delay_before_submit_for_review])
    end
    self.submit_for_review(token, upload_app, params)
  end
end

.submit_for_review(token, upload_app, params) ⇒ Object



29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/fastlane/plugin/huawei_appgallery_connect/actions/huawei_appgallery_connect_action.rb', line 29

def self.submit_for_review(token, upload_app, params)
  if params[:is_aab] && upload_app["success"] == true && params[:submit_for_review] != false
    compilationStatus = Helper::HuaweiAppgalleryConnectHelper.query_aab_compilation_status(token, params, upload_app["pkgVersion"])
    if compilationStatus == 1
      UI.important("aab file is currently processing, waiting for 2 minutes...")
      sleep(120)
      self.submit_for_review(token, upload_app, params)
    elsif compilationStatus == 2
      Helper::HuaweiAppgalleryConnectHelper.submit_app_for_review(token, params)
    else
      UI.user_error!("Compilation of aab failed")
    end
  elsif upload_app["success"] == true && params[:submit_for_review] != false
    Helper::HuaweiAppgalleryConnectHelper.submit_app_for_review(token, params)
  end
end