fastlane-plugin-get_new_build_number 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 1cb15ed22b821b5c8e87b142076831b99a5774cd869de652074a846098c37df0
4
+ data.tar.gz: c9e847a9eab00c13534ec2422fe865bd0a46b60bc878b75609e1f45f0f1710ee
5
+ SHA512:
6
+ metadata.gz: 48d388a477de3ee5328aa86af91eb3641cbeb54726083605c6fa76226bfa4f9e0fd4655a505ac4b6713dfbb6743425e66f92b36bac90700a575860eab4b8a9ca
7
+ data.tar.gz: 3a9efed83d7068698e237234a14205f68463658d67e74fd08c31797c37880d1806379ba3626c882a22f368e61efca5a8df5bd2e244da1fcba26ebde3b2c3c6f0
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2022 Bartek Pacia <barpac02@gmail.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.
data/README.md ADDED
@@ -0,0 +1,52 @@
1
+ # get_new_build_number plugin
2
+
3
+ [![fastlane Plugin Badge](https://rawcdn.githack.com/fastlane/fastlane/master/fastlane/assets/plugin-badge.svg)](https://rubygems.org/gems/fastlane-plugin-get_new_build_number)
4
+
5
+ ## Getting Started
6
+
7
+ This project is a [_fastlane_](https://github.com/fastlane/fastlane) plugin. To get started with `fastlane-plugin-get_new_build_number`, add it to your project by running:
8
+
9
+ ```bash
10
+ fastlane add_plugin get_new_build_number
11
+ ```
12
+
13
+ ## About get_new_build_number
14
+
15
+ Retrieves the new build number for your app.
16
+
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
+ ## Example
20
+
21
+ Check out the [example `Fastfile`](fastlane/Fastfile) to see how to use this plugin. Try it by cloning the repo, running `fastlane install_plugins` and `bundle exec fastlane test`.
22
+
23
+ **Note to author:** Please set up a sample project to make it easy for users to explore what your plugin does. Provide everything that is necessary to try out the plugin in this project (including a sample Xcode/Android project if necessary)
24
+
25
+ ## Run tests for this plugin
26
+
27
+ To run both the tests, and code style validation, run
28
+
29
+ ```
30
+ rake
31
+ ```
32
+
33
+ To automatically fix many of the styling issues, use
34
+ ```
35
+ rubocop -a
36
+ ```
37
+
38
+ ## Issues and Feedback
39
+
40
+ For any other issues and feedback about this plugin, please submit it to this repository.
41
+
42
+ ## Troubleshooting
43
+
44
+ If you have trouble using plugins, check out the [Plugins Troubleshooting](https://docs.fastlane.tools/plugins/plugins-troubleshooting/) guide.
45
+
46
+ ## Using _fastlane_ Plugins
47
+
48
+ For more information about how the `fastlane` plugin system works, check out the [Plugins documentation](https://docs.fastlane.tools/plugins/create-plugin/).
49
+
50
+ ## About _fastlane_
51
+
52
+ _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,128 @@
1
+ require 'fastlane/action'
2
+ require 'tmpdir'
3
+
4
+ require_relative '../helper/get_new_build_number_helper'
5
+
6
+ module Fastlane
7
+ module Actions
8
+ class GetNewBuildNumberAction < Action
9
+ def self.run(params)
10
+ UI.message("The get_new_build_number plugin is working!")
11
+
12
+ UI.message("bundle_identifier: #{params[:bundle_identifier]}")
13
+ UI.message("package_name: #{params[:package_name]}")
14
+ UI.message("google_play_json_key_path: #{params[:google_play_json_key_path]}")
15
+ UI.message("firebase_json_key_path: #{params[:firebase_json_key_path]}")
16
+ UI.message("firebase_app_ios: #{params[:firebase_app_ios]}")
17
+ UI.message("firebase_app_android: #{params[:firebase_app_android]}")
18
+
19
+ file = "#{Dir.tmpdir}/highest_build_number.txt"
20
+ UI.message "Temp file location: #{file}"
21
+
22
+ if(File.exist?(file))
23
+ UI.success "File with new number file exists. Reading build number from it..."
24
+ highest_build_number = File.read(file).to_i
25
+ else
26
+ UI.message "File with new build number does not exist. New build number will be "\
27
+ "retrieved and file with it will be created."
28
+ highest_build_number = Helper::GetNewBuildNumberHelper.get_highest_build_number(
29
+ bundle_identifier: params[:bundle_identifier],
30
+ package_name: params[:package_name],
31
+ google_play_json_key_path: params[:google_play_json_key_path],
32
+ firebase_json_key_path: params[:firebase_json_key_path],
33
+ firebase_app_ios: params[:firebase_app_ios],
34
+ firebase_app_android: params[:firebase_app_android],
35
+ )
36
+
37
+ File.open(file, "w") { |f| f.write "#{highest_build_number}\n" }
38
+ end
39
+
40
+ UI.message "Highest build number: #{highest_build_number}"
41
+
42
+ if highest_build_number.is_a? Integer
43
+ new_highest_build_number = highest_build_number + 1
44
+ UI.message "New build number: #{new_highest_build_number}"
45
+ return new_highest_build_number
46
+ else
47
+ UI.error "Highest build number is not an Integer"
48
+ return nil
49
+
50
+ end
51
+ end
52
+
53
+ def self.description
54
+ "Retrieves the new build number for your app."
55
+ end
56
+
57
+ def self.authors
58
+ ["Bartek Pacia"]
59
+ end
60
+
61
+ def self.return_value
62
+ "An integer representing a new build number. It's the highest build "\
63
+ "number collected from all services (e.g App Store, Google Play, App "\
64
+ "Center) plus 1."
65
+ end
66
+
67
+ def self.details
68
+ # Optional:
69
+ ""
70
+ end
71
+
72
+ def self.available_options
73
+ [
74
+ FastlaneCore::ConfigItem.new(
75
+ key: :bundle_identifier,
76
+ env_name: "APP_BUNDLE_ID",
77
+ description: "iOS bundle identifier",
78
+ optional: true,
79
+ type: String,
80
+ ),
81
+ FastlaneCore::ConfigItem.new(
82
+ key: :package_name,
83
+ env_name: "APP_PACKAGE_NAME",
84
+ description: "Android package name",
85
+ optional: true,
86
+ type: String,
87
+ ),
88
+ FastlaneCore::ConfigItem.new(
89
+ key: :google_play_json_key_path,
90
+ env_name: "GOOGLE_PLAY_JSON_KEY_PATH",
91
+ description: "Path to the Google Play Android Developer JSON key",
92
+ optional: true,
93
+ type: String,
94
+ ),
95
+ FastlaneCore::ConfigItem.new(
96
+ key: :firebase_json_key_path,
97
+ env_name: "FIREBASE_JSON_KEY_PATH",
98
+ description: "Path to the Firebase Admin JSON key",
99
+ optional: true,
100
+ type: String,
101
+ ),
102
+ FastlaneCore::ConfigItem.new(
103
+ key: :firebase_app_ios,
104
+ env_name: "FIREBASE_APP_IOS",
105
+ description: "Firebase iOS app ID",
106
+ optional: true,
107
+ type: String,
108
+ ),
109
+ FastlaneCore::ConfigItem.new(
110
+ key: :firebase_app_android,
111
+ env_name: "FIREBASE_APP_ANDROID",
112
+ description: "Firebase Android app ID",
113
+ optional: true,
114
+ type: String,
115
+ ),
116
+ ]
117
+ end
118
+
119
+ def self.is_supported?(platform)
120
+ # Adjust this if your plugin only works for a particular platform (iOS vs. Android, for example)
121
+ # See: https://docs.fastlane.tools/advanced/#control-configuration-by-lane-and-by-platform
122
+ #
123
+ # [:ios, :mac, :android].include?(platform)
124
+ true
125
+ end
126
+ end
127
+ end
128
+ end
@@ -0,0 +1,121 @@
1
+ require 'fastlane_core/ui/ui'
2
+ require 'tmpdir'
3
+
4
+ module Fastlane
5
+ UI = FastlaneCore::UI unless Fastlane.const_defined?("UI")
6
+
7
+ module Helper
8
+ class GetNewBuildNumberHelper
9
+ # class methods that you define here become available in your action
10
+ # as `Helper::GetNewBuildNumberHelper.your_method`
11
+ #
12
+ def self.show_message
13
+ UI.message("Hello from the get_new_build_number plugin helper!")
14
+ end
15
+
16
+ def self.get_highest_build_number(
17
+ bundle_identifier:nil,
18
+ package_name:nil,
19
+ google_play_json_key_path:nil,
20
+ firebase_json_key_path:nil,
21
+ firebase_app_ios:nil,
22
+ firebase_app_android:nil
23
+ )
24
+ if bundle_identifier.nil? && package_name.nil?
25
+ UI.error "Both bundle_identifier and package_name are nil"
26
+ return nil
27
+ end
28
+
29
+ if package_name.nil? && google_play_json_key_path.nil?
30
+ UI.error "Both package_name and google_play_json_key_path are nil"
31
+ return nil
32
+ end
33
+
34
+ app_store_build_number = 0
35
+ unless bundle_identifier.nil?
36
+ app_store_build_number = Fastlane::Actions::LatestTestflightBuildNumberAction.run(
37
+ app_identifier: bundle_identifier,
38
+ )
39
+
40
+ UI.message "build number (App Store): #{app_store_build_number}"
41
+ end
42
+
43
+ google_play_build_number_prod = get_version_code(
44
+ track: "production",
45
+ package_name: package_name,
46
+ json_key: google_play_json_key_path,
47
+ )
48
+
49
+ google_play_build_number_beta = get_version_code(
50
+ track: "beta",
51
+ package_name: package_name,
52
+ json_key: google_play_json_key_path,
53
+ )
54
+
55
+ google_play_build_number_alpha = get_version_code(
56
+ track: "alpha",
57
+ package_name: package_name,
58
+ json_key: google_play_json_key_path,
59
+ )
60
+
61
+ google_play_build_number_internal = get_version_code(
62
+ track: "internal",
63
+ package_name: package_name,
64
+ json_key: google_play_json_key_path,
65
+ )
66
+
67
+ google_play_build_number = [
68
+ google_play_build_number_prod,
69
+ google_play_build_number_beta,
70
+ google_play_build_number_alpha,
71
+ google_play_build_number_internal,
72
+ ].max
73
+
74
+ UI.message "build number (Google Play Store): #{google_play_build_number}"
75
+
76
+ fad_build_number_ios = 0
77
+ unless firebase_app_ios.nil?
78
+ fad_build_number_ios = Fastlane::Actions::FirebaseAppDistributionGetLatestReleaseAction.run(
79
+ app: firebase_app_ios,
80
+ service_credentials_file: firebase_json_key_path,
81
+ )[:buildVersion].to_i
82
+
83
+ UI.message "build number (Firebase App Distribution iOS): #{fad_build_number_ios}"
84
+ end
85
+
86
+ fad_build_number_android = 0
87
+ unless firebase_app_android.nil?
88
+ fad_build_number_android = Fastlane::Actions::FirebaseAppDistributionGetLatestReleaseAction.run(
89
+ app: firebase_app_android,
90
+ service_credentials_file: firebase_json_key_path,
91
+ )[:buildVersion].to_i
92
+
93
+ UI.message "build number (Firebase App Distribution Android): #{fad_build_number_android}"
94
+ end
95
+
96
+ return [
97
+ app_store_build_number,
98
+ google_play_build_number,
99
+ fad_build_number_ios,
100
+ fad_build_number_android,
101
+ ].max
102
+ end
103
+
104
+ # Returns highest build number for the given track.
105
+ def self.get_version_code(track:, package_name:, json_key:)
106
+ begin
107
+ codes = google_play_track_version_codes(
108
+ track: track,
109
+ package_name: package_name,
110
+ json_key: json_key,
111
+ )
112
+
113
+ return codes.max
114
+ rescue
115
+ UI.error "Version code not found for track #{track}"
116
+ return 0
117
+ end
118
+ end
119
+ end
120
+ end
121
+ end
@@ -0,0 +1,5 @@
1
+ module Fastlane
2
+ module GetNewBuildNumber
3
+ VERSION = "0.1.0"
4
+ end
5
+ end
@@ -0,0 +1,16 @@
1
+ require 'fastlane/plugin/get_new_build_number/version'
2
+
3
+ module Fastlane
4
+ module GetNewBuildNumber
5
+ # Return all .rb files inside the "actions" and "helper" directory
6
+ def self.all_classes
7
+ Dir[File.expand_path('**/{actions,helper}/*.rb', File.dirname(__FILE__))]
8
+ end
9
+ end
10
+ end
11
+
12
+ # By default we want to import all available actions and helpers
13
+ # A plugin can contain any number of actions and plugins
14
+ Fastlane::GetNewBuildNumber.all_classes.each do |current|
15
+ require current
16
+ end
metadata ADDED
@@ -0,0 +1,202 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: fastlane-plugin-get_new_build_number
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Bartek Pacia
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2022-05-29 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
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: fastlane
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: 2.206.2
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: 2.206.2
41
+ - !ruby/object:Gem::Dependency
42
+ name: pry
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rake
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rspec
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: rspec_junit_formatter
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: rubocop
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - '='
102
+ - !ruby/object:Gem::Version
103
+ version: 1.12.1
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - '='
109
+ - !ruby/object:Gem::Version
110
+ version: 1.12.1
111
+ - !ruby/object:Gem::Dependency
112
+ name: rubocop-performance
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - ">="
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - ">="
123
+ - !ruby/object:Gem::Version
124
+ version: '0'
125
+ - !ruby/object:Gem::Dependency
126
+ name: rubocop-require_tools
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - ">="
130
+ - !ruby/object:Gem::Version
131
+ version: '0'
132
+ type: :development
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - ">="
137
+ - !ruby/object:Gem::Version
138
+ version: '0'
139
+ - !ruby/object:Gem::Dependency
140
+ name: simplecov
141
+ requirement: !ruby/object:Gem::Requirement
142
+ requirements:
143
+ - - ">="
144
+ - !ruby/object:Gem::Version
145
+ version: '0'
146
+ type: :development
147
+ prerelease: false
148
+ version_requirements: !ruby/object:Gem::Requirement
149
+ requirements:
150
+ - - ">="
151
+ - !ruby/object:Gem::Version
152
+ version: '0'
153
+ - !ruby/object:Gem::Dependency
154
+ name: fastlane-plugin-firebase_app_distribution
155
+ requirement: !ruby/object:Gem::Requirement
156
+ requirements:
157
+ - - ">="
158
+ - !ruby/object:Gem::Version
159
+ version: '0'
160
+ type: :runtime
161
+ prerelease: false
162
+ version_requirements: !ruby/object:Gem::Requirement
163
+ requirements:
164
+ - - ">="
165
+ - !ruby/object:Gem::Version
166
+ version: '0'
167
+ description:
168
+ email: barpac02@gmail.com
169
+ executables: []
170
+ extensions: []
171
+ extra_rdoc_files: []
172
+ files:
173
+ - LICENSE
174
+ - README.md
175
+ - lib/fastlane/plugin/get_new_build_number.rb
176
+ - lib/fastlane/plugin/get_new_build_number/actions/get_new_build_number_action.rb
177
+ - lib/fastlane/plugin/get_new_build_number/helper/get_new_build_number_helper.rb
178
+ - lib/fastlane/plugin/get_new_build_number/version.rb
179
+ homepage: https://github.com/bartekpacia/fastlane-plugin-get_new_build_number
180
+ licenses:
181
+ - MIT
182
+ metadata: {}
183
+ post_install_message:
184
+ rdoc_options: []
185
+ require_paths:
186
+ - lib
187
+ required_ruby_version: !ruby/object:Gem::Requirement
188
+ requirements:
189
+ - - ">="
190
+ - !ruby/object:Gem::Version
191
+ version: '2.5'
192
+ required_rubygems_version: !ruby/object:Gem::Requirement
193
+ requirements:
194
+ - - ">="
195
+ - !ruby/object:Gem::Version
196
+ version: '0'
197
+ requirements: []
198
+ rubygems_version: 3.3.3
199
+ signing_key:
200
+ specification_version: 4
201
+ summary: Retrieves the new build number for your app.
202
+ test_files: []