fastlane-plugin-versioning 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 4a5cecca55ea703c542b4b7ea91c29336282f1f8
4
+ data.tar.gz: e0a9378879826b80ece1f8aaa28cbce9def0a70c
5
+ SHA512:
6
+ metadata.gz: bbbb1d600e50316a1ed1ba71b137171e91b7ea9df76aefc470621162dcc8c26847556a12c932c025251173f0d59dd4ce76af5e60981802ba676d8ff293649cb5
7
+ data.tar.gz: e367f303d8ebc5634da0acd83153b30ba2c0035f1a8599b9a7654588e8bc1f7ea3b39fce1c5e9cf6015457436dd4d67ab058f70df6da22d794e15a003f6a64cd
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2016 Siarhei Fiedartsou <siarhei.fedartsou@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.
@@ -0,0 +1,74 @@
1
+ # fastlane-plugin-versioning `fastlane` Plugin
2
+
3
+ [![fastlane Plugin Badge](https://rawcdn.githack.com/fastlane/fastlane/master/fastlane/assets/plugin-badge.svg)](https://rubygems.org/gems/fastlane-plugin-versioning)
4
+
5
+ ## Getting Started
6
+
7
+ This project is a [fastlane](https://github.com/fastlane/fastlane) plugin. To get started with fastlane-plugin-versioning, add it to your project by running:
8
+
9
+ ```bash
10
+ fastlane add_plugin versioning
11
+ ```
12
+
13
+ ## About versioning
14
+
15
+ Allows to work set/get app version directly to/from Info.plist
16
+
17
+ ## Actions
18
+
19
+ ### increment_version_number_in_plist
20
+
21
+ ```ruby
22
+ increment_version_number_in_plist # Automatically increment patch version number.
23
+ increment_version_number_in_plist(
24
+ bump_type: "patch" # Automatically increment patch version number
25
+ )
26
+ increment_version_number_in_plist(
27
+ bump_type: "minor" # Automatically increment minor version number
28
+ )
29
+ increment_version_number_in_plist(
30
+ bump_type: "major" # Automatically increment major version number
31
+ )
32
+ increment_version_number_in_plist(
33
+ version_number: '2.1.1' # Set a specific version number
34
+ )
35
+
36
+ increment_version_number_in_plist(
37
+ version_number: '2.1.1', # specify specific version number (optional, omitting it increments patch version number)
38
+ xcodeproj: './path/to/MyApp.xcodeproj' # (optional, you must specify the path to your main Xcode project if it is not in the project root directory or you have a multiple xcodeproj's in the root directory)
39
+ target: 'TestTarget' # (optional)
40
+ )
41
+ ```
42
+ You can also only receive the version number from plist without modifying it
43
+
44
+ ```ruby
45
+ version = get_version_number_from_plist(xcodeproj: "Project.xcodeproj", # optional
46
+ target: 'TestTarget', # optional
47
+ build_configuration_name: 'Release') # optional, must be specified if you have different Info.plist build settings for different build configurations
48
+ ```
49
+
50
+ ### get_info_plist_path
51
+
52
+ Get a path to target's Info.plist
53
+ ```ruby
54
+ get_info_plist_path(xcodeproj: 'Test.xcodeproj', # optional
55
+ target: 'TestTarget', # optional
56
+ build_configuration_name: 'Release' # optional, must be specified if you have different Info.plist build settings for different build configurations
57
+ )
58
+ ```
59
+
60
+ ## Issues and Feedback
61
+
62
+ For any other issues and feedback about this plugin, please submit it to this repository.
63
+
64
+ ## Troubleshooting
65
+
66
+ For some more detailed help with plugins problems, check out the [Plugins Troubleshooting](https://github.com/fastlane/fastlane/blob/master/fastlane/docs/PluginsTroubleshooting.md) doc in the main `fastlane` repo.
67
+
68
+ ## Using `fastlane` Plugins
69
+
70
+ For more information about how the `fastlane` plugin system works, check out the [Plugins documentation](https://github.com/fastlane/fastlane/blob/master/fastlane/docs/Plugins.md) in the main `fastlane` repo.
71
+
72
+ ## About `fastlane`
73
+
74
+ `fastlane` automates building, testing, and releasing your app for beta and app store distributions. To learn more about `fastlane`, check out [fastlane.tools](https://fastlane.tools).
@@ -0,0 +1,16 @@
1
+ require 'fastlane/plugin/versioning/version'
2
+
3
+ module Fastlane
4
+ module Versioning
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::Versioning.all_classes.each do |current|
15
+ require current
16
+ end
@@ -0,0 +1,86 @@
1
+ module Fastlane
2
+ module Actions
3
+ class GetInfoPlistPathAction < Action
4
+ require 'xcodeproj'
5
+
6
+ def self.run(params)
7
+ unless params[:xcodeproj]
8
+ if Helper.test?
9
+ params[:xcodeproj] = "/tmp/fastlane/tests/fastlane/bundle.xcodeproj"
10
+ else
11
+ params[:xcodeproj] = Dir["*.xcodeproj"][0] unless params[:xcodeproj]
12
+ end
13
+ end
14
+
15
+ project = Xcodeproj::Project.open(params[:xcodeproj])
16
+
17
+ if params[:target]
18
+ target = project.targets.detect { |t| t.name == params[:target]}
19
+ else
20
+ # firstly we are trying to find modern application target
21
+ target = project.targets.detect do |t|
22
+ t.kind_of?(Xcodeproj::Project::Object::PBXNativeTarget) &&
23
+ t.product_type == 'com.apple.product-type.application'
24
+ end
25
+ target = project.targets[0] if target.nil?
26
+ end
27
+
28
+ if params[:build_configuration_name]
29
+ build_settings = target.build_settings(params[:build_configuration_name])
30
+ plist = build_settings['INFOPLIST_FILE']
31
+ else
32
+ begin
33
+ plist = target.common_resolved_build_setting('INFOPLIST_FILE')
34
+ rescue
35
+ UI.user_error! 'Cannot resolve Info.plist build setting. Maybe you should specify :build_configuration_name?'
36
+ end
37
+ end
38
+
39
+ plist.gsub('$(SRCROOT)', project.path.parent.to_path)
40
+ end
41
+
42
+ #####################################################
43
+ # @!group Documentation
44
+ #####################################################
45
+
46
+ def self.description
47
+ "Get the version number of your project"
48
+ end
49
+
50
+ def self.details
51
+ [
52
+ "This action will return path to Info.plist for specific target in your project."
53
+ ].join(' ')
54
+ end
55
+
56
+ def self.available_options
57
+ [
58
+ FastlaneCore::ConfigItem.new(key: :xcodeproj,
59
+ env_name: "FL_INFO_PLIST_PROJECT",
60
+ description: "optional, you must specify the path to your main Xcode project if it is not in the project root directory or if you have multiple *.xcodeproj's in the root directory",
61
+ optional: true,
62
+ verify_block: proc do |value|
63
+ UI.user_error!("Please pass the path to the project, not the workspace") if value.end_with? ".xcworkspace"
64
+ UI.user_error!("Could not find Xcode project at path '#{File.expand_path(value)}'") if !File.exist?(value) and !Helper.is_test?
65
+ end),
66
+ FastlaneCore::ConfigItem.new(key: :target,
67
+ env_name: "FL_INFO_PLIST_TARGET",
68
+ optional: true,
69
+ description: "Specify a specific target if you have multiple per project, optional"),
70
+ FastlaneCore::ConfigItem.new(key: :build_configuration_name,
71
+ optional: true,
72
+ description: "Specify a specific build configuration if you have different Info.plist build settings for each configuration")
73
+
74
+ ]
75
+ end
76
+
77
+ def self.authors
78
+ ["SiarheiFedartsou"]
79
+ end
80
+
81
+ def self.is_supported?(platform)
82
+ [:ios, :mac].include? platform
83
+ end
84
+ end
85
+ end
86
+ end
@@ -0,0 +1,68 @@
1
+ module Fastlane
2
+ module Actions
3
+ class GetVersionNumberFromPlistAction < Action
4
+ def self.run(params)
5
+ if Helper.test?
6
+ plist = "./fastlane-plugin-versioning/spec/fixtures/plist/Info.plist"
7
+ else
8
+ plist = GetInfoPlistPathAction.run(xcodeproj: params[:xcodeproj],
9
+ target: params[:target],
10
+ build_configuration_name: params[:build_configuration_name])
11
+ end
12
+
13
+ version_number = GetInfoPlistValueAction.run(path: plist, key: 'CFBundleShortVersionString')
14
+ # Store the number in the shared hash
15
+ Actions.lane_context[SharedValues::VERSION_NUMBER] = version_number
16
+ end
17
+
18
+ #####################################################
19
+ # @!group Documentation
20
+ #####################################################
21
+
22
+ def self.description
23
+ "Get the version number of your project"
24
+ end
25
+
26
+ def self.details
27
+ [
28
+ "This action will return the current version number set on your project's Info.plist."
29
+ ].join(' ')
30
+ end
31
+
32
+ def self.available_options
33
+ [
34
+ FastlaneCore::ConfigItem.new(key: :xcodeproj,
35
+ env_name: "FL_VERSION_NUMBER_PROJECT",
36
+ description: "optional, you must specify the path to your main Xcode project if it is not in the project root directory",
37
+ optional: true,
38
+ verify_block: proc do |value|
39
+ UI.user_error!("Please pass the path to the project, not the workspace") if value.end_with? ".xcworkspace"
40
+ UI.user_error!("Could not find Xcode project at path '#{File.expand_path(value)}'") if !File.exist?(value) and !Helper.is_test?
41
+ end),
42
+ FastlaneCore::ConfigItem.new(key: :target,
43
+ env_name: "FL_VERSION_NUMBER_TARGET",
44
+ optional: true,
45
+ description: "Specify a specific target if you have multiple per project, optional"),
46
+ FastlaneCore::ConfigItem.new(key: :build_configuration_name,
47
+ optional: true,
48
+ description: "Specify a specific build configuration if you have different Info.plist build settings for each configuration")
49
+
50
+ ]
51
+ end
52
+
53
+ def self.output
54
+ [
55
+ ['VERSION_NUMBER', 'The version number']
56
+ ]
57
+ end
58
+
59
+ def self.authors
60
+ ["SiarheiFedartsou"]
61
+ end
62
+
63
+ def self.is_supported?(platform)
64
+ [:ios, :mac].include? platform
65
+ end
66
+ end
67
+ end
68
+ end
@@ -0,0 +1,97 @@
1
+ module Fastlane
2
+ module Actions
3
+ class IncrementVersionNumberInPlistAction < Action
4
+ def self.run(params)
5
+ if params[:version_number]
6
+ next_version_number = params[:version_number]
7
+ else
8
+ current_version = GetVersionNumberFromPlistAction.run(xcodeproj: params[:xcodeproj],
9
+ target: params[:target], build_configuration_name: params[:build_configuration_name])
10
+
11
+ version_array = current_version.split(".").map(&:to_i)
12
+ case params[:bump_type]
13
+ when "patch"
14
+ version_array[2] = version_array[2] + 1
15
+ next_version_number = version_array.join(".")
16
+ when "minor"
17
+ version_array[1] = version_array[1] + 1
18
+ version_array[2] = version_array[2] = 0
19
+ next_version_number = version_array.join(".")
20
+ when "major"
21
+ version_array[0] = version_array[0] + 1
22
+ version_array[1] = version_array[1] = 0
23
+ version_array[1] = version_array[2] = 0
24
+ next_version_number = version_array.join(".")
25
+ end
26
+ end
27
+
28
+ if Helper.test?
29
+ plist = "/tmp/fastlane/tests/fastlane/Info.plist"
30
+ else
31
+ plist = GetInfoPlistPathAction.run(xcodeproj: params[:xcodeproj],
32
+ target: params[:target],
33
+ build_configuration_name: params[:build_configuration_name])
34
+ end
35
+
36
+ SetInfoPlistValueAction.run(path: plist, key: 'CFBundleShortVersionString', value: next_version_number)
37
+
38
+ Actions.lane_context[SharedValues::VERSION_NUMBER] = next_version_number
39
+ end
40
+
41
+ def self.description
42
+ "Increment the version number of your project"
43
+ end
44
+
45
+ def self.details
46
+ [
47
+ "This action will increment the version number directly in Info.plist. "
48
+ ].join("\n")
49
+ end
50
+
51
+ def self.available_options
52
+ [
53
+ FastlaneCore::ConfigItem.new(key: :bump_type,
54
+ env_name: "FL_VERSION_NUMBER_BUMP_TYPE",
55
+ description: "The type of this version bump. Available: patch, minor, major",
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_number,
61
+ env_name: "FL_VERSION_NUMBER_VERSION_NUMBER",
62
+ description: "Change to a specific version. This will replace the bump type value",
63
+ optional: true),
64
+ FastlaneCore::ConfigItem.new(key: :xcodeproj,
65
+ env_name: "FL_VERSION_NUMBER_PROJECT",
66
+ description: "optional, you must specify the path to your main Xcode project if it is not in the project root directory",
67
+ verify_block: proc do |value|
68
+ UI.user_error!("Please pass the path to the project, not the workspace") if value.end_with? ".xcworkspace"
69
+ UI.user_error!("Could not find Xcode project") unless File.exist?(value)
70
+ end,
71
+ optional: true),
72
+ FastlaneCore::ConfigItem.new(key: :target,
73
+ env_name: "FL_VERSION_NUMBER_TARGET",
74
+ optional: true,
75
+ description: "Specify a specific target if you have multiple per project, optional"),
76
+ FastlaneCore::ConfigItem.new(key: :build_configuration_name,
77
+ optional: true,
78
+ description: "Specify a specific build configuration if you have different Info.plist build settings for each configuration")
79
+ ]
80
+ end
81
+
82
+ def self.output
83
+ [
84
+ ['VERSION_NUMBER', 'The new version number']
85
+ ]
86
+ end
87
+
88
+ def self.author
89
+ "SiarheiFedartsou"
90
+ end
91
+
92
+ def self.is_supported?(platform)
93
+ [:ios, :mac].include? platform
94
+ end
95
+ end
96
+ end
97
+ end
@@ -0,0 +1,12 @@
1
+ module Fastlane
2
+ module Helper
3
+ class VersioningHelper
4
+ # class methods that you define here become available in your action
5
+ # as `Helper::VersioningHelper.your_method`
6
+ #
7
+ def self.show_message
8
+ UI.message("Hello from the versioning plugin helper!")
9
+ end
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,5 @@
1
+ module Fastlane
2
+ module Versioning
3
+ VERSION = "0.1.0"
4
+ end
5
+ end
metadata ADDED
@@ -0,0 +1,107 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: fastlane-plugin-versioning
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Siarhei Fiedartsou
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2016-06-03 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: fastlane
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - '>='
60
+ - !ruby/object:Gem::Version
61
+ version: 1.93.1
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - '>='
67
+ - !ruby/object:Gem::Version
68
+ version: 1.93.1
69
+ description:
70
+ email: siarhei.fedartsou@gmail.com
71
+ executables: []
72
+ extensions: []
73
+ extra_rdoc_files: []
74
+ files:
75
+ - lib/fastlane/plugin/versioning/actions/get_info_plist_path.rb
76
+ - lib/fastlane/plugin/versioning/actions/get_version_number_from_plist.rb
77
+ - lib/fastlane/plugin/versioning/actions/increment_version_number_in_plist.rb
78
+ - lib/fastlane/plugin/versioning/helper/versioning_helper.rb
79
+ - lib/fastlane/plugin/versioning/version.rb
80
+ - lib/fastlane/plugin/versioning.rb
81
+ - README.md
82
+ - LICENSE
83
+ homepage: https://github.com/SiarheiFedartsou/fastlane-plugin-versioning
84
+ licenses:
85
+ - MIT
86
+ metadata: {}
87
+ post_install_message:
88
+ rdoc_options: []
89
+ require_paths:
90
+ - lib
91
+ required_ruby_version: !ruby/object:Gem::Requirement
92
+ requirements:
93
+ - - '>='
94
+ - !ruby/object:Gem::Version
95
+ version: '0'
96
+ required_rubygems_version: !ruby/object:Gem::Requirement
97
+ requirements:
98
+ - - '>='
99
+ - !ruby/object:Gem::Version
100
+ version: '0'
101
+ requirements: []
102
+ rubyforge_project:
103
+ rubygems_version: 2.1.11
104
+ signing_key:
105
+ specification_version: 4
106
+ summary: Allows to work set/get app version directly to/from Info.plist
107
+ test_files: []