fastlane-plugin-auto_version_name 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: 786d23d7922236df9c7f658a188c82be0e19c6de2135742caf00089a24cfbe39
4
+ data.tar.gz: 1b25b601ee511504b73ad010fdbf20c431af362946e43243b603a45298333f59
5
+ SHA512:
6
+ metadata.gz: 21acb54c2d35390b0d109a1ac37abee5d87fa845fc4a490b1d10204c3574d399e2a47658d0817128292de3b9e99c059a252cb341a869e049acd726e953157de0
7
+ data.tar.gz: d6767ad0df99cc1f2715ee2f12ec9bceb237fa9ee794952ea67823d61aeb57fe20a51f6b1f04ea4f328196ad82a56d31e207c022cb6ecfbe90f93298eda5e55e
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2022 gileadeteixeira <gileadeateixeira@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,183 @@
1
+ # auto_version_name plugin
2
+
3
+ [![fastlane Plugin Badge](https://rawcdn.githack.com/fastlane/fastlane/master/fastlane/assets/plugin-badge.svg)](https://rubygems.org/gems/fastlane-plugin-auto_version_name)
4
+
5
+ ## Getting Started
6
+
7
+ This project is a [_fastlane_](https://github.com/fastlane/fastlane) plugin. To get started with `fastlane-plugin-auto_version_name`, add it to your project by running:
8
+
9
+ ```bash
10
+ fastlane add_plugin auto_version_name
11
+ ```
12
+
13
+ ## About auto_version_name
14
+
15
+ Generate incremented version names from Apple and Google stores.
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` and `bundle exec fastlane test`.
20
+
21
+ **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)
22
+
23
+ ## Recommended Steps (Android & iOS)
24
+
25
+ 1 - In your `Root Directory`, create a `file` called `version_name`, with a minimal version that must be set as default:
26
+
27
+
28
+ ![image](https://user-images.githubusercontent.com/77688036/187472195-0295a9de-6381-4978-83c1-be189c76e676.png)
29
+
30
+ 2 - In your `Fastfiles`, create a `method` that returns, in `String`, the last version name in production (Store):
31
+
32
+ ```ruby
33
+ platform :android do
34
+ # [...]
35
+ def get_live_version() # METHOD
36
+ return google_play_track_release_names().first
37
+ # main method returns an array by default. ["1.0.0"] => "1.0.0"
38
+ end
39
+ # [...]
40
+ end
41
+ ```
42
+
43
+ ```ruby
44
+ platform :ios do
45
+ # [...]
46
+ root_directory = `cd ../.. && pwd`.chomp
47
+
48
+ api_key = app_store_connect_api_key(
49
+ key_id: "YOURKEYID",
50
+ issuer_id: "YOUR-ISSUER-ID",
51
+ key_filepath: "path/to/your/key.p8",
52
+ )
53
+
54
+ app_identifier = "your.app.identifier"
55
+
56
+ def get_live_version() # METHOD
57
+ app_store_build_number(api_key: api_key, live: true, app_identifier: app_identifier)
58
+ return lane_context[SharedValues::LATEST_VERSION] # "1.0.0"
59
+ end
60
+ # [...]
61
+ end
62
+ ```
63
+
64
+ 3 - In your `Fastfiles`, create a `lane` to export the live version name:
65
+
66
+ ```ruby
67
+ platform :android do
68
+ # [...]
69
+ desc "Export live version name"
70
+ lane :live_version_name do
71
+ get_live_version()
72
+ end
73
+ # [...]
74
+ end
75
+ ```
76
+
77
+ ```ruby
78
+ platform :ios do
79
+ # [...]
80
+ desc "Export live version name"
81
+ lane :live_version_name do
82
+ get_live_version()
83
+ end
84
+ # [...]
85
+ end
86
+ ```
87
+
88
+ 4 - In your `Fastfiles`, inside your main `lane`, call the plugin, passing the minimum version, and the version referring to the current platform. To reference the version of another platform, import the respective Fastfile and invoke its respective version lane:
89
+
90
+ ```ruby
91
+ platform :android do
92
+ # [...]
93
+ desc "Export live version name"
94
+ lane :live_version_name do
95
+ get_live_version()
96
+ end
97
+
98
+ desc "Submit a new build to Internal Test on Google Play"
99
+ lane :deploy do
100
+ # [...]
101
+ root_directory = `cd ../.. && pwd`.chomp
102
+
103
+ ios_lane = import("../../ios/fastlane/Fastfile")
104
+
105
+ version = auto_version_name(
106
+ minimal_version_string: File.open("#{root_directory}/version_name").read.chomp,
107
+ android_live_version: get_live_version(),
108
+ ios_live_version: ios_lane.runner.execute("live_version_name", "ios"),
109
+ # IMPORTANT: if your version lanes have the same name, you need to especify the platform on execute
110
+ )
111
+
112
+ puts version
113
+ # [...]
114
+ end
115
+ # [...]
116
+ end
117
+ ```
118
+
119
+ ```ruby
120
+ platform :ios do
121
+ # [...]
122
+ desc "Export live version name"
123
+ lane :live_version_name do
124
+ get_live_version()
125
+ end
126
+
127
+ desc "Push a new beta build to TestFlight"
128
+ lane :deploy do
129
+ # [...]
130
+ root_directory = `cd ../.. && pwd`.chomp
131
+
132
+ android_lane = import("#{root_directory}/android/fastlane/Fastfile")
133
+
134
+ version = auto_version_name(
135
+ minimal_version_string: File.open("#{root_directory}/version_name").read.chomp,
136
+ ios_live_version: get_live_version(),
137
+ android_live_version: android_lane.runner.execute("live_version_name", "android"),
138
+ # IMPORTANT: if your version lanes have the same name, you need to especify the platform on execute
139
+ )
140
+
141
+ puts version
142
+ # [...]
143
+ end
144
+ # [...]
145
+ end
146
+ ```
147
+
148
+ **Notes**
149
+
150
+ - If you don't pass parameters, the version considered will always be "1.0.0".
151
+
152
+ - Auto increment will only work if some live version is passed as parameter.
153
+
154
+ - The base version will always be the largest among the options passed as a parameter. Version comparison uses [Gem::Version](https://ruby-doc.org/stdlib-2.5.0/libdoc/rubygems/rdoc/Gem/Version.html#method-i-3C-3D-3E).
155
+
156
+ ## Run tests for this plugin
157
+
158
+ To run both the tests, and code style validation, run
159
+
160
+ ```
161
+ rake
162
+ ```
163
+
164
+ To automatically fix many of the styling issues, use
165
+ ```
166
+ rubocop -a
167
+ ```
168
+
169
+ ## Issues and Feedback
170
+
171
+ For any other issues and feedback about this plugin, please submit it to this repository.
172
+
173
+ ## Troubleshooting
174
+
175
+ If you have trouble using plugins, check out the [Plugins Troubleshooting](https://docs.fastlane.tools/plugins/plugins-troubleshooting/) guide.
176
+
177
+ ## Using _fastlane_ Plugins
178
+
179
+ For more information about how the `fastlane` plugin system works, check out the [Plugins documentation](https://docs.fastlane.tools/plugins/create-plugin/).
180
+
181
+ ## About _fastlane_
182
+
183
+ _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,136 @@
1
+ require 'fastlane/action'
2
+ require_relative '../helper/auto_version_name_helper'
3
+
4
+ module Fastlane
5
+ module Actions
6
+ class AutoVersionNameAction < Action
7
+ def self.run(params)
8
+ def self.version_string_to_array(version_string)
9
+ return version_string.split('.').map { |value| value.to_i }
10
+ end
11
+
12
+ def self.get_greater_version(version1, version2, version3)
13
+ greater_version = ""
14
+
15
+ version1 = version1 == nil ? "" : version1
16
+ version2 = version2 == nil ? "" : version2
17
+ version3 = version3 == nil ? "" : version3
18
+
19
+ is_v1_greater = Gem::Version.new(version1) >= Gem::Version.new(version2) && Gem::Version.new(version1) >= Gem::Version.new(version3)
20
+
21
+ is_v2_greater = Gem::Version.new(version2) >= Gem::Version.new(version1) && Gem::Version.new(version2) >= Gem::Version.new(version3)
22
+
23
+ is_v3_greater = Gem::Version.new(version3) >= Gem::Version.new(version1) && Gem::Version.new(version3) >= Gem::Version.new(version2)
24
+
25
+ if (is_v1_greater)
26
+ greater_version = version1
27
+ elsif (is_v2_greater)
28
+ greater_version = version2
29
+ elsif (is_v3_greater)
30
+ greater_version = version3
31
+ end
32
+
33
+ if (greater_version.empty? || greater_version == nil)
34
+ greater_version = "1.0.0"
35
+ end
36
+
37
+ return greater_version
38
+ end
39
+
40
+ # Initialize
41
+ branch = Actions.git_branch()
42
+ final_version_array = []
43
+ final_version_string = ""
44
+ minimal_version_string = params[:minimal_version]
45
+ ios_version_string = params[:ios_live_version]
46
+ android_version_string = params[:android_live_version]
47
+
48
+ final_version_array = get_greater_version(
49
+ minimal_version_string, ios_version_string, android_version_string
50
+ ).split('.').map { |value| value.to_i }
51
+
52
+ # Upgrade final version array and return
53
+ major = final_version_array[0]
54
+ minor = final_version_array[1]
55
+ patch = final_version_array[2]
56
+
57
+ # Auto increment.
58
+ # 1.0.1 => 1.0.1(+1) => 1.0.2 || 1.0.1 => 1.0(+1).1 => 1.1.0
59
+ if (branch.include? 'hotfix')
60
+ patch += 1
61
+ else
62
+ minor += 1
63
+ patch = 0
64
+ end
65
+
66
+ # Auto replacement if it reaches the limit.
67
+ # 1.999.1000 => 1.999(+1).0 => 1(+1).0.0 => 2.0.0
68
+ if(patch > 999)
69
+ patch = 0
70
+ minor += 1
71
+ end
72
+
73
+ if(minor > 999)
74
+ minor = 0
75
+ major += 1
76
+ end
77
+
78
+ live_versions_not_setted = (ios_version_string == nil || ios_version_string.empty?) && (android_version_string == nil || android_version_string.empty?)
79
+
80
+ unless (live_versions_not_setted)
81
+ final_version_array[0] = major
82
+ final_version_array[1] = minor
83
+ final_version_array[2] = patch
84
+ end
85
+
86
+ final_version_string = final_version_array.join('.') # [1, 0, 0] => "1.0.0"
87
+ return final_version_string
88
+ end
89
+
90
+ def self.description
91
+ "Generate incremented version names from Apple and Google stores"
92
+ end
93
+
94
+ def self.authors
95
+ ["gileadeteixeira"]
96
+ end
97
+
98
+ def self.return_value
99
+ # If your method provides a return value, you can describe here what it does
100
+ end
101
+
102
+ def self.details
103
+ # Optional:
104
+ ""
105
+ end
106
+
107
+ def self.available_options
108
+ [
109
+ FastlaneCore::ConfigItem.new(key: :minimal_version,
110
+ env_name: "MINIMAL_VERSION_STRING",
111
+ description: "A minimal version to be set",
112
+ optional: true,
113
+ type: String),
114
+ FastlaneCore::ConfigItem.new(key: :android_live_version,
115
+ env_name: "ANDROID_LIVE_VERSION",
116
+ description: "Android's live version name e.g. \"1.0.0\"",
117
+ optional: true,
118
+ type: String),
119
+ FastlaneCore::ConfigItem.new(key: :ios_live_version,
120
+ env_name: "IOS_LIVE_VERSION",
121
+ description: "iOS's live version name e.g. \"1.0.0\"",
122
+ optional: true,
123
+ type: String),
124
+ ]
125
+ end
126
+
127
+ def self.is_supported?(platform)
128
+ # Adjust this if your plugin only works for a particular platform (iOS vs. Android, for example)
129
+ # See: https://docs.fastlane.tools/advanced/#control-configuration-by-lane-and-by-platform
130
+ #
131
+ # [:ios, :mac, :android].include?(platform)
132
+ true
133
+ end
134
+ end
135
+ end
136
+ end
@@ -0,0 +1,16 @@
1
+ require 'fastlane_core/ui/ui'
2
+
3
+ module Fastlane
4
+ UI = FastlaneCore::UI unless Fastlane.const_defined?("UI")
5
+
6
+ module Helper
7
+ class AutoVersionNameHelper
8
+ # class methods that you define here become available in your action
9
+ # as `Helper::AutoVersionNameHelper.your_method`
10
+ #
11
+ def self.show_message
12
+ UI.message("Hello from the auto_version_name plugin helper!")
13
+ end
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,5 @@
1
+ module Fastlane
2
+ module AutoVersionName
3
+ VERSION = "0.1.0"
4
+ end
5
+ end
@@ -0,0 +1,16 @@
1
+ require 'fastlane/plugin/auto_version_name/version'
2
+
3
+ module Fastlane
4
+ module AutoVersionName
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::AutoVersionName.all_classes.each do |current|
15
+ require current
16
+ end
metadata ADDED
@@ -0,0 +1,188 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: fastlane-plugin-auto_version_name
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - gileadeteixeira
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2022-08-30 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
+ description:
154
+ email: gileadeateixeira@gmail.com
155
+ executables: []
156
+ extensions: []
157
+ extra_rdoc_files: []
158
+ files:
159
+ - LICENSE
160
+ - README.md
161
+ - lib/fastlane/plugin/auto_version_name.rb
162
+ - lib/fastlane/plugin/auto_version_name/actions/auto_version_name_action.rb
163
+ - lib/fastlane/plugin/auto_version_name/helper/auto_version_name_helper.rb
164
+ - lib/fastlane/plugin/auto_version_name/version.rb
165
+ homepage: https://github.com/App2Sales/fastlane-plugin-auto_version_name
166
+ licenses:
167
+ - MIT
168
+ metadata: {}
169
+ post_install_message:
170
+ rdoc_options: []
171
+ require_paths:
172
+ - lib
173
+ required_ruby_version: !ruby/object:Gem::Requirement
174
+ requirements:
175
+ - - ">="
176
+ - !ruby/object:Gem::Version
177
+ version: '2.5'
178
+ required_rubygems_version: !ruby/object:Gem::Requirement
179
+ requirements:
180
+ - - ">="
181
+ - !ruby/object:Gem::Version
182
+ version: '0'
183
+ requirements: []
184
+ rubygems_version: 3.0.9
185
+ signing_key:
186
+ specification_version: 4
187
+ summary: Generate incremented version names from Apple and Google stores
188
+ test_files: []