fastlane-plugin-xamversion 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 3364551440aef60486857d372e7e8092810900a57d8fcd275885eb3792e2431a
4
+ data.tar.gz: 6713488c6e712e722dea2d6b092f55920be8a06e5eabae20bbbb1dfd292de0f3
5
+ SHA512:
6
+ metadata.gz: 8efd7ef39540dc11c718fa1015c3ee24502f4715028e6d55654b77a059b64b002542b11e8244dc2a89377aa09121ea72c6575aa5f9abe66e7aa775f885b4d076
7
+ data.tar.gz: 317d4dcebd1e944d02cf7b9cea9690422ef47f1dacf2f53cd01ab96cd43735e53ce317d25d6baa14a4c15bce5b16d4f70e0b859103be39d6e8c29d9bdbc91e8a
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2020 Jake Barnby <j.barnby@we-are-mea.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,52 @@
1
+ # xamversion plugin
2
+
3
+ [![fastlane Plugin Badge](https://rawcdn.githack.com/fastlane/fastlane/master/fastlane/assets/plugin-badge.svg)](https://rubygems.org/gems/fastlane-plugin-xamversion)
4
+
5
+ ## Getting Started
6
+
7
+ This project is a [_fastlane_](https://github.com/fastlane/fastlane) plugin. To get started with `fastlane-plugin-xamversion`, add it to your project by running:
8
+
9
+ ```bash
10
+ fastlane add_plugin xamversion
11
+ ```
12
+
13
+ ## About xamversion
14
+
15
+ Read and manipulate Android and iOS app versions.
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/xamversion/version"
2
+
3
+ module Fastlane
4
+ module Xamversion
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::Xamversion.all_classes.each do |current|
15
+ require current
16
+ end
@@ -0,0 +1,157 @@
1
+ require "csproj"
2
+ require "csproj/platform"
3
+ require "mixlib/versioning"
4
+ require "fastlane/action"
5
+ require "fastlane/plugin/xamversion/helper/xamversion_helper"
6
+ require "fastlane/plugin/xamversion/options"
7
+
8
+ module Fastlane
9
+ module Actions
10
+ class XamversionAction < Action
11
+ def self.run(values)
12
+ values[:platform] = CsProj::Platform.from_lane_context(Actions.lane_context)
13
+
14
+ CsProj.config = values.values
15
+
16
+ current_version, current_build = set_version(
17
+ values[:version],
18
+ values[:build],
19
+ values[:plist_path],
20
+ values[:manifest_path]
21
+ )
22
+
23
+ if values[:bump] &&
24
+ !values[:version] &&
25
+ !values[:build] &&
26
+ !values[:readonly]
27
+ updated_version = do_version_bump_interactive(current_version)
28
+
29
+ puts "Update version: #{updated_version}"
30
+ new_version, new_build = set_version(
31
+ updated_version || current_version,
32
+ (current_build.to_i + 1).to_s,
33
+ values[:plist_path],
34
+ values[:manifest_path]
35
+ )
36
+ end
37
+
38
+ UI.important "Current Version is:"
39
+ UI.message " Version: #{new_version || current_version} #{"(was #{current_version})" if !new_version.nil? && new_version != current_version}"
40
+ UI.message " Build: #{new_build || current_build} #{"(was #{current_build})" if !new_build.nil? && new_build != current_build}"
41
+
42
+ {
43
+ version: new_version,
44
+ build: new_build
45
+ }
46
+ end
47
+
48
+ def self.do_version_bump_interactive(current_version)
49
+ bump_type = UI.select("Version bump type: ", ["Patch", "Minor", "Major"]).downcase
50
+ type_name = case bump_type
51
+ when "patch"
52
+ "bugfixes"
53
+ when "minor"
54
+ "features"
55
+ when "major"
56
+ "non-backwards compatible changes"
57
+ end
58
+
59
+ semver_version = Mixlib::Versioning.parse(current_version)
60
+
61
+ increment = UI.input("How many new #{type_name} were added since last release?")
62
+
63
+ if /\A\d+\Z/.match?(increment)
64
+ increment = increment.to_i
65
+ else
66
+ UI.user_error!("Not a valid integer!")
67
+ end
68
+
69
+ puts "Increment: #{increment}"
70
+
71
+ current_count = semver_version.instance_variable_get("@#{bump_type}")
72
+ puts "Current count: #{current_count}"
73
+
74
+ semver_version.instance_variable_set("@#{bump_type}", current_count + increment)
75
+ puts "Semver: #{semver_version.to_semver_string}"
76
+ semver_version.to_semver_string
77
+ end
78
+
79
+ def self.set_version(version, build, plist_path = nil, manifest_path = nil)
80
+ if CsProj.project.ios? || CsProj.project.osx?
81
+ set_plist_version(version, build, plist_path)
82
+ elsif CsProj.project.android?
83
+ set_manifest_version(version, build, manifest_path)
84
+ end
85
+ end
86
+
87
+ def self.set_plist_version(version, build, plist_path = nil)
88
+ plist_path ||= CsProj.config[:plist_path]
89
+ version ||= other_action.get_info_plist_value(path: plist_path, key: "CFBundleShortVersionString")
90
+ build ||= other_action.get_info_plist_value(path: plist_path, key: "CFBundleVersion")
91
+
92
+ other_action.set_info_plist_value(
93
+ path: plist_path,
94
+ key: "CFBundleShortVersionString",
95
+ value: version
96
+ )
97
+
98
+ other_action.set_info_plist_value(
99
+ path: plist_path,
100
+ key: "CFBundleVersion",
101
+ value: build
102
+ )
103
+
104
+ [version, build]
105
+ end
106
+
107
+ def self.set_manifest_version(version, build, manifest_path = nil)
108
+ manifest_path ||= CsProj.config[:manifest_path]
109
+
110
+ f1 = File.open(manifest_path)
111
+ doc = Nokogiri::XML(f1)
112
+ f1.close
113
+
114
+ attrs = doc.xpath("//manifest")[0]
115
+
116
+ version ||= attrs["android:versionName"]
117
+ build ||= attrs["android:versionCode"]
118
+
119
+ if version || build
120
+ attrs["android:versionName"] = version if version
121
+ attrs["android:versionCode"] = build if build
122
+
123
+ File.open(manifest_path, "w") do |f2|
124
+ f2.print(doc.to_xml)
125
+ end
126
+ end
127
+
128
+ [version, build]
129
+ end
130
+
131
+ def self.description
132
+ "Read and manipulate Android and iOS app versions."
133
+ end
134
+
135
+ def self.authors
136
+ ["Jake Barnby"]
137
+ end
138
+
139
+ def self.return_value
140
+ "Hash containing the latest version and build."
141
+ end
142
+
143
+ def self.details
144
+ # Optional:
145
+ "Allows you to read, set, increment and interactively bump Android and iOS app versions (following SemVer) and build numbers."
146
+ end
147
+
148
+ def self.available_options
149
+ ::Xamversion::Options.available_options
150
+ end
151
+
152
+ def self.is_supported?(platform)
153
+ true
154
+ end
155
+ end
156
+ end
157
+ end
@@ -0,0 +1,13 @@
1
+ module Xamversion
2
+ module Platform
3
+ IOS = "ios"
4
+ OSX = "osx"
5
+ ANDROID = "android"
6
+
7
+ def self.from_lane_context(context)
8
+ current_platform = context[:PLATFORM_NAME].to_s
9
+
10
+ current_platform
11
+ end
12
+ end
13
+ 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 XamversionHelper
8
+ # class methods that you define here become available in your action
9
+ # as `Helper::XamversionHelper.your_method`
10
+ #
11
+ def self.show_message
12
+ UI.message("Hello from the xamversion plugin helper!")
13
+ end
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,55 @@
1
+ module Xamversion
2
+ class Options
3
+ def self.available_options
4
+ [
5
+ FastlaneCore::ConfigItem.new(key: :version,
6
+ env_name: "FL_APP_VERSION",
7
+ description: "App version value",
8
+ optional: true),
9
+
10
+ FastlaneCore::ConfigItem.new(key: :build,
11
+ env_name: "FL_APP_BUILD",
12
+ description: "App build number value",
13
+ optional: true),
14
+
15
+ FastlaneCore::ConfigItem.new(key: :readonly,
16
+ env_name: "xamversion_READONLY",
17
+ description: "Only print out current version and build",
18
+ default_value: false,
19
+ is_string: false,
20
+ optional: true),
21
+
22
+ FastlaneCore::ConfigItem.new(key: :bump,
23
+ description: "Interactively bump version number",
24
+ default_value: false,
25
+ is_string: false,
26
+ optional: true),
27
+
28
+ FastlaneCore::ConfigItem.new(key: :platform,
29
+ env_name: "xamversion_PLATFORM",
30
+ description: "Targeted device platform (i.e. android, ios, osx)",
31
+ optional: false),
32
+
33
+ FastlaneCore::ConfigItem.new(key: :solution_path,
34
+ env_name: "xamversion_SOLUTION_PATH",
35
+ description: "Path to the build solution (sln) file",
36
+ optional: true),
37
+
38
+ FastlaneCore::ConfigItem.new(key: :project_path,
39
+ env_name: "xamversion_PROJECT_PATH",
40
+ description: "Path to the build project (csproj) file",
41
+ optional: true),
42
+
43
+ FastlaneCore::ConfigItem.new(key: :manifest_path,
44
+ env_name: "xamversion_ANDROID_MANIFEST_PATH",
45
+ description: "Path to the android manifest (xml) file",
46
+ optional: true),
47
+
48
+ FastlaneCore::ConfigItem.new(key: :plist_path,
49
+ env_name: "xamversion_IOS_PLIST_PATH",
50
+ description: "Path to the iOS plist file",
51
+ optional: true)
52
+ ]
53
+ end
54
+ end
55
+ end
@@ -0,0 +1,5 @@
1
+ module Fastlane
2
+ module Xamversion
3
+ VERSION = "0.1.0"
4
+ end
5
+ end
metadata ADDED
@@ -0,0 +1,218 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: fastlane-plugin-xamversion
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Jake Barnby
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2020-12-03 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: nokogiri
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.7'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.7'
27
+ - !ruby/object:Gem::Dependency
28
+ name: mixlib-versioning
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '1.2'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '1.2'
41
+ - !ruby/object:Gem::Dependency
42
+ name: csproj
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: 0.1.0
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: 0.1.0
55
+ - !ruby/object:Gem::Dependency
56
+ name: pry
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: bundler
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
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: rspec_junit_formatter
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
111
+ - !ruby/object:Gem::Dependency
112
+ name: rake
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
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - '='
130
+ - !ruby/object:Gem::Version
131
+ version: 0.49.1
132
+ type: :development
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - '='
137
+ - !ruby/object:Gem::Version
138
+ version: 0.49.1
139
+ - !ruby/object:Gem::Dependency
140
+ name: rubocop-require_tools
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: simplecov
155
+ requirement: !ruby/object:Gem::Requirement
156
+ requirements:
157
+ - - ">="
158
+ - !ruby/object:Gem::Version
159
+ version: '0'
160
+ type: :development
161
+ prerelease: false
162
+ version_requirements: !ruby/object:Gem::Requirement
163
+ requirements:
164
+ - - ">="
165
+ - !ruby/object:Gem::Version
166
+ version: '0'
167
+ - !ruby/object:Gem::Dependency
168
+ name: fastlane
169
+ requirement: !ruby/object:Gem::Requirement
170
+ requirements:
171
+ - - ">="
172
+ - !ruby/object:Gem::Version
173
+ version: 2.169.0
174
+ type: :development
175
+ prerelease: false
176
+ version_requirements: !ruby/object:Gem::Requirement
177
+ requirements:
178
+ - - ">="
179
+ - !ruby/object:Gem::Version
180
+ version: 2.169.0
181
+ description:
182
+ email: jakeb994@gmail.com
183
+ executables: []
184
+ extensions: []
185
+ extra_rdoc_files: []
186
+ files:
187
+ - LICENSE
188
+ - README.md
189
+ - lib/fastlane/plugin/xamversion.rb
190
+ - lib/fastlane/plugin/xamversion/actions/xamversion_action.rb
191
+ - lib/fastlane/plugin/xamversion/helper/platform.rb
192
+ - lib/fastlane/plugin/xamversion/helper/xamversion_helper.rb
193
+ - lib/fastlane/plugin/xamversion/options.rb
194
+ - lib/fastlane/plugin/xamversion/version.rb
195
+ homepage: https://github.com/abnegate/fastlane-plugin-xamversion
196
+ licenses:
197
+ - MIT
198
+ metadata: {}
199
+ post_install_message:
200
+ rdoc_options: []
201
+ require_paths:
202
+ - lib
203
+ required_ruby_version: !ruby/object:Gem::Requirement
204
+ requirements:
205
+ - - ">="
206
+ - !ruby/object:Gem::Version
207
+ version: '0'
208
+ required_rubygems_version: !ruby/object:Gem::Requirement
209
+ requirements:
210
+ - - ">="
211
+ - !ruby/object:Gem::Version
212
+ version: '0'
213
+ requirements: []
214
+ rubygems_version: 3.1.4
215
+ signing_key:
216
+ specification_version: 4
217
+ summary: Read and manipulate Android and iOS app versions.
218
+ test_files: []