fastlane-plugin-appcenter 1.7.1 → 1.8.0

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
2
  SHA256:
3
- metadata.gz: ba75670e59a7a2ba066a788088aeb05d96991bcc1ab693633bb0fca27fc821c5
4
- data.tar.gz: b11523450e225a2ec2b596d0a4db135cf1dd1a5acefd4a0a0bc0136cf42c8917
3
+ metadata.gz: d80a48da7efa15bbdfb68ed3af18b8ed57bac5ecca51d0725b428520a0912608
4
+ data.tar.gz: 651ed034f616868690bcf677453cb6c8646c9d02692d831284b54f5fe061d4f0
5
5
  SHA512:
6
- metadata.gz: ffd5e3de2a289e28e264a679fb286bb25ecc830a8c36d15c0d044291bc891f9eb17e76e8e4ea76682bf84b19c18db86d475c20b6cdab5f223fd85d7e207b8d85
7
- data.tar.gz: d8c07796377fb096fa566c35435e208d22de2dbd3bac1e5901fbff0b432ea7a7ecfdf77b60a5726ff30a87865062602544bd4f0f980c5a96dead0dd1d825855f
6
+ metadata.gz: 68027e3171f663771bc1030396874f14c95f118050b8b881a6d61c2a0a9569876f7fe27a8841c32cfcb00c7a8e536fed5c26f47a64f15df78aed5b9683681cc6
7
+ data.tar.gz: 8d4584eea5879862b0f08a7e074fbee368636de399dd55f76f3e585f4b44717b72f8c2d4dae3da6cbab32b6d19eb6b319a1cb7761850d3399866d167b3972993
data/README.md CHANGED
@@ -21,6 +21,8 @@ With [App Center](https://appcenter.ms) you can continuously build, test, releas
21
21
 
22
22
  `appcenter_upload` allows you to upload and [distribute](https://docs.microsoft.com/en-us/appcenter/distribution/uploading) apps to your testers on App Center as well as to upload .dSYM files to [collect detailed crash reports](https://docs.microsoft.com/en-us/appcenter/crashes/ios) in App Center.
23
23
 
24
+ `appcenter_fetch_version_number` allows you to obtain the latest version number (short or full) for an app. This is useful for tasks such as getting the latest version of an app so that an increment action can take place on CI, or checking that an upload has been successful.
25
+
24
26
  ## Usage
25
27
 
26
28
  To get started, first, [obtain an API token](https://appcenter.ms/settings/apitokens) in App Center. The API Token is used to authenticate with the App Center API in each call.
@@ -47,6 +49,20 @@ appcenter_upload(
47
49
  )
48
50
  ```
49
51
 
52
+ ```ruby
53
+ appcenter_fetch_version_number(
54
+ api_token: "<appcenter token>",
55
+ owner_name: "<appcenter account name of the owner of the app (username or organization URL name)>",
56
+ app_name: "<appcenter app name (as seen in app URL)>"
57
+ )
58
+ ```
59
+
60
+ The `appcenter_fetch_version_number` returns a hash that contains the id, the version number, and the build number. The version corresponds to the `short_version` and the build number to the `version` known by App Center for a given release:
61
+ ```ruby
62
+ {"id"=>1, "version"=>"1.0.0", "build_number"=>"1.0.0.1234"} # iOS apps contain the full version plus build number due to the way that Apple use CFBundleVersion for this value
63
+ {"id"=>588, "version"=>"1.2.0", "build_number"=>"1615"}
64
+ ```
65
+
50
66
  ### Help
51
67
 
52
68
  Once installed, information and help for an action can be printed out with this command:
@@ -96,11 +112,11 @@ Here is the list of all existing parameters:
96
112
  | `upload_dsym_only` <br/> `APPCENTER_DISTRIBUTE_UPLOAD_DSYM_ONLY` | Flag to upload only the dSYM file to App Center (default: `false`) |
97
113
  | `mapping` <br/> `APPCENTER_DISTRIBUTE_ANDROID_MAPPING` | Path to your Android mapping.txt |
98
114
  | `upload_mapping_only` <br/> `APPCENTER_DISTRIBUTE_UPLOAD_ANDROID_MAPPING_ONLY` | Flag to upload only the mapping.txt file to App Center (default: `false`) |
99
- | `destinations` <br/> `APPCENTER_DISTRIBUTE_DESTINATIONS` | Comma separated list of destination names. Both distribution groups and stores are supported. All names are required to be of the same destination type (default: `Collaborators`) |
115
+ | `destinations` <br/> `APPCENTER_DISTRIBUTE_DESTINATIONS` | Comma separated list of destination names, use '*' for all distribution groups if destination type is 'group'. Both distribution groups and stores are supported. All names are required to be of the same destination type (default: `Collaborators`) |
100
116
  | `destination_type` <br/> `APPCENTER_DISTRIBUTE_DESTINATION_TYPE` | Destination type of distribution destination. 'group' and 'store' are supported (default: `group`) |
101
117
  | `mandatory_update` <br/> `APPCENTER_DISTRIBUTE_MANDATORY_UPDATE` | Require users to update to this release. Ignored if destination type is 'store' (default: `false`) |
102
118
  | `notify_testers` <br/> `APPCENTER_DISTRIBUTE_NOTIFY_TESTERS` | Send email notification about release. Ignored if destination type is 'store' (default: `false`) |
103
- | `release_notes` <br/> `APPCENTER_DISTRIBUTE_RELEASE_NOTES` | Release notes (default: `No changelog given`) |
119
+ | `release_notes` <br/> `APPCENTER_DISTRIBUTE_RELEASE_NOTES` | Release notes (default: `No changelog given`) |
104
120
  | `should_clip` <br/> `APPCENTER_DISTRIBUTE_RELEASE_NOTES_CLIPPING` | Clip release notes if its length is more then 5000, true by default (default: `true`) |
105
121
  | `release_notes_link` <br/> `APPCENTER_DISTRIBUTE_RELEASE_NOTES_LINK` | Additional release notes link |
106
122
  | `build_number` <br/> `APPCENTER_DISTRIBUTE_BUILD_NUMBER` | The build number, required for macOS .pkg and .dmg builds, as well as Android ProGuard `mapping.txt` when using `upload_mapping_only` |
@@ -109,6 +125,13 @@ Here is the list of all existing parameters:
109
125
  | `dsa_signature` <br/> `APPCENTER_DISTRIBUTE_DSA_SIGNATURE` | DSA signature of the macOS or Windows release for Sparkle update feed |
110
126
  | `strict` <br/> `APPCENTER_STRICT_MODE` | Strict mode, set to 'true' to fail early in case a potential error was detected |
111
127
 
128
+ #### `appcenter_fetch_version_number`
129
+
130
+ | Key & Env Var | Description |
131
+ |-----------------|--------------------|
132
+ | `api_token` <br/> `APPCENTER_API_TOKEN` | API Token for App Center |
133
+ | `owner_name` <br/> `APPCENTER_OWNER_NAME` | Owner name, as found in the App's URL in App Center |
134
+ | `app_name` <br/> `APPCENTER_APP_NAME` | App name as found in the App's URL in App Center. If there is no app with such name, you will be prompted to create one |
112
135
 
113
136
  ## Example
114
137
 
@@ -0,0 +1,84 @@
1
+ require 'json'
2
+ require 'net/http'
3
+ require 'fastlane_core/ui/ui'
4
+
5
+ module Fastlane
6
+ UI = FastlaneCore::UI unless Fastlane.const_defined?("UI")
7
+
8
+ module Actions
9
+ class AppcenterFetchVersionNumberAction < Action
10
+ def self.description
11
+ "Fetches the latest version number of an app from App Center"
12
+ end
13
+
14
+ def self.authors
15
+ ["jspargo", "ShopKeep"]
16
+ end
17
+
18
+ def self.run(params)
19
+ api_token = params[:api_token]
20
+ app_name = params[:app_name]
21
+ owner_name = params[:owner_name]
22
+
23
+ releases = Helper::AppcenterHelper.fetch_releases(
24
+ api_token: api_token,
25
+ owner_name: owner_name,
26
+ app_name: app_name
27
+ )
28
+
29
+ UI.abort_with_message!("No versions found for '#{app_name}' owned by #{owner_name}") unless releases
30
+ sorted_release = releases.sort_by { |release| release['id'] }.reverse!
31
+ latest_release = sorted_release.first
32
+
33
+ if latest_release.nil?
34
+ UI.user_error!("This app has no releases yet")
35
+ return nil
36
+ end
37
+
38
+ return {
39
+ "id" => latest_release['id'],
40
+ "version" => latest_release['short_version'],
41
+ "build_number" => latest_release['version']
42
+ }
43
+ end
44
+
45
+ def self.available_options
46
+ [
47
+ FastlaneCore::ConfigItem.new(key: :api_token,
48
+ env_name: "APPCENTER_API_TOKEN",
49
+ description: "API Token for App Center Access",
50
+ verify_block: proc do |value|
51
+ UI.user_error!("No API token for App Center given, pass using `api_token: 'token'`") unless value && !value.empty?
52
+ end),
53
+ FastlaneCore::ConfigItem.new(key: :owner_name,
54
+ env_name: "APPCENTER_OWNER_NAME",
55
+ description: "Name of the owner of the application on App Center",
56
+ verify_block: proc do |value|
57
+ UI.user_error!("No owner name for App Center given, pass using `owner_name: 'owner name'`") unless value && !value.empty?
58
+ end),
59
+ FastlaneCore::ConfigItem.new(key: :app_name,
60
+ env_name: "APPCENTER_APP_NAME",
61
+ description: "Name of the application on App Center",
62
+ verify_block: proc do |value|
63
+ UI.user_error!("No app name for App Center given, pass using `app_name: 'app name'`") unless value && !value.empty?
64
+ end)
65
+ ]
66
+ end
67
+
68
+ def self.is_supported?(platform)
69
+ [:ios, :android].include?(platform)
70
+ end
71
+
72
+ def self.get_apps(api_token)
73
+ host_uri = URI.parse('https://api.appcenter.ms')
74
+ http = Net::HTTP.new(host_uri.host, host_uri.port)
75
+ http.use_ssl = true
76
+ apps_request = Net::HTTP::Get.new("/v0.1/apps")
77
+ apps_request['X-API-Token'] = api_token
78
+ apps_response = http.request(apps_request)
79
+ return [] unless apps_response.kind_of?(Net::HTTPOK)
80
+ return JSON.parse(apps_response.body)
81
+ end
82
+ end
83
+ end
84
+ end
@@ -22,6 +22,13 @@ module Fastlane
22
22
  end
23
23
 
24
24
  class AppcenterUploadAction < Action
25
+ def self.is_apple_build(file)
26
+ return false unless file
27
+
28
+ file_ext = Helper::AppcenterHelper.file_extname_full(file)
29
+ ((Constants::SUPPORTED_EXTENSIONS[:ios] + Constants::SUPPORTED_EXTENSIONS[:mac])).include? file_ext
30
+ end
31
+
25
32
  # run whole upload process for dSYM files
26
33
  def self.run_dsym_upload(params)
27
34
  values = params.values
@@ -35,8 +42,9 @@ module Fastlane
35
42
 
36
43
  dsym_path = nil
37
44
  if dsym
38
- # we can use dsym parameter only if build file is ipa
39
- dsym_path = dsym if !file || File.extname(file) == '.ipa'
45
+ # we can use dsym parameter for all apple builds
46
+ self.optional_error("dsym parameter can only be used with Apple builds (ios, mac)") unless !file || self.is_apple_build(file)
47
+ dsym_path = dsym
40
48
  else
41
49
  # if dsym is not set, but build is ipa - check default path
42
50
  if file && File.exist?(file) && File.extname(file) == '.ipa'
@@ -370,7 +370,7 @@ module Fastlane
370
370
  false
371
371
  end
372
372
  end
373
-
373
+
374
374
  # add release to distribution group or store
375
375
  def self.add_to_destination(api_token, owner_name, app_name, release_id, destination_type, destination_id, mandatory_update = false, notify_testers = false)
376
376
  connection = self.connection
@@ -526,6 +526,32 @@ module Fastlane
526
526
  end
527
527
  end
528
528
 
529
+ def self.fetch_releases(api_token:, owner_name:, app_name:)
530
+ connection = self.connection(nil, false, true)
531
+
532
+ endpoint = "/v0.1/apps/#{owner_name}/#{app_name}/releases"
533
+
534
+ response = connection.get(endpoint) do |req|
535
+ req.headers['X-API-Token'] = api_token
536
+ req.headers['internal-request-source'] = "fastlane"
537
+ end
538
+
539
+ case response.status
540
+ when 200...300
541
+ UI.message("DEBUG: #{response.body.inspect}") if ENV['DEBUG']
542
+ JSON.parse(response.body)
543
+ when 401
544
+ UI.user_error!("Auth Error, provided invalid token")
545
+ false
546
+ when 404
547
+ UI.error("Not found, invalid owner or application name")
548
+ false
549
+ else
550
+ UI.error("Error #{response.status}: #{response.body}")
551
+ false
552
+ end
553
+ end
554
+
529
555
  # Note: This does not support testing environment (INT)
530
556
  def self.get_release_url(owner_type, owner_name, app_name, release_id)
531
557
  owner_path = owner_type == "user" ? "users/#{owner_name}" : "orgs/#{owner_name}"
@@ -1,5 +1,5 @@
1
1
  module Fastlane
2
2
  module Appcenter
3
- VERSION = "1.7.1"
3
+ VERSION = "1.8.0"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fastlane-plugin-appcenter
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.7.1
4
+ version: 1.8.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Microsoft Corporation
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-12-04 00:00:00.000000000 Z
11
+ date: 2020-02-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -118,6 +118,7 @@ files:
118
118
  - README.md
119
119
  - lib/fastlane/plugin/appcenter.rb
120
120
  - lib/fastlane/plugin/appcenter/actions/appcenter_fetch_devices_action.rb
121
+ - lib/fastlane/plugin/appcenter/actions/appcenter_fetch_version_number.rb
121
122
  - lib/fastlane/plugin/appcenter/actions/appcenter_upload_action.rb
122
123
  - lib/fastlane/plugin/appcenter/helper/appcenter_helper.rb
123
124
  - lib/fastlane/plugin/appcenter/version.rb