fastlane-plugin-latest_appcenter_build_number 0.1.0 → 0.1.1
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
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: f9b2555a719cd267f2ab535d3aaa65d52b20756b1c629a25c29403c35ceae36e
|
4
|
+
data.tar.gz: 286400c56c2068ff07cf0060b607363773cbd29f23c0ae5650204f8500c45db7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2869a4a6cdbad6a559dbb3342f426051695ac504a7dccd8c80a228a4d90a19ca9dfda46ef96689f10a326933f004c58c6dddcf613aa2560ede272a0310adbf1f
|
7
|
+
data.tar.gz: a9006f753b7b648a629466a8238685f5a8ba1bdfac72506371abcf1ddd9067e986fb14e9ac373e729df561b5251db1eace391b8eaa35d1a6b96afaef3d23324d
|
data/README.md
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
# latest_appcenter_build_number plugin
|
2
2
|
|
3
3
|
[![fastlane Plugin Badge](https://rawcdn.githack.com/fastlane/fastlane/master/fastlane/assets/plugin-badge.svg)](https://rubygems.org/gems/fastlane-plugin-latest_appcenter_build_number)
|
4
|
+
[![Gem Version](https://badge.fury.io/rb/fastlane-plugin-latest_appcenter_build_number.svg)](https://badge.fury.io/rb/fastlane-plugin-latest_appcenter_build_number)
|
4
5
|
|
5
6
|
## Getting Started
|
6
7
|
|
@@ -14,13 +15,44 @@ fastlane add_plugin latest_appcenter_build_number
|
|
14
15
|
|
15
16
|
Use AppCenter API to get the latest version and build number for an App Center app
|
16
17
|
|
17
|
-
**Note to author:** Add a more detailed description about this plugin here. If your plugin contains multiple actions, make sure to mention them here.
|
18
|
-
|
19
18
|
## Example
|
20
19
|
|
21
|
-
|
20
|
+
You can fetch the latest version for a given app with the following command in your Fastfile:
|
21
|
+
|
22
|
+
```ruby
|
23
|
+
version_number = latest_appcenter_build_number
|
24
|
+
```
|
25
|
+
this will use the environment variable `APPCENTER_API_TOKEN` to fetch the list of apps for a given owner account, and then prompt you for which one to use. This can also be specified as a parameter, e.g.:
|
26
|
+
```ruby
|
27
|
+
version_number = latest_appcenter_build_number(api_token: "my-APPCENTER-api-token")
|
28
|
+
```
|
29
|
+
The parameters `owner_name` and `app_name`, or environment variables `APPCENTER_OWNER_NAME`, and `APPCENTER_APP_NAME`, can also be set:
|
30
|
+
```ruby
|
31
|
+
version_number = latest_appcenter_build_number(
|
32
|
+
api_token: "my-APPCENTER-api-token", # note that this will need to be generated from here: https://appcenter.ms/settings/apitokens
|
33
|
+
owner_name: "owner-name",
|
34
|
+
app_name: "My-Awesome-App"
|
35
|
+
)
|
36
|
+
```
|
37
|
+
You can then use `version_number` for whatever purpose you required, including updating the shortVersion or buildNumber of your Xcode project.
|
38
|
+
|
39
|
+
## Replacing latest_hockey_build_number
|
40
|
+
|
41
|
+
If you're using this as a direct replacement for the old `latest_hockey_build_number` having migrated your apps to AppCenter, you should change instances of this:
|
42
|
+
```ruby
|
43
|
+
latest_hockey_build_number(api_token: "my-HOCKEY-api-token", bundle_id: "com.example.my-awesome-app")
|
44
|
+
```
|
45
|
+
to this:
|
46
|
+
```ruby
|
47
|
+
latest_appcenter_build_number(
|
48
|
+
api_token: "my-APPCENTER-api-token", # note that this will need to be generated from here: https://appcenter.ms/settings/apitokens
|
49
|
+
owner_name: "owner-name",
|
50
|
+
app_name: "My-Awesome-App"
|
51
|
+
)
|
52
|
+
```
|
53
|
+
To find out your `app_name` correctly, head to https://appcenter.ms/apps?os=All. Your `app_name` will most likely be what's listed under the 'Name' column but with hyphens instead of whitespace.
|
22
54
|
|
23
|
-
|
55
|
+
To find out your `owner_name` correctly, head to https://appcenter.ms/settings/profile. Your `owner_name` will most likely be what's listed under the 'username' field.
|
24
56
|
|
25
57
|
## Run tests for this plugin
|
26
58
|
|
@@ -1,20 +1,36 @@
|
|
1
1
|
require 'json'
|
2
2
|
require 'net/http'
|
3
|
+
require 'fastlane_core/ui/ui'
|
3
4
|
|
4
5
|
module Fastlane
|
6
|
+
UI = FastlaneCore::UI unless Fastlane.const_defined?("UI")
|
7
|
+
|
5
8
|
module Actions
|
6
9
|
class LatestAppcenterBuildNumberAction < Action
|
7
10
|
def self.run(config)
|
11
|
+
app_name = config[:app_name]
|
12
|
+
owner_name = config[:owner_name]
|
13
|
+
if app_name.nil? || owner_name.nil?
|
14
|
+
owner_and_app_name = get_owner_and_app_name(config[:api_token])
|
15
|
+
app_name = owner_and_app_name[0]
|
16
|
+
owner_name = owner_and_app_name[1]
|
17
|
+
end
|
18
|
+
|
8
19
|
host_uri = URI.parse('https://api.appcenter.ms')
|
9
20
|
http = Net::HTTP.new(host_uri.host, host_uri.port)
|
10
21
|
http.use_ssl = true
|
11
|
-
list_request = Net::HTTP::Get.new("/v0.1/apps/#{
|
22
|
+
list_request = Net::HTTP::Get.new("/v0.1/apps/#{owner_name}/#{app_name}/releases")
|
12
23
|
list_request['X-API-Token'] = config[:api_token]
|
13
24
|
list_response = http.request(list_request)
|
14
|
-
releases = JSON.parse(list_response.body)
|
15
25
|
|
26
|
+
if list_response.kind_of?(Net::HTTPForbidden)
|
27
|
+
UI.error("API Key not valid for #{owner_name}. This will be because either the API Key or the owner_name are incorrect")
|
28
|
+
return nil
|
29
|
+
end
|
30
|
+
|
31
|
+
releases = JSON.parse(list_response.body)
|
16
32
|
if releases.nil?
|
17
|
-
UI.error
|
33
|
+
UI.error("No versions found for #{app_name} owned by #{owner_name}")
|
18
34
|
return nil
|
19
35
|
end
|
20
36
|
|
@@ -22,7 +38,7 @@ module Fastlane
|
|
22
38
|
latest_build = releases.first
|
23
39
|
|
24
40
|
if latest_build.nil?
|
25
|
-
UI.error
|
41
|
+
UI.error("The app has no versions yet")
|
26
42
|
return nil
|
27
43
|
end
|
28
44
|
|
@@ -43,25 +59,49 @@ module Fastlane
|
|
43
59
|
env_name: "APPCENTER_API_TOKEN",
|
44
60
|
description: "API Token for AppCenter Access",
|
45
61
|
verify_block: proc do |value|
|
46
|
-
UI.user_error!("No API token for AppCenter given, pass using `api_token: 'token'`") unless value
|
62
|
+
UI.user_error!("No API token for AppCenter given, pass using `api_token: 'token'`") unless value && !value.empty?
|
47
63
|
end),
|
48
64
|
FastlaneCore::ConfigItem.new(key: :owner_name,
|
49
65
|
env_name: "APPCENTER_OWNER_NAME",
|
66
|
+
optional: true,
|
50
67
|
description: "Name of the owner of the application on AppCenter",
|
51
68
|
verify_block: proc do |value|
|
52
|
-
UI.user_error!("No owner name for AppCenter given, pass using `owner_name: 'owner name'`") unless value
|
69
|
+
UI.user_error!("No owner name for AppCenter given, pass using `owner_name: 'owner name'`") unless value && !value.empty?
|
53
70
|
end),
|
54
71
|
FastlaneCore::ConfigItem.new(key: :app_name,
|
55
72
|
env_name: "APPCENTER_APP_NAME",
|
73
|
+
optional: true,
|
56
74
|
description: "Name of the application on AppCenter",
|
57
75
|
verify_block: proc do |value|
|
58
|
-
UI.user_error!("No app name for AppCenter given, pass using `app_name: 'app name'`") unless value
|
59
|
-
end)
|
76
|
+
UI.user_error!("No app name for AppCenter given, pass using `app_name: 'app name'`") unless value && !value.empty?
|
77
|
+
end)
|
60
78
|
]
|
61
79
|
end
|
62
80
|
|
63
81
|
def self.is_supported?(platform)
|
64
|
-
[:ios, :android].include?
|
82
|
+
[:ios, :android].include?(platform)
|
83
|
+
end
|
84
|
+
|
85
|
+
def self.get_owner_and_app_name(api_token)
|
86
|
+
apps = get_apps(api_token)
|
87
|
+
app_names = apps.map { |app| app['name'] }.sort
|
88
|
+
selected_app_name = UI.select("Select your project: ", app_names)
|
89
|
+
selected_app = apps.select { |app| app['name'] == selected_app_name }.first
|
90
|
+
|
91
|
+
name = selected_app['name'].to_s
|
92
|
+
owner = selected_app['owner']['name'].to_s
|
93
|
+
return name, owner
|
94
|
+
end
|
95
|
+
|
96
|
+
def self.get_apps(api_token)
|
97
|
+
host_uri = URI.parse('https://api.appcenter.ms')
|
98
|
+
http = Net::HTTP.new(host_uri.host, host_uri.port)
|
99
|
+
http.use_ssl = true
|
100
|
+
apps_request = Net::HTTP::Get.new("/v0.1/apps")
|
101
|
+
apps_request['X-API-Token'] = api_token
|
102
|
+
apps_response = http.request(apps_request)
|
103
|
+
apps = JSON.parse(apps_response.body)
|
104
|
+
return apps
|
65
105
|
end
|
66
106
|
end
|
67
107
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fastlane-plugin-latest_appcenter_build_number
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jack Spargo
|
@@ -167,8 +167,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
167
167
|
- !ruby/object:Gem::Version
|
168
168
|
version: '0'
|
169
169
|
requirements: []
|
170
|
-
|
171
|
-
rubygems_version: 2.6.14
|
170
|
+
rubygems_version: 3.0.6
|
172
171
|
signing_key:
|
173
172
|
specification_version: 4
|
174
173
|
summary: Use AppCenter API to get the latest version and build number for an App Center
|