fastlane-plugin-bitrise_bcsymbolmaps 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: ca1d83242d17b2462a1662e3a51fa79d8d5423066a5bacc968b3215b75100ec8
4
+ data.tar.gz: 80c87e4b63d79f320a90d93bcb0889c17e4c3a4e14c747427d0f33273265f792
5
+ SHA512:
6
+ metadata.gz: 810030fdaeadff3af7ab511ffb1ce396957cfe940dd7e2a6b8a1fd5f8d14b27c40567c0388ea3e0d76eea6b03ff8e2ae949101ae26b524de6c5d5fb8a9d0a828
7
+ data.tar.gz: 4d759dbda10f270a6bc62cfb16c8de34f8e43749f24e392ce64f4c5247df42c013d9b0612109c082c8b892247013c15f19a2ca0976a5a8db92471faf638756cb
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2020 Oleksandr Skrypnyk <olexandr.skrypnyk@me.com>
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,55 @@
1
+ # bitrise_bcsymbolmaps plugin
2
+
3
+ [![fastlane Plugin Badge](https://rawcdn.githack.com/fastlane/fastlane/master/fastlane/assets/plugin-badge.svg)](https://rubygems.org/gems/fastlane-plugin-bitrise_bcsymbolmaps)
4
+
5
+ ## Getting Started
6
+
7
+ This project is a [_fastlane_](https://github.com/fastlane/fastlane) plugin. To get started with `fastlane-plugin-bitrise_bcsymbolmaps`, add it to your project by running:
8
+
9
+ ```bash
10
+ fastlane add_plugin bitrise_bcsymbolmaps
11
+ ```
12
+
13
+ ## About bitrise_bcsymbolmaps
14
+
15
+ Download BCSymbolMaps from Bitrise before uploading them to a crash reporting tool.
16
+
17
+ ## Example
18
+
19
+ Check out the [example `Fastfile`](fastlane/Fastfile) to see how to use this plugin. Try it by cloning the repo, running `fastlane install_plugins`.
20
+
21
+ In order to download bitcode symbol maps, provide a Personal Access Token from Bitrise as well as a app slug (last segment of the app URL).
22
+ We're assuming that release builds are coming from `release/*` branches (thanks to [Gitflow](https://nvie.com/posts/a-successful-git-branching-model/)) and we only need successful builds (`status: "1"`).
23
+
24
+ ```ruby
25
+ build = bitrise_download_bcsymbolmaps(
26
+ api_access_token: ENV["BITRISE_TOKEN"],
27
+ app_slug: ENV["BITRISE_APP_SLUG"],
28
+ branch: "release/#{version}",
29
+ status: "1"
30
+ )
31
+ ```
32
+
33
+ This will return an object with two attributes: `build_number` and `commit_hash`. Having this information is sufficient to [download dSYMs from AppStore Connect](fastlane/Fastfile#L23-L27) and [create a release on Bugsnag](fastlane/Fastfile#L29-L34).
34
+
35
+ After all the operations are done, you might want to cleanup a work directory.
36
+
37
+ ```ruby
38
+ bitrise_clean_bcsymbolmaps
39
+ ```
40
+
41
+ ## Issues and Feedback
42
+
43
+ For any other issues and feedback about this plugin, please submit it to this repository.
44
+
45
+ ## Troubleshooting
46
+
47
+ If you have trouble using plugins, check out the [Plugins Troubleshooting](https://docs.fastlane.tools/plugins/plugins-troubleshooting/) guide.
48
+
49
+ ## Using _fastlane_ Plugins
50
+
51
+ For more information about how the `fastlane` plugin system works, check out the [Plugins documentation](https://docs.fastlane.tools/plugins/create-plugin/).
52
+
53
+ ## About _fastlane_
54
+
55
+ _fastlane_ is the easiest way to automate beta deployments and releases for your iOS and Android apps. To learn more, check out [fastlane.tools](https://fastlane.tools).
@@ -0,0 +1,13 @@
1
+ require 'fastlane/plugin/bitrise_bcsymbolmaps/version'
2
+
3
+ module Fastlane
4
+ module BitriseBcsymbolmaps
5
+ def self.all_classes
6
+ Dir[File.expand_path('**/{actions,helper}/*.rb', File.dirname(__FILE__))]
7
+ end
8
+ end
9
+ end
10
+
11
+ Fastlane::BitriseBcsymbolmaps.all_classes.each do |current|
12
+ require current
13
+ end
@@ -0,0 +1,22 @@
1
+ module Fastlane
2
+ module Actions
3
+ class BitriseCleanBcsymbolmapsAction < Action
4
+ def self.run(params)
5
+ FileUtils.rm_rf Dir.glob(File.join(Dir.pwd, "BCSymbolMaps*"))
6
+ FileUtils.rm_rf File.join(Dir.pwd, "fastlane", "BCSymbolmaps")
7
+ end
8
+
9
+ def self.description
10
+ "Cleans up downloaded artifacts."
11
+ end
12
+
13
+ def self.authors
14
+ ["Oleksandr Skrypnyk"]
15
+ end
16
+
17
+ def self.is_supported?(platform)
18
+ platform == :ios
19
+ end
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,178 @@
1
+ require 'fastlane/action'
2
+ require 'json'
3
+ require 'net/http'
4
+ require 'uri'
5
+ require 'zip'
6
+
7
+ module Fastlane
8
+ module Actions
9
+ class BitriseDownloadBcsymbolmapsAction < Action
10
+ API_VERSION = "v0.1"
11
+
12
+ Build = Struct.new(:build_number, :commit_hash)
13
+
14
+ def self.run(params)
15
+ build_response = bitrise_get_latest_build(params[:api_access_token], params[:app_slug], params[:branch], params[:status])
16
+ return if build_response.code != "200"
17
+ build_slug = get_build_slug(build_response)
18
+ build_number = get_build_number(build_response).to_s
19
+ build_commit_hash = get_build_commit_hash(build_response)
20
+
21
+ artifacts_response = bitrise_get_artifacts(params[:api_access_token], params[:app_slug], build_slug)
22
+ return if artifacts_response.code != "200"
23
+ artifact_slug = get_artifact_slug(artifacts_response)
24
+
25
+ artifact_response = bitrise_get_artifact(params[:api_access_token], params[:app_slug], build_slug, artifact_slug)
26
+ return if artifact_response.code != "200"
27
+ artifact_link = get_artifact_link(artifact_response)
28
+
29
+ destination_path = File.join(Dir.pwd, "fastlane", "BCSymbolMaps")
30
+ prepare_destination_path(destination_path)
31
+ zip_path = download_file_with_prompt(artifact_link, build_number)
32
+ extract_zip(zip_path)
33
+
34
+ Build.new(build_number, build_commit_hash)
35
+ end
36
+
37
+ def self.description
38
+ "Downloads BCSymbolMaps from Bitrise before uploading them to a crash reporting tool."
39
+ end
40
+
41
+ def self.authors
42
+ ["Oleksandr Skrypnyk"]
43
+ end
44
+
45
+ def self.return_value
46
+ "Struct (build number, commit hash)"
47
+ end
48
+
49
+ def self.available_options
50
+ [
51
+ FastlaneCore::ConfigItem.new(key: :api_access_token,
52
+ env_name: "BITRISE_BCSYMBOLMAPS_API_TOKEN",
53
+ description: "Bitrise Personal Access Token",
54
+ optional: false,
55
+ verify_block: proc do |value|
56
+ UI.user_error!("No token for bitrise_download_bcsymbolmaps action given, pass using `api_access_token: \"<YOUR TOKEN>\"`") unless value
57
+ end),
58
+ FastlaneCore::ConfigItem.new(key: :app_slug,
59
+ env_name: "BITRISE_BCSYMBOLMAPS_APP_SLUG",
60
+ description: "Bitrise App Slug",
61
+ optional: false,
62
+ verify_block: proc do |value|
63
+ UI.user_error!("No app slug for bitrise_download_bcsymbolmaps action given, pass using `app_slug: \"<APP SLUG>\"`") unless value
64
+ end),
65
+ FastlaneCore::ConfigItem.new(key: :branch,
66
+ env_name: "BITRISE_BCSYMBOLMAPS_BRANCH",
67
+ description: "Git Branch",
68
+ optional: false,
69
+ verify_block: proc do |value|
70
+ UI.user_error!("No git branch for bitrise_download_bcsymbolmaps action given, pass using `branch: \"<BRANCH>\"`") unless value
71
+ end),
72
+ FastlaneCore::ConfigItem.new(key: :status,
73
+ env_name: "BITRISE_BCSYMBOLMAPS_STATUS",
74
+ description: "Build Status",
75
+ optional: true,
76
+ verify_block: proc do |value|
77
+ UI.user_error!("No status for bitrise_download_bcsymbolmaps action given, pass using `status: \"<STATUS>\"`") unless value
78
+ end)
79
+ ]
80
+ end
81
+
82
+ def self.is_supported?(platform)
83
+ platform == :ios
84
+ end
85
+
86
+ def self.perform_api_request(token, path)
87
+ uri = URI.parse("https://api.bitrise.io/#{API_VERSION}#{path}")
88
+ request = Net::HTTP::Get.new(uri)
89
+ request["Accept"] = "application/json"
90
+ request["Authorization"] = token
91
+ req_options = {use_ssl: uri.scheme == "https"}
92
+ Net::HTTP.start(uri.hostname, uri.port, req_options) do |http|
93
+ http.request(request)
94
+ end
95
+ end
96
+
97
+ def self.bitrise_get_latest_build(token, app_slug, branch, status)
98
+ perform_api_request(token, "/apps/#{app_slug}/builds?branch=#{branch}&status=#{status}")
99
+ end
100
+
101
+ def self.get_latest_build(response)
102
+ json = JSON.parse(response.body)
103
+ json["data"].sort { |lhs, rhs| rhs["build_number"].to_i <=> lhs["build_number"].to_i }.first
104
+ end
105
+
106
+ def self.get_build_slug(response)
107
+ get_latest_build(response)["slug"]
108
+ end
109
+
110
+ def self.get_build_number(response)
111
+ get_latest_build(response)["build_number"]
112
+ end
113
+
114
+ def self.get_build_commit_hash(response)
115
+ get_latest_build(response)["commit_hash"]
116
+ end
117
+
118
+ def self.bitrise_get_artifacts(token, app_slug, build_slug)
119
+ perform_api_request(token, "/apps/#{app_slug}/builds/#{build_slug}/artifacts")
120
+ end
121
+
122
+ def self.get_artifact_slug(response)
123
+ json = JSON.parse(response.body)
124
+ json["data"].select { |artifact| artifact["artifact_type"] == "ios-ipa" }.first["slug"]
125
+ end
126
+
127
+ def self.bitrise_get_artifact(token, app_slug, build_slug, artifact_slug)
128
+ perform_api_request(token, "/apps/#{app_slug}/builds/#{build_slug}/artifacts/#{artifact_slug}")
129
+ end
130
+
131
+ def self.get_artifact_link(response)
132
+ json = JSON.parse(response.body)
133
+ json["data"]["expiring_download_url"]
134
+ end
135
+
136
+ def self.extract_zip(file)
137
+ Zip::File.open(file) do |zip_file|
138
+ zip_file.glob("BCSymbolMaps/*.bcsymbolmap").each do |f|
139
+ fpath = File.join(Dir.pwd, "fastlane", f.name)
140
+ zip_file.extract(f, fpath) unless File.exist?(fpath)
141
+ end
142
+ end
143
+ end
144
+
145
+ def self.download_file_with_prompt(url, build_number)
146
+ file_path = File.join(Dir.pwd, "BCSymbolMaps-#{build_number}.zip")
147
+
148
+ if File.exists?(file_path)
149
+ if UI.confirm("File at #{file_path} is already exists. Do you want to overwrite it?")
150
+ UI.verbose("Overwriting an already exisiting file at #{file_path}")
151
+ File.rm(file_path)
152
+ self.download_file(url, file_path)
153
+ else
154
+ UI.verbose("Skipping download")
155
+ end
156
+ else
157
+ UI.message("Downloading a BCSymbolMaps")
158
+ self.download_file(url, file_path)
159
+ end
160
+
161
+ file_path
162
+ end
163
+
164
+ def self.download_file(url, file_path)
165
+ uri = URI.parse(url)
166
+ http = Net::HTTP.new(uri.host, uri.port)
167
+ http.use_ssl = (uri.scheme == "https")
168
+ res = http.get(uri.request_uri)
169
+ File.binwrite(file_path, res.body)
170
+ end
171
+
172
+ def self.prepare_destination_path(destination_path)
173
+ FileUtils.rm_r(destination_path) if Dir.exists?(destination_path)
174
+ FileUtils.mkdir_p(destination_path)
175
+ end
176
+ end
177
+ end
178
+ end
@@ -0,0 +1,5 @@
1
+ module Fastlane
2
+ module BitriseBcsymbolmaps
3
+ VERSION = "0.1.1"
4
+ end
5
+ end
metadata ADDED
@@ -0,0 +1,90 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: fastlane-plugin-bitrise_bcsymbolmaps
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.1
5
+ platform: ruby
6
+ authors:
7
+ - Oleksandr Skrypnyk
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2020-07-24 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: pry
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: bundler
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: fastlane
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: 2.148.0
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: 2.148.0
55
+ description:
56
+ email: olexandr.skrypnyk@me.com
57
+ executables: []
58
+ extensions: []
59
+ extra_rdoc_files: []
60
+ files:
61
+ - LICENSE
62
+ - README.md
63
+ - lib/fastlane/plugin/bitrise_bcsymbolmaps.rb
64
+ - lib/fastlane/plugin/bitrise_bcsymbolmaps/actions/bitrise_clean_bcsymbolmaps.rb
65
+ - lib/fastlane/plugin/bitrise_bcsymbolmaps/actions/bitrise_download_bcsymbolmaps.rb
66
+ - lib/fastlane/plugin/bitrise_bcsymbolmaps/version.rb
67
+ homepage: https://github.com/sxua/fastlane-plugin-bitrise_bcsymbolmaps
68
+ licenses:
69
+ - MIT
70
+ metadata: {}
71
+ post_install_message:
72
+ rdoc_options: []
73
+ require_paths:
74
+ - lib
75
+ required_ruby_version: !ruby/object:Gem::Requirement
76
+ requirements:
77
+ - - ">="
78
+ - !ruby/object:Gem::Version
79
+ version: '0'
80
+ required_rubygems_version: !ruby/object:Gem::Requirement
81
+ requirements:
82
+ - - ">="
83
+ - !ruby/object:Gem::Version
84
+ version: '0'
85
+ requirements: []
86
+ rubygems_version: 3.0.3
87
+ signing_key:
88
+ specification_version: 4
89
+ summary: Download BCSymbolMaps from Bitrise
90
+ test_files: []