fastlane-plugin-appcircle_enterprise_app_store 0.1.1.beta.1 → 0.2.0.beta.1
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 +4 -4
- data/README.md +24 -3
- data/lib/fastlane/plugin/appcircle_enterprise_app_store/actions/appcircle_enterprise_app_store_action.rb +33 -2
- data/lib/fastlane/plugin/appcircle_enterprise_app_store/helper/auth_service.rb +75 -3
- data/lib/fastlane/plugin/appcircle_enterprise_app_store/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: f076cd7ebd5cb43899b15c3c6761e14a2613249e80f531489c53b5dc12429f69
|
|
4
|
+
data.tar.gz: ebd42c4b8fa00f2b4dab0be761e9619a2e8e3673a768de0164c480e206b9bdcb
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 7c42be368afb1f91f78f12c85246c07f72c2bbc6d4ef4af407a543a9e7c307b7cf7fe56425f922bd6ddd987ae90d200d825d0913990ec3aa5e72f4f1b4c57c4c
|
|
7
|
+
data.tar.gz: cc1cb9459a4655ec4387e6aeda6b626cf48e4bddf072e54dfa6c64178746c9214785e3b42f55113f03b0f95aaa397d6f4053e026aaaf4913503df7fcaa62602d
|
data/README.md
CHANGED
|
@@ -51,9 +51,9 @@ Note: We currently support **Appcircle Cloud**, with **self-hosted** support pla
|
|
|
51
51
|
|
|
52
52
|
To generate a Personal API Token:
|
|
53
53
|
|
|
54
|
-
1.
|
|
55
|
-
2.
|
|
56
|
-
3.
|
|
54
|
+
1. In the left sidebar, go to **Organization** > **Security**.
|
|
55
|
+
2. Find the **Personal access key** section.
|
|
56
|
+
3. Select **Generate key** to generate your token.
|
|
57
57
|
|
|
58
58
|

