Class: Fastlane::Actions::AppcircleEnterpriseAppStoreAction
- Inherits:
-
Action
- Object
- Action
- Fastlane::Actions::AppcircleEnterpriseAppStoreAction
- Defined in:
- lib/fastlane/plugin/appcircle_enterprise_app_store/actions/appcircle_enterprise_app_store_action.rb
Constant Summary collapse
- @@apiToken =
nil
Class Method Summary collapse
- .ac_login_with_pak(personalAccessKey) ⇒ Object
- .ac_login_with_pat(accessToken) ⇒ Object
- .authors ⇒ Object
- .available_options ⇒ Object
- .checkTaskStatus(taskId) ⇒ Object
- .description ⇒ Object
- .details ⇒ Object
- .is_supported?(platform) ⇒ Boolean
- .publishToStore(entProfileId, entVersionId, summary, releaseNote, publishType) ⇒ Object
- .return_value ⇒ Object
- .run(params) ⇒ Object
- .send_request(uri, access_token) ⇒ Object
- .uploadToProfile(appPath, summary, releaseNotes, publishType) ⇒ Object
Class Method Details
.ac_login_with_pak(personalAccessKey) ⇒ Object
69 70 71 72 73 74 75 76 77 78 |
# File 'lib/fastlane/plugin/appcircle_enterprise_app_store/actions/appcircle_enterprise_app_store_action.rb', line 69 def self.ac_login_with_pak(personalAccessKey) begin user = AuthService.get_ac_token_with_pak(personal_access_key: personalAccessKey) UI.success("Login is successful.") @@apiToken = user.accessToken rescue => e UI.error("Login failed: #{e.}") raise e end end |
.ac_login_with_pat(accessToken) ⇒ Object
58 59 60 61 62 63 64 65 66 67 |
# File 'lib/fastlane/plugin/appcircle_enterprise_app_store/actions/appcircle_enterprise_app_store_action.rb', line 58 def self.ac_login_with_pat(accessToken) begin user = AuthService.get_ac_token(pat: accessToken) UI.success("Login is successful.") @@apiToken = user.accessToken rescue => e UI.error("Login failed: #{e.}") raise e end end |
.authors ⇒ Object
154 155 156 |
# File 'lib/fastlane/plugin/appcircle_enterprise_app_store/actions/appcircle_enterprise_app_store_action.rb', line 154 def self. ["Guven Karanfil"] end |
.available_options ⇒ Object
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 203 204 205 |
# File 'lib/fastlane/plugin/appcircle_enterprise_app_store/actions/appcircle_enterprise_app_store_action.rb', line 167 def self. [ FastlaneCore::ConfigItem.new(key: :personalAPIToken, env_name: "AC_PERSONAL_API_TOKEN", description: "Provide Personal API Token to authenticate Appcircle services (use either personalAPIToken or personalAccessKey)", optional: true, type: String), FastlaneCore::ConfigItem.new(key: :personalAccessKey, env_name: "AC_PERSONAL_ACCESS_KEY", description: "Provide Personal Access Key to authenticate Appcircle services (use either personalAPIToken or personalAccessKey)", optional: true, type: String), FastlaneCore::ConfigItem.new(key: :appPath, env_name: "AC_APP_PATH", description: "Specify the path to your application file. For iOS, this can be a .ipa or .xcarchive file path. For Android, specify the .apk or .appbundle file path", optional: false, type: String), FastlaneCore::ConfigItem.new(key: :summary, env_name: "AC_SUMMARY", description: "Provide a summary for the application to be published. This summary will be displayed in the Appcircle Enterprise App Store", optional: false, type: String), FastlaneCore::ConfigItem.new(key: :releaseNotes, env_name: "AC_RELEASE_NOTES", description: "Provide release notes for the application to be published. These notes will be displayed in the Appcircle Enterprise App Store", optional: false, type: String), FastlaneCore::ConfigItem.new(key: :publishType, env_name: "AC_PUBLISH_TYPE", description: "Specify the publish type for the application. This can be 0: None, 1: Beta, 2: Live. Default is 0: None. For more information, provide the number of the publish type", optional: false, type: String), ] end |
.checkTaskStatus(taskId) ⇒ Object
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 |
# File 'lib/fastlane/plugin/appcircle_enterprise_app_store/actions/appcircle_enterprise_app_store_action.rb', line 81 def self.checkTaskStatus(taskId) uri = URI.parse("https://api.appcircle.io/task/v1/tasks/#{taskId}") timeout = 1 response = self.send_request(uri, @@apiToken) if response.is_a?(Net::HTTPSuccess) stateValue = JSON.parse(response.body)["stateValue"] if stateValue == 1 sleep(1) return checkTaskStatus(taskId) end if stateValue == 3 return true else taskStatus = { 0 => "Unknown", 1 => "Begin", 2 => "Canceled", 3 => 'Completed', } raise UI.error("#{taskId} id upload request failed with status #{taskStatus[stateValue]}.") end else "Upload failed with response code #{response.code} and message '#{response.}'" raise end end |
.description ⇒ Object
150 151 152 |
# File 'lib/fastlane/plugin/appcircle_enterprise_app_store/actions/appcircle_enterprise_app_store_action.rb', line 150 def self.description "Efficiently publish your apps to Appcircle Enterprise Store" end |
.details ⇒ Object
162 163 164 165 |
# File 'lib/fastlane/plugin/appcircle_enterprise_app_store/actions/appcircle_enterprise_app_store_action.rb', line 162 def self.details # Optional: "Appcircle Enterprise Mobile App Store is your own mobile app store for providing access to in-house apps with a customizable mobile storefront" end |
.is_supported?(platform) ⇒ Boolean
207 208 209 210 211 212 213 |
# File 'lib/fastlane/plugin/appcircle_enterprise_app_store/actions/appcircle_enterprise_app_store_action.rb', line 207 def self.is_supported?(platform) # Adjust this if your plugin only works for a particular platform (iOS vs. Android, for example) # See: https://docs.fastlane.tools/advanced/#control-configuration-by-lane-and-by-platform # # [:ios, :mac, :android].include?(platform) true end |
.publishToStore(entProfileId, entVersionId, summary, releaseNote, publishType) ⇒ Object
125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 |
# File 'lib/fastlane/plugin/appcircle_enterprise_app_store/actions/appcircle_enterprise_app_store_action.rb', line 125 def self.publishToStore(entProfileId, entVersionId, summary, releaseNote, publishType) begin = { auth_token: @@apiToken, ent_profile_id: entProfileId, ent_version_id: entVersionId, summary: summary, release_notes: releaseNote, publish_type: publishType } response = UploadService.publishVersion() rescue => e UI.error("App could not publish at Enterprise App Store. #{e&.response}") raise e end end |
.return_value ⇒ Object
158 159 160 |
# File 'lib/fastlane/plugin/appcircle_enterprise_app_store/actions/appcircle_enterprise_app_store_action.rb', line 158 def self.return_value # If your method provides a return value, you can describe here what it does end |
.run(params) ⇒ Object
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 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/fastlane/plugin/appcircle_enterprise_app_store/actions/appcircle_enterprise_app_store_action.rb', line 17 def self.run(params) personalAPIToken = params[:personalAPIToken] personalAccessKey = params[:personalAccessKey] appPath = params[:appPath] summary = params[:summary] releaseNotes = params[:releaseNotes] publishType = params[:publishType] valid_extensions = ['.apk', '.ipa'] file_extension = File.extname(appPath).downcase unless valid_extensions.include?(file_extension) raise "Invalid file extension: #{file_extension}. For Android, use .apk. For iOS, use .ipa." end if personalAPIToken.nil? && personalAccessKey.nil? raise UI.error("Please provide either Personal API Token (personalAPIToken) or Personal Access Key (personalAccessKey) to authenticate connections to Appcircle services") elsif !personalAPIToken.nil? && !personalAccessKey.nil? raise UI.error("Please provide only one authentication method: either Personal API Token (personalAPIToken) or Personal Access Key (personalAccessKey), not both") elsif appPath.nil? raise UI.error("Please specify the path to your application file. For iOS, this can be a .ipa or .xcarchive file path. For Android, specify the .apk or .appbundle file path") elsif summary.nil? raise UI.error("Please provide a summary for the application to be published. This summary will be displayed in the Appcircle Enterprise App Store") elsif releaseNotes.nil? raise UI.error("Please provide release notes for the application to be published. These notes will be displayed in the Appcircle Enterprise App Store") elsif publishType.nil? raise UI.error("Please specify the publish type for the application. This can be 0: None, 1: Beta, 2: Live. Default is 0: None. For more information, provide the number of the publish type") elsif publishType != "0" && publishType != "1" && publishType != "2" raise UI.error("Please provide a valid publish type. This can be 0: None, 1: Beta, 2: Live. Default is 0: None. For more information, provide the number of the publish type") end if !personalAPIToken.nil? self.ac_login_with_pat(personalAPIToken) else self.ac_login_with_pak(personalAccessKey) end self.uploadToProfile(appPath, summary, releaseNotes, publishType) end |
.send_request(uri, access_token) ⇒ Object
142 143 144 145 146 147 148 |
# File 'lib/fastlane/plugin/appcircle_enterprise_app_store/actions/appcircle_enterprise_app_store_action.rb', line 142 def self.send_request(uri, access_token) http = Net::HTTP.new(uri.host, uri.port) http.use_ssl = (uri.scheme == "https") request = Net::HTTP::Get.new(uri.request_uri) request["Authorization"] = "Bearer #{access_token}" http.request(request) end |
.uploadToProfile(appPath, summary, releaseNotes, publishType) ⇒ Object
110 111 112 113 114 115 116 117 118 119 120 121 122 123 |
# File 'lib/fastlane/plugin/appcircle_enterprise_app_store/actions/appcircle_enterprise_app_store_action.rb', line 110 def self.uploadToProfile(appPath, summary, releaseNotes, publishType) response = UploadService.upload_artifact(token: @@apiToken, app: appPath) result = self.checkTaskStatus(response["taskId"]) if result profileId = UploadService.getProfileId(authToken: @@apiToken) appVersions = UploadService.getAppVersions(auth_token: @@apiToken, entProfileId: profileId) appVersionId = UploadService.getVersionId(versionList: appVersions) if publishType != "0" self.publishToStore(profileId, appVersionId, summary, releaseNotes, publishType) end UI.success("#{appPath} uploaded to the Appcircle Enterprise Store successfully") end end |