fastlane-plugin-android_versioning 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
+ SHA1:
3
+ metadata.gz: 1b8d53637bdc5f7a9a378084c65ccb7466b446d9
4
+ data.tar.gz: 11e44f2880c306080600eefd3af60ceae71cebac
5
+ SHA512:
6
+ metadata.gz: 51d17f075e9db8c7dcbcd03f866e3c09070f2745d643f43e9a0313fcdd382ae36a5b66b4571950d91a6a64ec8e641e852930a584f634e0dcff39dbd7481ef06d
7
+ data.tar.gz: 63cae38a551191c2fdd2df8b5ad4d66af1c10a0558914f853973cff066deba1f4f5e1c29399fecf20c21f737ba89d6c03dd8ccbea456290d60a40573f75e5f4a
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2017 Manabu OHTAKE <manabu2783@hotmail.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
+ # android_versioning plugin
2
+
3
+ [![fastlane Plugin Badge](https://rawcdn.githack.com/fastlane/fastlane/master/fastlane/assets/plugin-badge.svg)](https://rubygems.org/gems/fastlane-plugin-android_versioning)
4
+
5
+ ## Getting Started
6
+
7
+ This project is a [fastlane](https://github.com/fastlane/fastlane) plugin. To get started with `fastlane-plugin-android_versioning`, add it to your project by running:
8
+
9
+ ```bash
10
+ fastlane add_plugin android_versioning
11
+ ```
12
+
13
+ ## About android_versioning
14
+
15
+ Allows to set/get app version name and version code directly to/from build.gradle
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,16 @@
1
+ require 'fastlane/plugin/android_versioning/version'
2
+
3
+ module Fastlane
4
+ module AndroidVersioning
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::AndroidVersioning.all_classes.each do |current|
15
+ require current
16
+ end
@@ -0,0 +1,61 @@
1
+ require 'fileutils'
2
+
3
+ module Fastlane
4
+ module Actions
5
+ class GetValueFromBuildAction < Action
6
+ def self.run(params)
7
+ app_folder_name ||= params[:app_folder_name]
8
+ value = ""
9
+ found = false
10
+ Dir.glob("**/#{app_folder_name}/build.gradle") do |path|
11
+ begin
12
+ File.open(path, 'r') do |file|
13
+ file.each_line do |line|
14
+ unless line.include? "#{params[:key]} " and !found
15
+ next
16
+ end
17
+ components = line.strip.split(' ')
18
+ value = components.last.tr("\"", "").tr("\'", "")
19
+ break
20
+ end
21
+ file.close
22
+ end
23
+ end
24
+ end
25
+ return value
26
+ end
27
+
28
+ #####################################################
29
+ # @!group Documentation
30
+ #####################################################
31
+ def self.available_options
32
+ [
33
+ FastlaneCore::ConfigItem.new(key: :app_folder_name,
34
+ env_name: "ANDROID_VERSIONING_APP_FOLDER_NAME",
35
+ description: "The name of the application source folder in the Android project (default: app)",
36
+ optional: true,
37
+ type: String,
38
+ default_value: "app"),
39
+ FastlaneCore::ConfigItem.new(key: :key,
40
+ description: "The property key",
41
+ type: String)
42
+
43
+ ]
44
+ end
45
+
46
+ def self.output
47
+ [
48
+ ['PROPERTY_VALUE', 'The property value']
49
+ ]
50
+ end
51
+
52
+ def self.authors
53
+ ["Manabu OHTAKE"]
54
+ end
55
+
56
+ def self.is_supported?(platform)
57
+ platform == :android
58
+ end
59
+ end
60
+ end
61
+ end
@@ -0,0 +1,57 @@
1
+ require 'fileutils'
2
+
3
+ module Fastlane
4
+ module Actions
5
+ module SharedValues
6
+ VERSION_CODE = :VERSION_CODE
7
+ end
8
+ class GetVersionCodeAction < Action
9
+ def self.run(params)
10
+ code = GetValueFromBuildAction.run(
11
+ app_folder_name: params[:app_folder_name],
12
+ key: "versionCode"
13
+ )
14
+ Actions.lane_context[SharedValues::VERSION_CODE] = code
15
+ code
16
+ end
17
+
18
+ #####################################################
19
+ # @!group Documentation
20
+ #####################################################
21
+ def self.available_options
22
+ [
23
+ FastlaneCore::ConfigItem.new(key: :app_folder_name,
24
+ env_name: "ANDROID_VERSIONING_APP_FOLDER_NAME",
25
+ description: "The name of the application source folder in the Android project (default: app)",
26
+ optional: true,
27
+ type: String,
28
+ default_value: "app")
29
+ ]
30
+ end
31
+
32
+ def self.description
33
+ "Get the version code of your project"
34
+ end
35
+
36
+ def self.details
37
+ [
38
+ "This action will return the current version code set on your project's build.gradle."
39
+ ].join(' ')
40
+ end
41
+
42
+ def self.output
43
+ [
44
+ ['VERSION_CODE', 'The version code']
45
+ ]
46
+ end
47
+
48
+ def self.authors
49
+ ["Manabu OHTAKE"]
50
+ end
51
+
52
+ def self.is_supported?(platform)
53
+ platform == :android
54
+ end
55
+ end
56
+ end
57
+ end
@@ -0,0 +1,57 @@
1
+ require 'fileutils'
2
+
3
+ module Fastlane
4
+ module Actions
5
+ module SharedValues
6
+ VERSION_NAME = :VERSION_NAME
7
+ end
8
+ class GetVersionNameAction < Action
9
+ def self.run(params)
10
+ name = GetValueFromBuildAction.run(
11
+ app_folder_name: params[:app_folder_name],
12
+ key: "versionName"
13
+ )
14
+ Actions.lane_context[SharedValues::VERSION_NAME] = name
15
+ name
16
+ end
17
+
18
+ #####################################################
19
+ # @!group Documentation
20
+ #####################################################
21
+ def self.available_options
22
+ [
23
+ FastlaneCore::ConfigItem.new(key: :app_folder_name,
24
+ env_name: "ANDROID_VERSIONING_APP_FOLDER_NAME",
25
+ description: "The name of the application source folder in the Android project (default: app)",
26
+ optional: true,
27
+ type: String,
28
+ default_value: "app")
29
+ ]
30
+ end
31
+
32
+ def self.description
33
+ "Get the version name of your project"
34
+ end
35
+
36
+ def self.details
37
+ [
38
+ "This action will return the current version name set on your project's build.gradle."
39
+ ].join(' ')
40
+ end
41
+
42
+ def self.output
43
+ [
44
+ ['VERSION_NAME', 'The version name']
45
+ ]
46
+ end
47
+
48
+ def self.authors
49
+ ["Manabu OHTAKE"]
50
+ end
51
+
52
+ def self.is_supported?(platform)
53
+ platform == :android
54
+ end
55
+ end
56
+ end
57
+ end
@@ -0,0 +1,66 @@
1
+ require 'tempfile'
2
+ require 'fileutils'
3
+
4
+ module Fastlane
5
+ module Actions
6
+ module SharedValues
7
+ VERSION_CODE = :VERSION_CODE
8
+ end
9
+ class IncrementVersionCodeAction < Action
10
+ def self.run(params)
11
+ current_version_code = GetVersionCodeAction.run(params)
12
+ new_version_code = params[:version_code].nil? || params[:version_code].empty? ? current_version_code.to_i + 1 : params[:version_code].to_i
13
+ SetValueInBuildAction.run(
14
+ app_folder_name: params[:app_folder_name],
15
+ key: "versionCode",
16
+ value: new_version_code
17
+ )
18
+ Actions.lane_context[SharedValues::VERSION_CODE] = new_version_code.to_s
19
+ new_version_code.to_s
20
+ end
21
+
22
+ #####################################################
23
+ # @!group Documentation
24
+ #####################################################
25
+ def self.available_options
26
+ [
27
+ FastlaneCore::ConfigItem.new(key: :app_folder_name,
28
+ env_name: "ANDROID_VERSIONING_APP_FOLDER_NAME",
29
+ description: "The name of the application source folder in the Android project (default: app)",
30
+ optional: true,
31
+ type: String,
32
+ default_value: "app"),
33
+ FastlaneCore::ConfigItem.new(key: :version_code,
34
+ env_name: "ANDROID_VERSIONING_VERSION_CODE",
35
+ description: "Change to a specific version (optional)",
36
+ optional: true,
37
+ type: Integer)
38
+ ]
39
+ end
40
+
41
+ def self.description
42
+ "Increment the version code of your project"
43
+ end
44
+
45
+ def self.details
46
+ [
47
+ "This action will increment the version code directly in build.gradle . "
48
+ ].join("\n")
49
+ end
50
+
51
+ def self.output
52
+ [
53
+ ['VERSION_CODE', 'The new version code']
54
+ ]
55
+ end
56
+
57
+ def self.authors
58
+ ["Manabu OHTAKE"]
59
+ end
60
+
61
+ def self.is_supported?(platform)
62
+ platform == :android
63
+ end
64
+ end
65
+ end
66
+ end
@@ -0,0 +1,93 @@
1
+ require 'tempfile'
2
+ require 'fileutils'
3
+
4
+ module Fastlane
5
+ module Actions
6
+ module SharedValues
7
+ VERSION_NAME = :VERSION_NAME
8
+ end
9
+ class IncrementVersionNameAction < Action
10
+ def self.run(params)
11
+ if params[:version_name].nil? or params[:version_name].empty?
12
+ current_version = GetVersionNameAction.run(params)
13
+ version = current_version.split(".").map(&:to_i)
14
+ case params[:bump_type]
15
+ when "patch"
16
+ version[2] = version[2] + 1
17
+ new_version = version.join(".")
18
+ when "minor"
19
+ version[1] = version[1] + 1
20
+ version[2] = version[2] = 0
21
+ new_version = version.join(".")
22
+ when "major"
23
+ version[0] = version[0] + 1
24
+ version[1] = 0
25
+ version[2] = 0
26
+ new_version = version.join(".")
27
+ end
28
+ else
29
+ new_version = params[:version_name]
30
+ end
31
+ SetValueInBuildAction.run(
32
+ app_folder_name: params[:app_folder_name],
33
+ key: "versionName",
34
+ value: new_version
35
+ )
36
+ Actions.lane_context[SharedValues::VERSION_NAME] = new_version
37
+ new_version
38
+ end
39
+
40
+ #####################################################
41
+ # @!group Documentation
42
+ #####################################################
43
+ def self.available_options
44
+ [
45
+ FastlaneCore::ConfigItem.new(key: :app_folder_name,
46
+ env_name: "ANDROID_VERSIONING_APP_FOLDER_NAME",
47
+ description: "The name of the application source folder in the Android project (default: app)",
48
+ optional: true,
49
+ type: String,
50
+ default_value: "app"),
51
+ FastlaneCore::ConfigItem.new(key: :bump_type,
52
+ env_name: "ANDROID_VERSIONING_BUMP_TYPE",
53
+ description: "Change to a specific type (optional)",
54
+ optional: true,
55
+ type: String,
56
+ default_value: "patch",
57
+ verify_block: proc do |value|
58
+ UI.user_error!("Available values are 'patch', 'minor' and 'major'") unless ['patch', 'minor', 'major'].include? value
59
+ end),
60
+ FastlaneCore::ConfigItem.new(key: :version_name,
61
+ env_name: "ANDROID_VERSIONING_VERSION_NAME",
62
+ description: "Change to a specific version (optional)",
63
+ optional: true,
64
+ type: String)
65
+ ]
66
+ end
67
+
68
+ def self.description
69
+ "Increment the version name of your project"
70
+ end
71
+
72
+ def self.details
73
+ [
74
+ "This action will increment the version name directly in build.gradle."
75
+ ].join("\n")
76
+ end
77
+
78
+ def self.output
79
+ [
80
+ ['VERSION_NAME', 'The new version name']
81
+ ]
82
+ end
83
+
84
+ def self.authors
85
+ ["Manabu OHTAKE"]
86
+ end
87
+
88
+ def self.is_supported?(platform)
89
+ platform == :android
90
+ end
91
+ end
92
+ end
93
+ end
@@ -0,0 +1,74 @@
1
+ require 'tempfile'
2
+ require 'fileutils'
3
+
4
+ module Fastlane
5
+ module Actions
6
+ class SetValueInBuildAction < Action
7
+ def self.run(params)
8
+ app_folder_name ||= params[:app_folder_name]
9
+ found = false
10
+ Dir.glob("**/#{app_folder_name}/build.gradle") do |path|
11
+ begin
12
+ temp_file = Tempfile.new('versioning')
13
+ File.open(path, 'r') do |file|
14
+ file.each_line do |line|
15
+ unless line.include? "#{params[:key]} " and !found
16
+ temp_file.puts line
17
+ next
18
+ end
19
+ components = line.strip.split(' ')
20
+ value = components.last.tr("\"", "").tr("\'", "")
21
+ line.replace line.sub(value, params[:value].to_s)
22
+ found = true
23
+ temp_file.puts line
24
+ end
25
+ file.close
26
+ end
27
+ temp_file.rewind
28
+ temp_file.close
29
+ FileUtils.mv(temp_file.path, path)
30
+ temp_file.unlink
31
+ end
32
+ end
33
+ end
34
+
35
+ #####################################################
36
+ # @!group Documentation
37
+ #####################################################
38
+ def self.available_options
39
+ [
40
+ FastlaneCore::ConfigItem.new(key: :app_folder_name,
41
+ env_name: "ANDROID_VERSIONING_APP_FOLDER_NAME",
42
+ description: "The name of the application source folder in the Android project (default: app)",
43
+ optional: true,
44
+ type: String,
45
+ default_value: "app"),
46
+ FastlaneCore::ConfigItem.new(key: :key,
47
+ description: "The property key",
48
+ type: String),
49
+ FastlaneCore::ConfigItem.new(key: :value,
50
+ description: "The property value",
51
+ type: String)
52
+ ]
53
+ end
54
+
55
+ def self.description
56
+ "Set the value of your project"
57
+ end
58
+
59
+ def self.details
60
+ [
61
+ "This action will set the value directly in build.gradle . "
62
+ ].join("\n")
63
+ end
64
+
65
+ def self.authors
66
+ ["Manabu OHTAKE"]
67
+ end
68
+
69
+ def self.is_supported?(platform)
70
+ platform == :android
71
+ end
72
+ end
73
+ end
74
+ end
@@ -0,0 +1,5 @@
1
+ module Fastlane
2
+ module AndroidVersioning
3
+ VERSION = "0.1.0"
4
+ end
5
+ end
metadata ADDED
@@ -0,0 +1,137 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: fastlane-plugin-android_versioning
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Manabu OHTAKE
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2017-02-18 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: rspec
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: rubocop
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: fastlane
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: 2.17.0
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: 2.17.0
97
+ description:
98
+ email: manabu2783@hotmail.com
99
+ executables: []
100
+ extensions: []
101
+ extra_rdoc_files: []
102
+ files:
103
+ - LICENSE
104
+ - README.md
105
+ - lib/fastlane/plugin/android_versioning.rb
106
+ - lib/fastlane/plugin/android_versioning/actions/get_value_from_build.rb
107
+ - lib/fastlane/plugin/android_versioning/actions/get_version_code.rb
108
+ - lib/fastlane/plugin/android_versioning/actions/get_version_name.rb
109
+ - lib/fastlane/plugin/android_versioning/actions/increment_version_code.rb
110
+ - lib/fastlane/plugin/android_versioning/actions/increment_version_name.rb
111
+ - lib/fastlane/plugin/android_versioning/actions/set_value_in_build.rb
112
+ - lib/fastlane/plugin/android_versioning/version.rb
113
+ homepage: https://github.com/otkmnb2783/fastlane-plugin-android_versioning
114
+ licenses:
115
+ - MIT
116
+ metadata: {}
117
+ post_install_message:
118
+ rdoc_options: []
119
+ require_paths:
120
+ - lib
121
+ required_ruby_version: !ruby/object:Gem::Requirement
122
+ requirements:
123
+ - - ">="
124
+ - !ruby/object:Gem::Version
125
+ version: '0'
126
+ required_rubygems_version: !ruby/object:Gem::Requirement
127
+ requirements:
128
+ - - ">="
129
+ - !ruby/object:Gem::Version
130
+ version: '0'
131
+ requirements: []
132
+ rubyforge_project:
133
+ rubygems_version: 2.4.5.1
134
+ signing_key:
135
+ specification_version: 4
136
+ summary: Allows to set/get app version name and version code directly to/from build.gradle
137
+ test_files: []