fastlane-plugin-flutter_bump_version 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/LICENSE +21 -0
- data/README.md +38 -0
- data/lib/fastlane/plugin/flutter_bump_version/actions/flutter_bump_version_action.rb +170 -0
- data/lib/fastlane/plugin/flutter_bump_version/helper/flutter_bump_version_helper.rb +15 -0
- data/lib/fastlane/plugin/flutter_bump_version/version.rb +5 -0
- data/lib/fastlane/plugin/flutter_bump_version.rb +16 -0
- metadata +188 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 0b63260d2d10beb5f5b682ad4b1724758250200bcc1e4b3a22ca82ad4869922b
|
4
|
+
data.tar.gz: f4e7fe350c26b929470aea33e16fb359ca7dcd6844ccd79cb64c40c05d1baa93
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 963ec1b1eb51094c345f78b095b332377c49e2b87b2aa77329cdaffe23def06f949dbb12ad19b5a56689cd20b5f90f678e068a4c6f5a08405e9bbee860d40699
|
7
|
+
data.tar.gz: 6cb389130b0b1b678553117a4beb5bc324fae5ec9731985dbd1435b308750509cf163f3596905afb63b0fc16dd8edfa9cba76afe12394277903047229c069633
|
data/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2022 Mohammed chahboun <m97.chahboun@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,38 @@
|
|
1
|
+
# flutter_bump_version plugin
|
2
|
+
|
3
|
+
[![fastlane Plugin Badge](https://rawcdn.githack.com/fastlane/fastlane/master/fastlane/assets/plugin-badge.svg)](https://rubygems.org/gems/fastlane-plugin-flutter_bump_version)
|
4
|
+
|
5
|
+
## Getting Started
|
6
|
+
|
7
|
+
This project is a [_fastlane_](https://github.com/fastlane/fastlane) plugin. To get started with `fastlane-plugin-flutter_bump_version`, add it to your project by running:
|
8
|
+
|
9
|
+
```bash
|
10
|
+
fastlane add_plugin flutter_bump_version
|
11
|
+
```
|
12
|
+
|
13
|
+
## About flutter_bump_version
|
14
|
+
|
15
|
+
Manages Flutter project version
|
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 bump_version bump:patch`.
|
20
|
+
|
21
|
+
You can bump any part of version you want by use instead of patch (major,minor,patch or build)
|
22
|
+
|
23
|
+
## Issues and Feedback
|
24
|
+
|
25
|
+
For any other issues and feedback about this plugin, please submit it to this repository.
|
26
|
+
|
27
|
+
## Troubleshooting
|
28
|
+
|
29
|
+
If you have trouble using plugins, check out the [Plugins Troubleshooting](https://docs.fastlane.tools/plugins/plugins-troubleshooting/) guide.
|
30
|
+
|
31
|
+
## Using _fastlane_ Plugins
|
32
|
+
|
33
|
+
For more information about how the `fastlane` plugin system works, check out the [Plugins documentation](https://docs.fastlane.tools/plugins/create-plugin/).
|
34
|
+
|
35
|
+
## About _fastlane_
|
36
|
+
|
37
|
+
_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).
|
38
|
+
|
@@ -0,0 +1,170 @@
|
|
1
|
+
require 'fastlane'
|
2
|
+
require_relative '../helper/flutter_bump_version_helper'
|
3
|
+
require 'yaml'
|
4
|
+
|
5
|
+
module Fastlane
|
6
|
+
module Actions
|
7
|
+
class YamlReader
|
8
|
+
def initialize(yaml_path)
|
9
|
+
@yaml_file = YAML.load_file(yaml_path)
|
10
|
+
end
|
11
|
+
|
12
|
+
def field(field_name)
|
13
|
+
@yaml_file[field_name]
|
14
|
+
end
|
15
|
+
|
16
|
+
def all
|
17
|
+
@yaml_file
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
class FileReader
|
22
|
+
def initialize(yaml_path)
|
23
|
+
@yaml_path = yaml_path
|
24
|
+
end
|
25
|
+
|
26
|
+
def read
|
27
|
+
IO.readlines(@yaml_path)
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
class FileWritter
|
32
|
+
def initialize(yaml_path)
|
33
|
+
@yaml_path = yaml_path
|
34
|
+
end
|
35
|
+
|
36
|
+
def write(content)
|
37
|
+
File.open(@yaml_path, "w") do |file|
|
38
|
+
file.puts(content)
|
39
|
+
file.close
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
class FlutterBumpVersion
|
45
|
+
def initialize(pubspec_path)
|
46
|
+
@pubspec_yaml_reader = YamlReader.new(pubspec_path)
|
47
|
+
@pubspec_file_reader = FileReader.new(pubspec_path)
|
48
|
+
@pubspec_file_writter = FileWritter.new(pubspec_path)
|
49
|
+
end
|
50
|
+
|
51
|
+
def congigure_major
|
52
|
+
return @is_major ? @current_version_in_hash['major'] + 1 : @current_version_in_hash['major']
|
53
|
+
end
|
54
|
+
|
55
|
+
def configure_minor
|
56
|
+
if @is_minor
|
57
|
+
@current_version_in_hash['minor'] + 1
|
58
|
+
else
|
59
|
+
@is_major ? 0 : @current_version_in_hash['minor']
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
def configure_patch
|
64
|
+
if @is_patch
|
65
|
+
@current_version_in_hash['patch'] + 1
|
66
|
+
else
|
67
|
+
@is_major || @is_minor ? 0 : @current_version_in_hash['patch']
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
def configure_build
|
72
|
+
if @is_build
|
73
|
+
@current_version_in_hash['build'] + 1
|
74
|
+
else
|
75
|
+
@is_major || @is_minor || @is_patch ? 0 : @current_version_in_hash['minor']
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
def bump_version(part)
|
80
|
+
@is_major = part == "major"
|
81
|
+
@is_minor = part == "minor"
|
82
|
+
@is_patch = part == "patch"
|
83
|
+
@is_build = part == "build"
|
84
|
+
current_version = @pubspec_yaml_reader.field('version')
|
85
|
+
split_current_version = current_version.split(".")
|
86
|
+
build_exist = current_version.count("+") != 0
|
87
|
+
patch = build_exist ? split_current_version.last.split("+")[0] : split_current_version[2]
|
88
|
+
build = build_exist ? split_current_version.last.split("+")[1] : "0"
|
89
|
+
@current_version_in_hash = Hash("major" => split_current_version[0].to_i, "minor" => split_current_version[1].to_i, "patch" => patch.to_i, "build" => build.to_i)
|
90
|
+
@current_version_in_hash['major'] = congigure_major
|
91
|
+
@current_version_in_hash['minor'] = configure_minor
|
92
|
+
@current_version_in_hash['patch'] = configure_patch
|
93
|
+
@current_version_in_hash['build'] = configure_build
|
94
|
+
new_version = "#{@current_version_in_hash['major']}.#{@current_version_in_hash['minor']}.#{@current_version_in_hash['patch']}"
|
95
|
+
new_version = @is_build ? new_version + "+#{@current_version_in_hash['build']}" : new_version
|
96
|
+
update_pubspec(new_version, current_version)
|
97
|
+
end
|
98
|
+
|
99
|
+
def update_pubspec(new_version, current_version)
|
100
|
+
version_string = "version: "
|
101
|
+
new_content = @pubspec_file_reader.read.map { |s| s.gsub(version_string + current_version, version_string + new_version) }
|
102
|
+
@pubspec_file_writter.write(new_content)
|
103
|
+
UI.message("Previous app version: #{current_version}")
|
104
|
+
UI.message("New app version: #{new_version}")
|
105
|
+
end
|
106
|
+
end
|
107
|
+
|
108
|
+
class FlutterBumpVersionAction < Action
|
109
|
+
def self.run(params)
|
110
|
+
pubspec_path = params[:pubspec] || '../'
|
111
|
+
arguments = params[:arguments]
|
112
|
+
args = arguments.keys
|
113
|
+
bump_version = FlutterBumpVersion.new(pubspec_path)
|
114
|
+
# Check if the user has passed additional arguments
|
115
|
+
if args.include?(:bump)
|
116
|
+
args.each do |a|
|
117
|
+
case a
|
118
|
+
when :bump
|
119
|
+
available_version_options = ['major', 'minor', 'patch', 'build']
|
120
|
+
if available_version_options.include?(arguments[:bump])
|
121
|
+
bump_version.bump_version(arguments[:bump])
|
122
|
+
else
|
123
|
+
UI.message("You pass with bump wrong option, Available options : #{available_version_options}")
|
124
|
+
end
|
125
|
+
end
|
126
|
+
end
|
127
|
+
else
|
128
|
+
UI.message("Something wrong, Try: bundle exec fastlane bump_version bump:major,minor,patch or build")
|
129
|
+
end
|
130
|
+
end
|
131
|
+
|
132
|
+
def self.description
|
133
|
+
"Fastlane plugin for upgrade flutter projects version by any part (major,minor,patch or build)"
|
134
|
+
end
|
135
|
+
|
136
|
+
def self.authors
|
137
|
+
["Mohammed chahboun"]
|
138
|
+
end
|
139
|
+
|
140
|
+
def self.return_value
|
141
|
+
# If your method provides a return value, you can describe here what it does
|
142
|
+
end
|
143
|
+
|
144
|
+
def self.details
|
145
|
+
"App versioning tool for Flutter projects that can be integrate easily into pipeline via CI/CD"
|
146
|
+
end
|
147
|
+
|
148
|
+
def self.available_options
|
149
|
+
[
|
150
|
+
FastlaneCore::ConfigItem.new(
|
151
|
+
key: :pubspec,
|
152
|
+
description: "Path to pubspec.yaml",
|
153
|
+
optional: false,
|
154
|
+
type: String
|
155
|
+
),
|
156
|
+
FastlaneCore::ConfigItem.new(
|
157
|
+
key: :arguments,
|
158
|
+
description: "part you want upgrade (major,minor,patch or build)",
|
159
|
+
optional: true,
|
160
|
+
type: Hash
|
161
|
+
)
|
162
|
+
]
|
163
|
+
end
|
164
|
+
|
165
|
+
def self.is_supported?(platform)
|
166
|
+
true
|
167
|
+
end
|
168
|
+
end
|
169
|
+
end
|
170
|
+
end
|
@@ -0,0 +1,15 @@
|
|
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 FlutterBumpVersionHelper
|
8
|
+
# class methods that you define here become available in your action
|
9
|
+
# as `Helper::FlutterBumpVersionHelper.your_method`
|
10
|
+
#
|
11
|
+
def self.show_message
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
require 'fastlane/plugin/flutter_bump_version/version'
|
2
|
+
|
3
|
+
module Fastlane
|
4
|
+
module FlutterBumpVersion
|
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::FlutterBumpVersion.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-flutter_bump_version
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Mohammed chahboun
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2022-09-22 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.210.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.210.0
|
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: m97.chahboun@gmail.com
|
155
|
+
executables: []
|
156
|
+
extensions: []
|
157
|
+
extra_rdoc_files: []
|
158
|
+
files:
|
159
|
+
- LICENSE
|
160
|
+
- README.md
|
161
|
+
- lib/fastlane/plugin/flutter_bump_version.rb
|
162
|
+
- lib/fastlane/plugin/flutter_bump_version/actions/flutter_bump_version_action.rb
|
163
|
+
- lib/fastlane/plugin/flutter_bump_version/helper/flutter_bump_version_helper.rb
|
164
|
+
- lib/fastlane/plugin/flutter_bump_version/version.rb
|
165
|
+
homepage: https://github.com/m97chahboun/fastlane-plugin-flutter_bump_version
|
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.6'
|
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.3.1
|
185
|
+
signing_key:
|
186
|
+
specification_version: 4
|
187
|
+
summary: Manages Flutter project version
|
188
|
+
test_files: []
|