fastlane-plugin-appcircle_testing_distribution 0.1.5 → 0.1.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b6a0c80a1e6889f442eef2d0936349770ebc1ce097d3ca182c503d19b296b799
4
- data.tar.gz: 4b1f71d3e9256ed0a3d571fba78784535c4bced2b5036b52dc207c9bc919da04
3
+ metadata.gz: a02bb68865ce3d94c903651486aa0da0dd6ce65b1a031d49f9ae65dd1f280df3
4
+ data.tar.gz: 7cf9e84c39f8dac3db289e273d15b4b458baf1a3c3c8307e1fa04ae483dcda07
5
5
  SHA512:
6
- metadata.gz: 190efe4a6c0fe954500e2eed5701b90241e8c242d42c8b3c989ff1c7f8831c206f419486504b099042bb8f45c909f9d8f8d2577360a2ea5743d21cfe4c18095f
7
- data.tar.gz: 88fbca845051d596a62c710bc0bcceea39a98d930549f334cead5280bfbe1d4f3d3ca93f0811e8a8beda23bcfd1f0f0e92411ccab7e598fdfd9a214ab1309204
6
+ metadata.gz: 3c220a3b09805d02df2e3cab87bb4cb89714a00a27b598cfc83a51f61436b3ee84c709c4378effbf161fed1654b2fe2250dc95fcefff34a45c60896ed2a76c0e
7
+ data.tar.gz: 387fc503a7975c0f8fa3f021e4f5c466c79a8cdcc11b9c38669c932bfe7d96469bb53b6a8181c3fcb6059f160ade2612f306f74518ec407cf966dd938f814e97
@@ -1,4 +1,7 @@
1
1
  require 'fastlane/action'
2
+ require 'net/http'
3
+ require 'uri'
4
+ require 'json'
2
5
  require_relative '../helper/appcircle_testing_distribution_helper'
3
6
 
4
7
  module Fastlane
@@ -10,9 +13,19 @@ module Fastlane
10
13
  appPath = params[:appPath]
11
14
  message = params[:message]
12
15
 
16
+ if accessToken.nil?
17
+ raise UI.error("Access token is required to authenticate connections to Appcircle services. Please provide a valid access token")
18
+ elsif profileID.nil?
19
+ raise UI.error("Distribution profile ID is required to distribute applications. Please provide a valid distribution profile ID")
20
+ elsif appPath.nil?
21
+ raise UI.error("Application file path is required to distribute applications. Please provide a valid application file path")
22
+ elsif message.nil?
23
+ raise UI.error("Message field is required. Please provide a valid message")
24
+ end
25
+
26
+
13
27
  self.ac_login(accessToken)
14
28
  self.ac_upload(appPath, profileID, message)
15
-
16
29
  end
17
30
 
18
31
  def self.ac_login(accessToken)
@@ -23,10 +36,48 @@ module Fastlane
23
36
  raise "Error executing command of logging to Appcircle. Please make sure you have installed Appcircle CLI and provided a valid access token. For more information, please visit https://docs.appcircle.io/appcircle-api/api-authentication#generatingmanaging-the-personal-api-tokens #{ac_login}"
24
37
  end
25
38
  end
39
+
40
+ def self.checkTaskStatus(taskId)
41
+ uri = URI.parse("https://api.appcircle.io/task/v1/tasks/#{taskId}")
42
+ timeout = 1
43
+ jwtToken = `appcircle config get AC_ACCESS_TOKEN -o json`
44
+ apiAccessToken = JSON.parse(jwtToken)
45
+
46
+ response = self.send_request(uri, apiAccessToken["AC_ACCESS_TOKEN"])
47
+ if response.is_a?(Net::HTTPSuccess)
48
+ stateValue = JSON.parse(response.body)["stateValue"]
49
+
50
+ if stateValue == 1
51
+ sleep(1)
52
+ return checkTaskStatus(taskId)
53
+ end
54
+ if stateValue == 3
55
+ return true
56
+ else
57
+ UI.error("Task Id #{taskId} failed with state value #{stateValue}")
58
+ raise "Upload could not completed successfully"
59
+ end
60
+ else
61
+ UI.error("Request failed with response code #{response.code} and message #{response.message}")
62
+ raise "Request failed"
63
+ end
64
+ end
65
+
66
+ def self.send_request(uri, access_token)
67
+ http = Net::HTTP.new(uri.host, uri.port)
68
+ http.use_ssl = (uri.scheme == "https")
69
+ request = Net::HTTP::Get.new(uri.request_uri)
70
+ request["Authorization"] = "Bearer #{access_token}"
71
+ http.request(request)
72
+ end
26
73
 