|
|
59
59
|
|
|
@@ -80,6 +80,7 @@ After adding the plugin to your project, configure your Fastfile as follows:
|
|
|
80
80
|
```
|
|
81
81
|
|
|
82
82
|
- `personalAPIToken` / `personalAccessKey`: Provide exactly one to authenticate with Appcircle services. Providing both, or neither, fails with a descriptive error.
|
|
83
|
+
- `subOrganizationName` (optional): Sub-organization name of the target enterprise app store profile. See [Sub-Organizations](#sub-organizations).
|
|
83
84
|
- `appPath`: Indicates the file path to the application that will be uploaded to the Appcircle Enterprise App Store.
|
|
84
85
|
- `releaseNote`: Contains the details of changes, updates, and improvements made in the current version of the app being published.
|
|
85
86
|
- `Summary`: Used to provide a brief overview of the version of the app that is about to be published.
|
|
@@ -91,6 +92,7 @@ If you run a self-hosted Appcircle installation, point the action to your own en
|
|
|
91
92
|
|
|
92
93
|
- `authEndpoint` (optional): Authentication endpoint URL. Defaults to `https://auth.appcircle.io`.
|
|
93
94
|
- `apiEndpoint` (optional): API endpoint URL. Defaults to `https://api.appcircle.io`.
|
|
95
|
+
- Set `authEndpoint` and `apiEndpoint` together. If you set only one of them, the lane stops before it sends a request, so a self-hosted token never goes to the Appcircle cloud.
|
|
94
96
|
|
|
95
97
|
```ruby
|
|
96
98
|
appcircle_enterprise_app_store(
|
|
@@ -104,6 +106,25 @@ If you run a self-hosted Appcircle installation, point the action to your own en
|
|
|
104
106
|
)
|
|
105
107
|
```
|
|
106
108
|
|
|
109
|
+
### Sub-Organizations
|
|
110
|
+
|
|
111
|
+
If your Personal API Token or Personal Access Key belongs to the root organization and the target enterprise app store profile is in a sub-organization, set the optional `subOrganizationName` parameter. The action then uses a token of that sub-organization for all later requests. If you use a token or key of the sub-organization, you do not need this parameter.
|
|
112
|
+
|
|
113
|
+
- `subOrganizationName` (optional): The exact name of the sub-organization (case-sensitive). If the action cannot find the sub-organization, or the token cannot access it, the lane fails. The action does not fall back to the root organization.
|
|
114
|
+
|
|
115
|
+
The option also reads the `AC_SUB_ORGANIZATION_NAME` environment variable. The other Appcircle Fastlane plugins use the same variable, so if your lane sets it for one action, it applies to this action too.
|
|
116
|
+
|
|
117
|
+
```ruby
|
|
118
|
+
appcircle_enterprise_app_store(
|
|
119
|
+
personalAPIToken: "$(AC_PERSONAL_API_TOKEN)",
|
|
120
|
+
subOrganizationName: "My Sub Organization",
|
|
121
|
+
appPath: "$(AC_APP_PATH)",
|
|
122
|
+
summary: "$(SUMMARY)",
|
|
123
|
+
releaseNotes: "$(RELEASE_NOTES)",
|
|
124
|
+
publishType: "$(PUBLISH_TYPE)"
|
|
125
|
+
)
|
|
126
|
+
```
|
|
127
|
+
|
|
107
128
|
**Ensure that this action is added after build steps have been completed.**
|
|
108
129
|
|
|
109
130
|
**If two workflows start simultaneously, the last workflow to reach the publish step will be the up-to-date version on the Enterprise App Store. If these workflows building the same package version, the first publish will be successful, while later deployments with the same version will fail.**
|
|
@@ -19,12 +19,13 @@ module Fastlane
|
|
|
19
19
|
def self.run(params)
|
|
20
20
|
personalAPIToken = params[:personalAPIToken]
|
|
21
21
|
personalAccessKey = params[:personalAccessKey]
|
|
22
|
+
subOrganizationName = params[:subOrganizationName]
|
|
22
23
|
appPath = params[:appPath]
|
|
23
24
|
summary = params[:summary]
|
|
24
25
|
releaseNotes = params[:releaseNotes]
|
|
25
26
|
publishType = params[:publishType]
|
|
26
|
-
@@authEndpoint = params[:authEndpoint]
|
|
27
|
-
@@apiEndpoint = params[:apiEndpoint]
|
|
27
|
+
@@authEndpoint = AuthService.normalize_endpoint(params[:authEndpoint], AuthService::CLOUD_AUTH_ENDPOINT)
|
|
28
|
+
@@apiEndpoint = AuthService.normalize_endpoint(params[:apiEndpoint], AuthService::CLOUD_API_ENDPOINT)
|
|
28
29
|
|
|
29
30
|
valid_extensions = ['.apk', '.ipa']
|
|
30
31
|
|
|
@@ -49,11 +50,13 @@ module Fastlane
|
|
|
49
50
|
UI.user_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")
|
|
50
51
|
end
|
|
51
52
|
|
|
53
|
+
self.ac_validate_endpoints(@@authEndpoint, @@apiEndpoint)
|
|
52
54
|
if personalAPIToken.nil?
|
|
53
55
|
self.ac_login_with_pak(personalAccessKey)
|
|
54
56
|
else
|
|
55
57
|
self.ac_login_with_pat(personalAPIToken)
|
|
56
58
|
end
|
|
59
|
+
self.ac_switch_sub_organization(subOrganizationName, personalAPIToken, personalAccessKey)
|
|
57
60
|
self.uploadToProfile(appPath, summary, releaseNotes, publishType)
|
|
58
61
|
end
|
|
59
62
|
|
|
@@ -75,6 +78,28 @@ module Fastlane
|
|
|
75
78
|
raise e
|
|
76
79
|
end
|
|
77
80
|
|
|
81
|
+
def self.ac_validate_endpoints(auth_endpoint, api_endpoint)
|
|
82
|
+
AuthService.validate_endpoints(auth_endpoint: auth_endpoint, api_endpoint: api_endpoint)
|
|
83
|
+
rescue StandardError => e
|
|
84
|
+
UI.user_error!(e.message)
|
|
85
|
+
end
|
|
86
|
+
|
|
87
|
+
def self.ac_switch_sub_organization(sub_organization_name, personal_api_token, personal_access_key)
|
|
88
|
+
name = sub_organization_name.to_s.strip
|
|
89
|
+
return if name.empty?
|
|
90
|
+
|
|
91
|
+
@@apiToken = AuthService.switch_to_sub_organization(
|
|
92
|
+
root_token: @@apiToken,
|
|
93
|
+
name: name,
|
|
94
|
+
pat: personal_api_token || personal_access_key,
|
|
95
|
+
auth_endpoint: @@authEndpoint,
|
|
96
|
+
api_endpoint: @@apiEndpoint
|
|
97
|
+
)
|
|
98
|
+
UI.message("Switched to sub-organization: #{name}")
|
|
99
|
+
rescue StandardError => e
|
|
100
|
+
UI.user_error!(e.message)
|
|
101
|
+
end
|
|
102
|
+
|
|
78
103
|
def self.checkTaskStatus(taskId)
|
|
79
104
|
uri = URI.parse("#{@@apiEndpoint}/task/v1/tasks/#{taskId}")
|
|
80
105
|
timeout = 1
|
|
@@ -172,6 +197,12 @@ module Fastlane
|
|
|
172
197
|
optional: true,
|
|
173
198
|
type: String),
|
|
174
199
|
|
|
200
|
+
FastlaneCore::ConfigItem.new(key: :subOrganizationName,
|
|
201
|
+
env_name: "AC_SUB_ORGANIZATION_NAME",
|
|
202
|
+
description: "Optional: Sub-organization name of the target enterprise app store profile. Use it when the Personal API Token or Personal Access Key belongs to the root organization. Leave empty to use the organization of the token",
|
|
203
|
+
optional: true,
|
|
204
|
+
type: String),
|
|
205
|
+
|
|
175
206
|
FastlaneCore::ConfigItem.new(key: :authEndpoint,
|
|
176
207
|
env_name: "AC_AUTH_ENDPOINT",
|
|
177
208
|
description: "Optional: Authentication endpoint URL for self-hosted Appcircle installations. Defaults to the Appcircle cloud",
|
|
@@ -12,7 +12,34 @@ class UserResponse
|
|
|
12
12
|
end
|
|
13
13
|
|
|
14
14
|
module AuthService
|
|
15
|
-
|
|
15
|
+
class TokenRequestError < RuntimeError
|
|
16
|
+
attr_reader :code
|
|
17
|
+
|
|
18
|
+
def initialize(code, message)
|
|
19
|
+
super(message)
|
|
20
|
+
@code = code
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
CLOUD_AUTH_ENDPOINT = 'https://auth.appcircle.io'.freeze
|
|
25
|
+
CLOUD_API_ENDPOINT = 'https://api.appcircle.io'.freeze
|
|
26
|
+
|
|
27
|
+
def self.validate_endpoints(auth_endpoint:, api_endpoint:)
|
|
28
|
+
return if cloud_endpoint?(auth_endpoint, CLOUD_AUTH_ENDPOINT) == cloud_endpoint?(api_endpoint, CLOUD_API_ENDPOINT)
|
|
29
|
+
|
|
30
|
+
raise 'Set both authEndpoint and apiEndpoint for a self-hosted Appcircle server, or leave both empty for the Appcircle cloud.'
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
def self.normalize_endpoint(endpoint, cloud_endpoint)
|
|
34
|
+
value = endpoint.to_s.strip.sub(%r{/+\z}, '')
|
|
35
|
+
value.empty? ? cloud_endpoint : value
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
def self.cloud_endpoint?(endpoint, cloud_endpoint)
|
|
39
|
+
normalize_endpoint(endpoint, cloud_endpoint).casecmp?(cloud_endpoint)
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
def self.get_ac_token(pat:, sub_organization_id: nil, auth_endpoint: 'https://auth.appcircle.io')
|
|
16
43
|
endpoint_url = "#{auth_endpoint}/auth/v2/token"
|
|
17
44
|
uri = URI(endpoint_url)
|
|
18
45
|
|
|
@@ -23,6 +50,7 @@ module AuthService
|
|
|
23
50
|
|
|
24
51
|
# Encode parameters
|
|
25
52
|
params = { pat: pat }
|
|
53
|
+
params[:subOrganizationId] = sub_organization_id if sub_organization_id
|
|
26
54
|
request.body = URI.encode_www_form(params)
|
|
27
55
|
|
|
28
56
|
# Make the HTTP request
|
|
@@ -40,7 +68,7 @@ module AuthService
|
|
|
40
68
|
|
|
41
69
|
return user
|
|
42
70
|
else
|
|
43
|
-
raise "HTTP Request failed (#{response.code} #{response.message})"
|
|
71
|
+
raise TokenRequestError.new(response.code, "HTTP Request failed (#{response.code} #{response.message})")
|
|
44
72
|
end
|
|
45
73
|
end
|
|
46
74
|
|
|
@@ -54,7 +82,7 @@ module AuthService
|
|
|
54
82
|
request['Accept'] = 'application/json'
|
|
55
83
|
|
|
56
84
|
# Encode parameters
|
|
57
|
-
params = {
|
|
85
|
+
params = { pat: personal_access_key }
|
|
58
86
|
request.body = URI.encode_www_form(params)
|
|
59
87
|
|
|
60
88
|
# Make the HTTP request
|
|
@@ -75,4 +103,48 @@ module AuthService
|
|
|
75
103
|
raise "HTTP Request failed (#{response.code} #{response.message})"
|
|
76
104
|
end
|
|
77
105
|
end
|
|
106
|
+
|
|
107
|
+
def self.get_organization_id(access_token:, name:, api_endpoint: 'https://api.appcircle.io')
|
|
108
|
+
uri = URI("#{api_endpoint}/identity/v1/organizations")
|
|
109
|
+
uri.query = URI.encode_www_form(page: 1, perPage: 1000)
|
|
110
|
+
|
|
111
|
+
request = Net::HTTP::Get.new(uri)
|
|
112
|
+
request['Authorization'] = "Bearer #{access_token}"
|
|
113
|
+
request['Accept'] = 'application/json'
|
|
114
|
+
|
|
115
|
+
response = Net::HTTP.start(uri.host, uri.port, use_ssl: uri.scheme == 'https') do |http|
|
|
116
|
+
http.request(request)
|
|
117
|
+
end
|
|
118
|
+
|
|
119
|
+
raise "Could not list the organizations of this token (HTTP #{response.code})." unless response.kind_of?(Net::HTTPSuccess)
|
|
120
|
+
|
|
121
|
+
payload = begin
|
|
122
|
+
JSON.parse(response.body)
|
|
123
|
+
rescue JSON::ParserError
|
|
124
|
+
nil
|
|
125
|
+
end
|
|
126
|
+
raise 'Could not list the organizations of this token (unexpected response).' unless payload.kind_of?(Hash)
|
|
127
|
+
|
|
128
|
+
organizations = payload['data'].kind_of?(Array) ? payload['data'] : []
|
|
129
|
+
organization = organizations.find { |org| org['name'] == name }
|
|
130
|
+
raise "Sub-organization '#{name}' could not be found or is not accessible with this token." if organization.nil? || organization['id'].to_s.empty?
|
|
131
|
+
|
|
132
|
+
organization['id']
|
|
133
|
+
end
|
|
134
|
+
|
|
135
|
+
def self.switch_to_sub_organization(root_token:, name:, pat:, auth_endpoint:, api_endpoint:)
|
|
136
|
+
organization_id = get_organization_id(access_token: root_token, name: name, api_endpoint: api_endpoint)
|
|
137
|
+
begin
|
|
138
|
+
user = get_ac_token(pat: pat, sub_organization_id: organization_id, auth_endpoint: auth_endpoint)
|
|
139
|
+
rescue TokenRequestError => e
|
|
140
|
+
raise "Could not authenticate against sub-organization '#{name}' (HTTP #{e.code})."
|
|
141
|
+
rescue JSON::ParserError
|
|
142
|
+
raise "Could not obtain an access token for sub-organization '#{name}'."
|
|
143
|
+
end
|
|
144
|
+
|
|
145
|
+
token = user.accessToken
|
|
146
|
+
raise "Could not obtain an access token for sub-organization '#{name}'." if token.nil? || token.to_s.empty?
|
|
147
|
+
|
|
148
|
+
token
|
|
149
|
+
end
|
|
78
150
|
end
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: fastlane-plugin-appcircle_enterprise_app_store
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.2.0.beta.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- appcircleio
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2026-
|
|
11
|
+
date: 2026-11-30 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: rest-client
|