fastlane-plugin-android_versioning_kts 0.1.0 → 0.2.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: a6d0cc411f15eaa1426d3280109c7af26f6e8545ca5f52a22542cf490e5386c8
4
- data.tar.gz: d18e94c2670b2063de334ca26be51f3df0228046d7472af0be673bcf07635d55
3
+ metadata.gz: 852c0240e6569bfacdd645ad069a6edb7e8480d366522a61b56e7bb21b29e983
4
+ data.tar.gz: 3b24074101209e4e1b524b361085d6ad6ff2fc037542b07976697f445c115066
5
5
  SHA512:
6
- metadata.gz: bc9a2008ee34caf5405b366f7c0c4cd03aaa0fefffd9400f6ba4936b018e019a0f643e47fd4e513200a757dd1cd8c7f83ea2084c8a80aeae84eda2512d5f0417
7
- data.tar.gz: d08a4f1df14f9391fec4d1d2fd2b33686374cb4334609bd8f897233a29a53299eab51965d448820520ac294ebff8ed437c8691cee462a4c219345ef90ef3f00d
6
+ metadata.gz: 298f29aaf6eaeb7fb2e3a00f6b1e6e06c852ef81bcda7a20b0de2d2554074151870f315a241b34a63127ae70f91d71fe3640b07c1fb4bc880338e65e9fd9a6ad
7
+ data.tar.gz: e4c68d187f79caa0a1b7d75f8c453a441b8c9c62385863be7e6e587670f4734fe4b894238d7e46f6e45bdd76ca475b5ac0bbcd690be8060a0d3d1efadd6e2d41
data/LICENSE CHANGED
@@ -1,21 +1,21 @@
1
- The MIT License (MIT)
2
-
3
- Copyright (c) 2019 zmunm <atheist2197@naver.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.
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2019 zmunm <atheist2197@naver.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 CHANGED
@@ -1,52 +1,52 @@
1
- # android_versioning_kts 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_kts)
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_kts`, add it to your project by running:
8
-
9
- ```bash
10
- fastlane add_plugin android_versioning_kts
11
- ```
12
-
13
- ## About android_versioning_kts
14
-
15
- android versioning for gradle kotlin DSL
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).
1
+ # android_versioning_kts 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_kts)
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_kts`, add it to your project by running:
8
+
9
+ ```bash
10
+ fastlane add_plugin android_versioning_kts
11
+ ```
12
+
13
+ ## About android_versioning_kts
14
+
15
+ android versioning for gradle kotlin DSL
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).
@@ -1,16 +1,18 @@
1
- require 'fastlane/plugin/android_versioning_kts/version'
2
-
3
- module Fastlane
4
- module AndroidVersioningKts
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::AndroidVersioningKts.all_classes.each do |current|
15
- require current
16
- end
1
+ # frozen_string_literal: true
2
+
3
+ require 'fastlane/plugin/android_versioning_kts/version'
4
+
5
+ module Fastlane
6
+ module AndroidVersioningKts
7
+ # Return all .rb files inside the "actions" and "helper" directory
8
+ def self.all_classes
9
+ Dir[File.expand_path('**/{actions,helper}/*.rb', File.dirname(__FILE__))]
10
+ end
11
+ end
12
+ end
13
+
14
+ # By default we want to import all available actions and helpers
15
+ # A plugin can contain any number of actions and plugins
16
+ Fastlane::AndroidVersioningKts.all_classes.each do |current|
17
+ require current
18
+ end
@@ -1,72 +1,118 @@
1
- require 'fileutils'
2
-
3
- module Fastlane
4
- module Actions
5
- class GetValueFromBuildAction < Action
6
- def self.run(params)
7
- app_project_dir ||= params[:app_project_dir]
8
-
9
- type ||= params[:type]
10
-
11
- case type
12
- when "param"
13
- regex = Regexp.new(/\s*(?<key>#{params[:key]}\s*=\s*)(?<left>[\'\"]?)(?<value>[a-zA-Z0-9\.\_]*)(?<right>[\'\"]?)(?<comment>.*)/)
14
- when "function"
15
- regex = Regexp.new(/\s*(?<key>#{params[:key]}\s*\(\s*)(?<left>[\'\"]?)(?<value>[a-zA-Z0-9\.\_]*)(?<right>[\'\"]?)(?<comment>.*\).*)/)
16
- else
17
- throw "#{type} is not valid type"
18
- end
19
-
20
- value = ""
21
- found = false
22
- Dir.glob("#{app_project_dir}/build.gradle.kts") do |path|
23
- UI.verbose("path: #{path}")
24
- UI.verbose("absolute_path: #{File.expand_path(path)}")
25
- begin
26
- File.open(path, 'r') do |file|
27
- file.each_line do |line|
28
- unless line.match(regex) and !found
29
- next
30
- end
31
- key, left, value, right, comment = line.match(regex).captures
32
- break
33
- end
34
- file.close
35
- end
36
- end
37
- end
38
- return value
39
- end
40
-
41
- #####################################################
42
- # @!group Documentation
43
- #####################################################
44
- def self.available_options
45
- [
46
- FastlaneCore::ConfigItem.new(key: :app_project_dir,
47
- env_name: "ANDROID_VERSIONING_APP_PROJECT_DIR",
48
- description: "The path to the application source folder in the Android project (default: android/app)",
49
- optional: true,
50
- type: String,
51
- default_value: "android/app"),
52
- FastlaneCore::ConfigItem.new(key: :key,
53
- description: "The property key",
54
- type: String),
55
- FastlaneCore::ConfigItem.new(key: :type,
56
- description: "The property Type [\"function\", \"param\"])",
57
- type: String,
58
- default_value: "param")
59
-
60
- ]
61
- end
62
-
63
- def self.authors
64
- ["zmunm"]
65
- end
66
-
67
- def self.is_supported?(platform)
68
- platform == :android
69
- end
70
- end
71
- end
72
- end
1
+ # frozen_string_literal: true
2
+
3
+ require 'fileutils'
4
+
5
+ module Fastlane
6
+ module Actions
7
+ class GetValueFromBuildAction < Action
8
+ def self.run(params)
9
+ app_project_dir ||= params[:app_project_dir]
10
+
11
+ type ||= params[:type]
12
+
13
+ case type
14
+ when 'param'
15
+ regex = /
16
+ \s*
17
+ (?<key>#{params[:key]}\s*=\s*)
18
+ (?<left>['"]?)
19
+ (?<value>[a-zA-Z0-9._]*)
20
+ (?<right>['"]?)
21
+ (?<comment>.*)
22
+ /x
23
+ when 'function'
24
+ regex = /
25
+ \s*
26
+ (?<key>#{params[:key]}\s*\(\s*)
27
+ (?<left>['"]?)
28
+ (?<value>[a-zA-Z0-9._]*)
29
+ (?<right>['"]?)
30
+ (?<comment>.*\).*)
31
+ /x
32
+ else
33
+ throw "#{type} is not valid type"
34
+ end
35
+
36
+ flavor = params[:flavor]
37
+ flavor_specified = !(flavor.nil? or flavor.empty?)
38
+ regex_flavor = Regexp.new(/[ \t]create\("#{flavor}"\)[ \t]/)
39
+ value = ''
40
+ found = false
41
+ flavor_found = false
42
+ product_flavors_section = false
43
+
44
+ Dir.glob("#{app_project_dir}/build.gradle.kts") do |path|
45
+ UI.verbose("path: #{path}")
46
+ UI.verbose("absolute_path: #{File.expand_path(path)}")
47
+
48
+ File.open(path, 'r') do |file|
49
+ file.each_line do |line|
50
+ if flavor_specified && !product_flavors_section
51
+ next unless line.include? 'productFlavors'
52
+
53
+ product_flavors_section = true
54
+ end
55
+
56
+ if flavor_specified && !flavor_found
57
+ next unless line.match(regex_flavor)
58
+
59
+ flavor_found = true
60
+ end
61
+
62
+ next unless line.match(regex) && !found
63
+
64
+ key, left, value, right, comment = line.match(regex).captures
65
+ break
66
+ end
67
+ file.close
68
+ end
69
+ end
70
+ value
71
+ end
72
+
73
+ #####################################################
74
+ # @!group Documentation
75
+ #####################################################
76
+ def self.available_options
77
+ [
78
+ FastlaneCore::ConfigItem.new(
79
+ key: :app_project_dir,
80
+ env_name: 'ANDROID_VERSIONING_APP_PROJECT_DIR',
81
+ description: 'The path to the application source folder
82
+ in the Android project (default: android/app)',
83
+ optional: true,
84
+ type: String,
85
+ default_value: 'android/app'
86
+ ),
87
+ FastlaneCore::ConfigItem.new(
88
+ key: :flavor,
89
+ env_name: 'ANDROID_VERSIONING_FLAVOR',
90
+ description: 'The product flavor name (optional)',
91
+ optional: true,
92
+ type: String
93
+ ),
94
+ FastlaneCore::ConfigItem.new(
95
+ key: :key,
96
+ description: 'The property key',
97
+ type: String
98
+ ),
99
+ FastlaneCore::ConfigItem.new(
100
+ key: :type,
101
+ description: 'The property Type ["function", "param"])',
102
+ type: String,
103
+ default_value: 'param'
104
+ )
105
+
106
+ ]
107
+ end
108
+
109
+ def self.authors
110
+ ['zmunm']
111
+ end
112
+
113
+ def self.is_supported?(platform)
114
+ platform == :android
115
+ end
116
+ end
117
+ end
118
+ end
@@ -1,53 +1,67 @@
1
- require 'fileutils'
2
-
3
- module Fastlane
4
- module Actions
5
- class GetVersionCodeAction < Action
6
- def self.run(params)
7
- GetValueFromBuildAction.run(
8
- app_project_dir: params[:app_project_dir],
9
- key: 'versionCode',
10
- type: 'param'
11
- )
12
- end
13
-
14
- #####################################################
15
- # @!group Documentation
16
- #####################################################
17
- def self.available_options
18
- [
19
- FastlaneCore::ConfigItem.new(key: :app_project_dir,
20
- env_name: 'ANDROID_VERSIONING_APP_PROJECT_DIR',
21
- description: 'The path to the application source folder in the Android project (default: android/app)',
22
- optional: true,
23
- type: String,
24
- default_value: 'android/app')
25
- ]
26
- end
27
-
28
- def self.description
29
- 'Get the version code of your project'
30
- end
31
-
32
- def self.details
33
- [
34
- "This action will return the current version code set on your project's build.gradle.kts."
35
- ].join(' ')
36
- end
37
-
38
- def self.output
39
- [
40
- ['VERSION_CODE', 'The version code']
41
- ]
42
- end
43
-
44
- def self.authors
45
- ['zmunm']
46
- end
47
-
48
- def self.is_supported?(platform)
49
- platform == :android
50
- end
51
- end
52
- end
53
- end
1
+ # frozen_string_literal: true
2
+
3
+ require 'fileutils'
4
+
5
+ module Fastlane
6
+ module Actions
7
+ class GetVersionCodeAction < Action
8
+ def self.run(params)
9
+ GetValueFromBuildAction.run(
10
+ app_project_dir: params[:app_project_dir],
11
+ flavor: params[:flavor],
12
+ key: 'versionCode',
13
+ type: 'param'
14
+ )
15
+ end
16
+
17
+ #####################################################
18
+ # @!group Documentation
19
+ #####################################################
20
+ def self.available_options
21
+ [
22
+ FastlaneCore::ConfigItem.new(
23
+ key: :app_project_dir,
24
+ env_name: 'ANDROID_VERSIONING_APP_PROJECT_DIR',
25
+ description: 'The path to the application source folder
26
+ in the Android project (default: android/app)',
27
+ optional: true,
28
+ type: String,
29
+ default_value: 'android/app'
30
+ ),
31
+ FastlaneCore::ConfigItem.new(
32
+ key: :flavor,
33
+ env_name: 'ANDROID_VERSIONING_FLAVOR',
34
+ description: 'The product flavor name (optional)',
35
+ optional: true,
36
+ type: String
37
+ )
38
+ ]
39
+ end
40
+
41
+ def self.description
42
+ 'Get the version code of your project'
43
+ end
44
+
45
+ def self.details
46
+ [
47
+ "This action will return the current version code set
48
+ on your project's build.gradle.kts."
49
+ ].join(' ')
50
+ end
51
+
52
+ def self.output
53
+ [
54
+ ['VERSION_CODE', 'The version code']
55
+ ]
56
+ end
57
+
58
+ def self.authors
59
+ ['zmunm']
60
+ end
61
+
62
+ def self.is_supported?(platform)
63
+ platform == :android
64
+ end
65
+ end
66
+ end
67
+ end
@@ -1,53 +1,66 @@
1
- require 'fileutils'
2
-
3
- module Fastlane
4
- module Actions
5
- class GetVersionNameAction < Action
6
- def self.run(params)
7
- GetValueFromBuildAction.run(
8
- app_project_dir: params[:app_project_dir],
9
- key: 'versionName',
10
- type: 'param'
11
- )
12
- end
13
-
14
- #####################################################
15
- # @!group Documentation
16
- #####################################################
17
- def self.available_options
18
- [
19
- FastlaneCore::ConfigItem.new(key: :app_project_dir,
20
- env_name: 'ANDROID_VERSIONING_APP_PROJECT_DIR',
21
- description: 'The path to the application source folder in the Android project (default: android/app)',
22
- optional: true,
23
- type: String,
24
- default_value: 'android/app')
25
- ]
26
- end
27
-
28
- def self.description
29
- 'Get the version name of your project'
30
- end
31
-
32
- def self.details
33
- [
34
- "This action will return the current version name set on your project's build.gradle.kts."
35
- ].join(' ')
36
- end
37
-
38
- def self.output
39
- [
40
- ['VERSION_NAME', 'The version name']
41
- ]
42
- end
43
-
44
- def self.authors
45
- ['zmunm']
46
- end
47
-
48
- def self.is_supported?(platform)
49
- platform == :android
50
- end
51
- end
52
- end
53
- end
1
+ # frozen_string_literal: true
2
+
3
+ require 'fileutils'
4
+
5
+ module Fastlane
6
+ module Actions
7
+ class GetVersionNameAction < Action
8
+ def self.run(params)
9
+ GetValueFromBuildAction.run(
10
+ app_project_dir: params[:app_project_dir],
11
+ flavor: params[:flavor],
12
+ key: 'versionName',
13
+ type: 'param'
14
+ )
15
+ end
16
+
17
+ #####################################################
18
+ # @!group Documentation
19
+ #####################################################
20
+ def self.available_options
21
+ [
22
+ FastlaneCore::ConfigItem.new(
23
+ key: :app_project_dir,
24
+ env_name: 'ANDROID_VERSIONING_APP_PROJECT_DIR',
25
+ description: 'The path to the application source folder in the Android project (default: android/app)',
26
+ optional: true,
27
+ type: String,
28
+ default_value: 'android/app'
29
+ ),
30
+ FastlaneCore::ConfigItem.new(
31
+ key: :flavor,
32
+ env_name: 'ANDROID_VERSIONING_FLAVOR',
33
+ description: 'The product flavor name (optional)',
34
+ optional: true,
35
+ type: String
36
+ )
37
+ ]
38
+ end
39
+
40
+ def self.description
41
+ 'Get the version name of your project'
42
+ end
43
+
44
+ def self.details
45
+ [
46
+ "This action will return the current version name set
47
+ on your project's build.gradle.kts."
48
+ ].join(' ')
49
+ end
50
+
51
+ def self.output
52
+ [
53
+ ['VERSION_NAME', 'The version name']
54
+ ]
55
+ end
56
+
57
+ def self.authors
58
+ ['zmunm']
59
+ end
60
+
61
+ def self.is_supported?(platform)
62
+ platform == :android
63
+ end
64
+ end
65
+ end
66
+ end
@@ -0,0 +1,92 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'tempfile'
4
+ require 'fileutils'
5
+
6
+ module Fastlane
7
+ module Actions
8
+ module SharedValues
9
+ VERSION_CODE = :VERSION_CODE
10
+ end
11
+
12
+ class IncrementVersionCodeAction < Action
13
+ def self.run(params)
14
+ current_version_code = GetVersionCodeAction.run(params)
15
+
16
+ new_version_code =
17
+ if params[:version_code].nil?
18
+ current_version_code.to_i + 1
19
+ elsif params[:version_code] == -1
20
+ ((Time.now.to_f * 1000).to_i / (60 * 1000)).to_i
21
+ else
22
+ params[:version_code].to_i
23
+ end
24
+
25
+ SetValueInBuildAction.run(
26
+ app_project_dir: params[:app_project_dir],
27
+ flavor: params[:flavor],
28
+ key: 'versionCode',
29
+ value: new_version_code
30
+ )
31
+ Actions.lane_context[SharedValues::VERSION_CODE] = new_version_code.to_s
32
+ new_version_code.to_s
33
+ end
34
+
35
+ #####################################################
36
+ # @!group Documentation
37
+ #####################################################
38
+ def self.available_options
39
+ [
40
+ FastlaneCore::ConfigItem.new(
41
+ key: :app_project_dir,
42
+ env_name: 'ANDROID_VERSIONING_APP_PROJECT_DIR',
43
+ description: 'The path to the application source folder
44
+ in the Android project (default: android/app)',
45
+ optional: true,
46
+ type: String,
47
+ default_value: 'android/app'
48
+ ),
49
+ FastlaneCore::ConfigItem.new(
50
+ key: :flavor,
51
+ env_name: 'ANDROID_VERSIONING_FLAVOR',
52
+ description: 'The product flavor name (optional)',
53
+ optional: true,
54
+ type: String
55
+ ),
56
+ FastlaneCore::ConfigItem.new(
57
+ key: :version_code,
58
+ env_name: 'ANDROID_VERSIONING_VERSION_CODE',
59
+ description: 'Change to a specific version (optional)',
60
+ optional: true,
61
+ type: Integer
62
+ )
63
+ ]
64
+ end
65
+
66
+ def self.description
67
+ 'Increment the version code of your project'
68
+ end
69
+
70
+ def self.details
71
+ [
72
+ 'This action will increment the version code directly
73
+ in build.gradle.kts'
74
+ ].join("\n")
75
+ end
76
+
77
+ def self.output
78
+ [
79
+ ['VERSION_CODE', 'The new version code']
80
+ ]
81
+ end
82
+
83
+ def self.authors
84
+ ['Manabu OHTAKE']
85
+ end
86
+
87
+ def self.is_supported?(platform)
88
+ platform == :android
89
+ end
90
+ end
91
+ end
92
+ end
@@ -0,0 +1,125 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'tempfile'
4
+ require 'fileutils'
5
+
6
+ module Fastlane
7
+ module Actions
8
+ module SharedValues
9
+ VERSION_NAME = :VERSION_NAME
10
+ end
11
+
12
+ class IncrementVersionNameAction < Action
13
+ def self.run(params)
14
+ if params[:version_name].nil? || params[:version_name].empty?
15
+ current_version = GetVersionNameAction.run(params)
16
+ unless current_version =~ /\d+.\d+.\d+/
17
+ UI.user_error!(
18
+ "Your current version (#{current_version})
19
+ does not respect the format A.B.C"
20
+ )
21
+ end
22
+ version = current_version.split('.').map(&:to_i)
23
+ case params[:bump_type]
24
+ when 'patch'
25
+ version[2] = version[2] + 1
26
+ new_version = version.join('.')
27
+ when 'minor'
28
+ version[1] = version[1] + 1
29
+ version[2] = version[2] = 0
30
+ new_version = version.join('.')
31
+ when 'major'
32
+ version[0] = version[0] + 1
33
+ version[1] = 0
34
+ version[2] = 0
35
+ new_version = version.join('.')
36
+ end
37
+ else
38
+ new_version = params[:version_name]
39
+ end
40
+ SetValueInBuildAction.run(
41
+ app_project_dir: params[:app_project_dir],
42
+ flavor: params[:flavor],
43
+ key: 'versionName',
44
+ value: new_version
45
+ )
46
+ Actions.lane_context[SharedValues::VERSION_NAME] = new_version
47
+ new_version
48
+ end
49
+
50
+ #####################################################
51
+ # @!group Documentation
52
+ #####################################################
53
+ def self.available_options
54
+ [
55
+ FastlaneCore::ConfigItem.new(
56
+ key: :app_project_dir,
57
+ env_name: 'ANDROID_VERSIONING_APP_PROJECT_DIR',
58
+ description: 'The path to the application source folder
59
+ in the Android project (default: android/app)',
60
+ optional: true,
61
+ type: String,
62
+ default_value: 'android/app'
63
+ ),
64
+ FastlaneCore::ConfigItem.new(
65
+ key: :flavor,
66
+ env_name: 'ANDROID_VERSIONING_FLAVOR',
67
+ description: 'The product flavor name (optional)',
68
+ optional: true,
69
+ type: String
70
+ ),
71
+ FastlaneCore::ConfigItem.new(
72
+ key: :bump_type,
73
+ env_name: 'ANDROID_VERSIONING_BUMP_TYPE',
74
+ description: 'Change to a specific type (optional)',
75
+ optional: true,
76
+ type: String,
77
+ default_value: 'patch',
78
+ verify_block:
79
+ proc do |value|
80
+ unless %w[
81
+ patch minor major
82
+ ].include? value
83
+ UI.user_error!(
84
+ "Available values are 'patch', 'minor' and 'major'"
85
+ )
86
+ end
87
+ end
88
+ ),
89
+ FastlaneCore::ConfigItem.new(
90
+ key: :version_name,
91
+ env_name: 'ANDROID_VERSIONING_VERSION_NAME',
92
+ description: 'Change to a specific version (optional)',
93
+ optional: true,
94
+ type: String
95
+ )
96
+ ]
97
+ end
98
+
99
+ def self.description
100
+ 'Increment the version name of your project'
101
+ end
102
+
103
+ def self.details
104
+ [
105
+ 'This action will increment the version name directly
106
+ in build.gradle.kts'
107
+ ].join("\n")
108
+ end
109
+
110
+ def self.output
111
+ [
112
+ ['VERSION_NAME', 'The new version name']
113
+ ]
114
+ end
115
+
116
+ def self.authors
117
+ ['Manabu OHTAKE']
118
+ end
119
+
120
+ def self.is_supported?(platform)
121
+ platform == :android
122
+ end
123
+ end
124
+ end
125
+ end
@@ -0,0 +1,115 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'tempfile'
4
+ require 'fileutils'
5
+
6
+ module Fastlane
7
+ module Actions
8
+ class SetValueInBuildAction < Action
9
+ def self.run(params)
10
+ app_project_dir ||= params[:app_project_dir]
11
+ regex = /
12
+ (?<key>#{params[:key]}\s*=\s*)
13
+ (?<left>['"]?)
14
+ (?<value>[a-zA-Z0-9._]*)
15
+ (?<right>['"]?)
16
+ (?<comment>.*)
17
+ /x
18
+ flavor = params[:flavor]
19
+ flavor_specified = !(flavor.nil? or flavor.empty?)
20
+ regex_flavor = /[ \t]create\("#{flavor}"\)[ \t]/
21
+ found = false
22
+ product_flavors_section = false
23
+ flavor_found = false
24
+ Dir.glob("#{app_project_dir}/build.gradle.kts") do |path|
25
+ temp_file = Tempfile.new('versioning')
26
+ File.open(path, 'r') do |file|
27
+ file.each_line do |line|
28
+ if flavor_specified && !product_flavors_section
29
+ unless line.include?('productFlavors') || product_flavors_section
30
+ temp_file.puts line
31
+ next
32
+ end
33
+ product_flavors_section = true
34
+ end
35
+
36
+ if flavor_specified && !flavor_found
37
+ unless line.match(regex_flavor)
38
+ temp_file.puts line
39
+ next
40
+ end
41
+ flavor_found = true
42
+ end
43
+
44
+ unless line.match(regex) && !found
45
+ temp_file.puts line
46
+ next
47
+ end
48
+ line = line.gsub regex,
49
+ "\\k<key>\\k<left>#{params[:value]}\\k<right>\\k<comment>"
50
+ found = true
51
+ temp_file.puts line
52
+ end
53
+ file.close
54
+ end
55
+ temp_file.rewind
56
+ temp_file.close
57
+ FileUtils.mv(temp_file.path, path)
58
+ temp_file.unlink
59
+ end
60
+ end
61
+
62
+ #####################################################
63
+ # @!group Documentation
64
+ #####################################################
65
+ def self.available_options
66
+ [
67
+ FastlaneCore::ConfigItem.new(
68
+ key: :app_project_dir,
69
+ env_name: 'ANDROID_VERSIONING_APP_PROJECT_DIR',
70
+ description: 'The path to the application source folder
71
+ in the Android project (default: android/app)',
72
+ optional: true,
73
+ type: String,
74
+ default_value: 'android/app'
75
+ ),
76
+ FastlaneCore::ConfigItem.new(
77
+ key: :flavor,
78
+ env_name: 'ANDROID_VERSIONING_FLAVOR',
79
+ description: 'The product flavor name (optional)',
80
+ optional: true,
81
+ type: String
82
+ ),
83
+ FastlaneCore::ConfigItem.new(
84
+ key: :key,
85
+ description: 'The property key',
86
+ type: String
87
+ ),
88
+ FastlaneCore::ConfigItem.new(
89
+ key: :value,
90
+ description: 'The property value',
91
+ type: String
92
+ )
93
+ ]
94
+ end
95
+
96
+ def self.description
97
+ 'Set the value of your project'
98
+ end
99
+
100
+ def self.details
101
+ [
102
+ 'This action will set the value directly in build.gradle.kts '
103
+ ].join("\n")
104
+ end
105
+
106
+ def self.authors
107
+ ['Manabu OHTAKE']
108
+ end
109
+
110
+ def self.is_supported?(platform)
111
+ platform == :android
112
+ end
113
+ end
114
+ end
115
+ end
@@ -1,16 +1,18 @@
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 AndroidVersioningKtsHelper
8
- # class methods that you define here become available in your action
9
- # as `Helper::AndroidVersioningKtsHelper.your_method`
10
- #
11
- def self.show_message
12
- UI.message("Hello from the android_versioning_kts plugin helper!")
13
- end
14
- end
15
- end
16
- end
1
+ # frozen_string_literal: true
2
+
3
+ require 'fastlane_core/ui/ui'
4
+
5
+ module Fastlane
6
+ UI = FastlaneCore::UI unless Fastlane.const_defined?('UI')
7
+
8
+ module Helper
9
+ class AndroidVersioningKtsHelper
10
+ # class methods that you define here become available in your action
11
+ # as `Helper::AndroidVersioningKtsHelper.your_method`
12
+ #
13
+ def self.show_message
14
+ UI.message('Hello from the android_versioning_kts plugin helper!')
15
+ end
16
+ end
17
+ end
18
+ end
@@ -1,5 +1,7 @@
1
- module Fastlane
2
- module AndroidVersioningKts
3
- VERSION = "0.1.0"
4
- end
5
- end
1
+ # frozen_string_literal: true
2
+
3
+ module Fastlane
4
+ module AndroidVersioningKts
5
+ VERSION = '0.2.0'
6
+ end
7
+ end
metadata CHANGED
@@ -1,17 +1,17 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fastlane-plugin-android_versioning_kts
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - zmunm
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-09-18 00:00:00.000000000 Z
11
+ date: 2021-06-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- name: pry
14
+ name: bundler
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
17
  - - ">="
@@ -25,7 +25,21 @@ dependencies:
25
25
  - !ruby/object:Gem::Version
26
26
  version: '0'
27
27
  - !ruby/object:Gem::Dependency
28
- name: bundler
28
+ name: fastlane
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: 2.130.0
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: 2.130.0
41
+ - !ruby/object:Gem::Dependency
42
+ name: pry
29
43
  requirement: !ruby/object:Gem::Requirement
30
44
  requirements:
31
45
  - - ">="
@@ -39,7 +53,7 @@ dependencies:
39
53
  - !ruby/object:Gem::Version
40
54
  version: '0'
41
55
  - !ruby/object:Gem::Dependency
42
- name: rspec
56
+ name: rake
43
57
  requirement: !ruby/object:Gem::Requirement
44
58
  requirements:
45
59
  - - ">="
@@ -53,7 +67,7 @@ dependencies:
53
67
  - !ruby/object:Gem::Version
54
68
  version: '0'
55
69
  - !ruby/object:Gem::Dependency
56
- name: rspec_junit_formatter
70
+ name: rspec
57
71
  requirement: !ruby/object:Gem::Requirement
58
72
  requirements:
59
73
  - - ">="
@@ -67,7 +81,7 @@ dependencies:
67
81
  - !ruby/object:Gem::Version
68
82
  version: '0'
69
83
  - !ruby/object:Gem::Dependency
70
- name: rake
84
+ name: rspec_junit_formatter
71
85
  requirement: !ruby/object:Gem::Requirement
72
86
  requirements:
73
87
  - - ">="
@@ -122,21 +136,7 @@ dependencies:
122
136
  - - ">="
123
137
  - !ruby/object:Gem::Version
124
138
  version: '0'
125
- - !ruby/object:Gem::Dependency
126
- name: fastlane
127
- requirement: !ruby/object:Gem::Requirement
128
- requirements:
129
- - - ">="
130
- - !ruby/object:Gem::Version
131
- version: 2.130.0
132
- type: :development
133
- prerelease: false
134
- version_requirements: !ruby/object:Gem::Requirement
135
- requirements:
136
- - - ">="
137
- - !ruby/object:Gem::Version
138
- version: 2.130.0
139
- description:
139
+ description:
140
140
  email: atheist2197@gmail.com
141
141
  executables: []
142
142
  extensions: []
@@ -148,13 +148,16 @@ files:
148
148
  - lib/fastlane/plugin/android_versioning_kts/actions/get_value_from_build.rb
149
149
  - lib/fastlane/plugin/android_versioning_kts/actions/get_version_code.rb
150
150
  - lib/fastlane/plugin/android_versioning_kts/actions/get_version_name.rb
151
+ - lib/fastlane/plugin/android_versioning_kts/actions/increment_version_code.rb
152
+ - lib/fastlane/plugin/android_versioning_kts/actions/increment_version_name.rb
153
+ - lib/fastlane/plugin/android_versioning_kts/actions/set_value_in_build.rb
151
154
  - lib/fastlane/plugin/android_versioning_kts/helper/android_versioning_kts_helper.rb
152
155
  - lib/fastlane/plugin/android_versioning_kts/version.rb
153
156
  homepage: https://github.com/zmunm/fastlane-plugin-android-versioning-kts
154
157
  licenses:
155
158
  - MIT
156
159
  metadata: {}
157
- post_install_message:
160
+ post_install_message:
158
161
  rdoc_options: []
159
162
  require_paths:
160
163
  - lib
@@ -169,8 +172,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
169
172
  - !ruby/object:Gem::Version
170
173
  version: '0'
171
174
  requirements: []
172
- rubygems_version: 3.0.3
173
- signing_key:
175
+ rubygems_version: 3.1.4
176
+ signing_key:
174
177
  specification_version: 4
175
178
  summary: android versioning for gradle kotlin DSL
176
179
  test_files: []