27
74
  def self.ac_upload(appPath, profileID, message)
28
- ac_upload = `appcircle testing-distribution upload --app=#{appPath} --distProfileId=#{profileID} --message "#{message}"`;
29
- if $?.success?
75
+ ac_upload = `appcircle testing-distribution upload --app=#{appPath} --distProfileId=#{profileID} --message "#{message}" -o json`
76
+ taskId = JSON.parse(ac_upload)["taskId"]
77
+ UI.message("taskID #{taskId}")
78
+ result = self.checkTaskStatus(taskId)
79
+
80
+ if $?.success? and result
30
81
  UI.success("#{appPath} Uploaded to Appcircle successfully.")
31
82
  else
32
83
  raise "Error executing command of uploading to Appcircle. Please make sure you have provide the valid app path and distribution profile id. For more information\n" + ac_upload
@@ -53,28 +104,28 @@ module Fastlane
53
104
  def self.available_options
54
105
  [
55
106
  FastlaneCore::ConfigItem.new(key: :accessToken,
56
- env_name: "AC_ACCESS_TOKEN",
57
- description: "Provide the Appcircle access token to authenticate connections to Appcircle services. This token allows your Azure DevOps pipeline to interact with Appcircle for distributing applications",
58
- optional: false,
59
- type: String),
107
+ env_name: "AC_ACCESS_TOKEN",
108
+ description: "Provide the Appcircle access token to authenticate connections to Appcircle services",
109
+ optional: false,
110
+ type: String),
60
111
 
61
112
  FastlaneCore::ConfigItem.new(key: :profileID,
62
- env_name: "AC_PROFILE_ID",
63
- description: "Enter the ID of the Appcircle distribution profile. This ID uniquely identifies the profile under which your applications will be distributed",
64
- optional: false,
65
- type: String),
113
+ env_name: "AC_PROFILE_ID",
114
+ description: "Enter the ID of the Appcircle distribution profile. This ID uniquely identifies the profile under which your applications will be distributed",
115
+ optional: false,
116
+ type: String),
66
117
 
67
118
  FastlaneCore::ConfigItem.new(key: :appPath,
68
- env_name: "AC_APP_PATH",
69
- 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",
70
- optional: false,
71
- type: String),
72
-
119
+ env_name: "AC_APP_PATH",
120
+ 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",
121
+ optional: false,
122
+ type: String),
123
+
73
124
  FastlaneCore::ConfigItem.new(key: :message,
74
- env_name: "AC_MESSAGE",
75
- description: "Optional message to include with the distribution to provide additional information to testers or users receiving the build",
76
- optional: false,
77
- type: String),
125
+ env_name: "AC_MESSAGE",
126
+ description: "Optional message to include with the distribution to provide additional information to testers or users receiving the build",
127
+ optional: false,
128
+ type: String)
78
129
  ]
79
130
  end
80
131
 
@@ -1,5 +1,5 @@
1
1
  module Fastlane
2
2
  module AppcircleTestingDistribution
3
- VERSION = "0.1.5"
3
+ VERSION = "0.1.6"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fastlane-plugin-appcircle_testing_distribution
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.5
4
+ version: 0.1.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - appcircleio
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-06-12 00:00:00.000000000 Z
11
+ date: 2024-07-22 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description:
14
14
  email: cloud@appcircle.io