fastlane-plugin-flutter_versioncode_bump 1.0.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.
- checksums.yaml +7 -0
- data/LICENSE +21 -0
- data/README.md +64 -0
- data/lib/fastlane/plugin/flutter_versioncode_bump/actions/flutter_versioncode_bump_action.rb +73 -0
- data/lib/fastlane/plugin/flutter_versioncode_bump/helper/flutter_versioncode_bump_helper.rb +55 -0
- data/lib/fastlane/plugin/flutter_versioncode_bump/version.rb +5 -0
- data/lib/fastlane/plugin/flutter_versioncode_bump.rb +16 -0
- metadata +188 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: ed6d73f3b7a2d53820b5eae19331524979485fe739cb4dadd39891935f267347
|
4
|
+
data.tar.gz: 8a0b411749fad4f319d17092407816e14953c0cfdc5d254278d8cea6cacc5e66
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 83fa5146cd4b9583bb4a50e65af00a42dae548a0f83970ee70a16fa9894d1d9ca5f10e06585c9a34d63855f640b8539f508f6b9806cb79b52314d185950e6325
|
7
|
+
data.tar.gz: cc65d4f7240a3502855bcde39903415961a8fd23df76114b6bf009713764da26e9bf193d20e957957542ecc3ac3593b522b16ab32c6853810af23ff49011176e
|
data/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2022 Sjors van Mierlo <spmvm.95@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,64 @@
|
|
1
|
+
# flutter_versioncode_bump plugin
|
2
|
+
|
3
|
+
[](https://rubygems.org/gems/fastlane-plugin-flutter_versioncode_bump)
|
4
|
+
|
5
|
+
## Getting Started
|
6
|
+
|
7
|
+
This project is a [_fastlane_](https://github.com/fastlane/fastlane) plugin. To get started with `fastlane-plugin-flutter_versioncode_bump`, add it to your project by running:
|
8
|
+
|
9
|
+
```bash
|
10
|
+
fastlane add_plugin flutter_versioncode_bump
|
11
|
+
```
|
12
|
+
|
13
|
+
## About flutter_versioncode_bump
|
14
|
+
|
15
|
+
Bump the flutter version code. This plugin requires that the `version:` option is used of the Flutter project its pubspec.yaml. It bumps the versioncode with +1 or the given increment. Supported versioncode examples are: `+0`, `+0001`, `+2022010001` etc. Checkout the [Flutter documentation](https://docs.flutter.dev/development/tools/pubspec) for more information about the pubspec or versioncode.
|
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 test`. There is a [example `pubspec.yaml`](pubspec.yaml) available to bump the version code of.
|
20
|
+
|
21
|
+
Add `flutter_versioncode_bump` to your Fastfile to use it with the default options. [example `Fastfile`](fastlane/Fastfile)
|
22
|
+
|
23
|
+
or override the options in the Fastfile. Example:
|
24
|
+
```
|
25
|
+
flutter_versioncode_bump({
|
26
|
+
pubspec_location: "./pubspec.yaml", # Changes the location of the pubspec.yaml
|
27
|
+
version_code_increment: 1 # Changes the increment of the bump
|
28
|
+
})
|
29
|
+
```
|
30
|
+
|
31
|
+
Environment variables can also be used. Example:
|
32
|
+
```
|
33
|
+
PUBSPEC_LOCATION # Changes the location of the pubspec.
|
34
|
+
VERSION_CODE_INCREMENT # Changes the increment of the bump
|
35
|
+
```
|
36
|
+
|
37
|
+
## Run tests for this plugin
|
38
|
+
|
39
|
+
To run both the tests, and code style validation, run
|
40
|
+
|
41
|
+
```
|
42
|
+
rake
|
43
|
+
```
|
44
|
+
|
45
|
+
To automatically fix many of the styling issues, use
|
46
|
+
```
|
47
|
+
rubocop -a
|
48
|
+
```
|
49
|
+
|
50
|
+
## Issues and Feedback
|
51
|
+
|
52
|
+
For any other issues and feedback about this plugin, please submit it to this repository.
|
53
|
+
|
54
|
+
## Troubleshooting
|
55
|
+
|
56
|
+
If you have trouble using plugins, check out the [Plugins Troubleshooting](https://docs.fastlane.tools/plugins/plugins-troubleshooting/) guide.
|
57
|
+
|
58
|
+
## Using _fastlane_ Plugins
|
59
|
+
|
60
|
+
For more information about how the `fastlane` plugin system works, check out the [Plugins documentation](https://docs.fastlane.tools/plugins/create-plugin/).
|
61
|
+
|
62
|
+
## About _fastlane_
|
63
|
+
|
64
|
+
_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,73 @@
|
|
1
|
+
require 'fastlane'
|
2
|
+
require 'yaml'
|
3
|
+
require_relative '../helper/flutter_versioncode_bump_helper'
|
4
|
+
|
5
|
+
module Fastlane
|
6
|
+
module Actions
|
7
|
+
class FlutterVersioncodeBumpAction < Action
|
8
|
+
def self.run(params)
|
9
|
+
# Retrieve given params
|
10
|
+
pubspec_location = params[:pubspec_location]
|
11
|
+
version_code_increment = params[:version_code_increment]
|
12
|
+
|
13
|
+
UI.message("Let's bump the flutter version code with an increment of #{version_code_increment}!")
|
14
|
+
|
15
|
+
# Retrieve the full version of the given pubspec.yaml location
|
16
|
+
full_version = Helper::FlutterVersioncodeBumpHelper.retrieve_full_version(pubspec_location)
|
17
|
+
UI.message("Current version is: #{full_version}")
|
18
|
+
|
19
|
+
# Bump the version code of the full version by the increment that is given
|
20
|
+
full_version = Helper::FlutterVersioncodeBumpHelper.bump_version_code(full_version, version_code_increment)
|
21
|
+
|
22
|
+
# Update the version code of the pubspec.yaml
|
23
|
+
Helper::FlutterVersioncodeBumpHelper.write_full_version(pubspec_location, full_version)
|
24
|
+
UI.success("Succesfully bumped flutter version to: #{full_version}")
|
25
|
+
{
|
26
|
+
'version' => full_version
|
27
|
+
}
|
28
|
+
end
|
29
|
+
|
30
|
+
def self.description
|
31
|
+
"A plugin to bump the flutter version code with fastlane."
|
32
|
+
end
|
33
|
+
|
34
|
+
def self.authors
|
35
|
+
["Sjors van Mierlo"]
|
36
|
+
end
|
37
|
+
|
38
|
+
def self.return_value
|
39
|
+
[
|
40
|
+
['VERSION', 'The bumped version']
|
41
|
+
]
|
42
|
+
end
|
43
|
+
|
44
|
+
def self.details
|
45
|
+
"A plugin to bump the flutter version code with fastlane
|
46
|
+
and also keep the comments in the pubspec.yaml.
|
47
|
+
|
48
|
+
Useful for automated app distribution with an unique version code for each build."
|
49
|
+
end
|
50
|
+
|
51
|
+
def self.available_options
|
52
|
+
[
|
53
|
+
FastlaneCore::ConfigItem.new(key: :pubspec_location,
|
54
|
+
env_name: "PUBSPEC_LOCATION",
|
55
|
+
description: "The location of the pubspec.yaml",
|
56
|
+
optional: true,
|
57
|
+
type: String,
|
58
|
+
default_value: 'pubspec.yaml'),
|
59
|
+
FastlaneCore::ConfigItem.new(key: :version_code_increment,
|
60
|
+
env_name: "VERSION_CODE_INCREMENT",
|
61
|
+
description: "The increment of the version code",
|
62
|
+
optional: true,
|
63
|
+
type: Integer,
|
64
|
+
default_value: 1)
|
65
|
+
]
|
66
|
+
end
|
67
|
+
|
68
|
+
def self.is_supported?(platform)
|
69
|
+
true
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
@@ -0,0 +1,55 @@
|
|
1
|
+
require 'fastlane_core/ui/ui'
|
2
|
+
require 'yaml'
|
3
|
+
|
4
|
+
module Fastlane
|
5
|
+
UI = FastlaneCore::UI unless Fastlane.const_defined?(:UI)
|
6
|
+
|
7
|
+
module Helper
|
8
|
+
class FlutterVersioncodeBumpHelper
|
9
|
+
def self.retrieve_full_version(pubspec_location)
|
10
|
+
begin
|
11
|
+
pubspec = YAML.load_file(pubspec_location)
|
12
|
+
rescue StandardError
|
13
|
+
raise 'Reading the pubspec failed!'
|
14
|
+
end
|
15
|
+
|
16
|
+
pubspec['version']
|
17
|
+
end
|
18
|
+
|
19
|
+
def self.write_full_version(pubspec_location, version)
|
20
|
+
# To retain the comments and whitespace(s) in the file replace the version in the text.
|
21
|
+
pubspec_as_text = File.read(pubspec_location)
|
22
|
+
|
23
|
+
# Apply regex to edit the version line
|
24
|
+
pubspec_new_content = pubspec_as_text.gsub(/version:.*/, "version: #{version}")
|
25
|
+
|
26
|
+
# Write updated content to pubspec
|
27
|
+
File.open(pubspec_location, 'w') { |file| file.puts(pubspec_new_content) }
|
28
|
+
rescue StandardError
|
29
|
+
raise "Could not write the updated version to the pubspec"
|
30
|
+
end
|
31
|
+
|
32
|
+
def self.bump_version_code(full_version, increment)
|
33
|
+
unless full_version.include?('+')
|
34
|
+
raise 'No version code to bump :( ! Add a version code (example: 1.0.0+0001)'
|
35
|
+
end
|
36
|
+
|
37
|
+
splitted_version = full_version.split('+')
|
38
|
+
|
39
|
+
version_name = splitted_version[0]
|
40
|
+
version_code = splitted_version[1]
|
41
|
+
|
42
|
+
# TODO: Add check for negative value!
|
43
|
+
|
44
|
+
if version_code.to_i < 0 || version_code.to_s.length == 0
|
45
|
+
raise 'Version code is invalid! Should be 0 or greater.'
|
46
|
+
end
|
47
|
+
|
48
|
+
incremented_version_code = version_code.to_i + increment
|
49
|
+
new_version_code = format("%0#{version_code.to_s.length}d", incremented_version_code.to_s)
|
50
|
+
|
51
|
+
"#{version_name}+#{new_version_code}"
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
require 'fastlane/plugin/flutter_versioncode_bump/version'
|
2
|
+
|
3
|
+
module Fastlane
|
4
|
+
module FlutterVersioncodeBump
|
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::FlutterVersioncodeBump.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_versioncode_bump
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Sjors van Mierlo
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2022-02-02 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.203.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.203.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: spmvm.95@gmail.com
|
155
|
+
executables: []
|
156
|
+
extensions: []
|
157
|
+
extra_rdoc_files: []
|
158
|
+
files:
|
159
|
+
- LICENSE
|
160
|
+
- README.md
|
161
|
+
- lib/fastlane/plugin/flutter_versioncode_bump.rb
|
162
|
+
- lib/fastlane/plugin/flutter_versioncode_bump/actions/flutter_versioncode_bump_action.rb
|
163
|
+
- lib/fastlane/plugin/flutter_versioncode_bump/helper/flutter_versioncode_bump_helper.rb
|
164
|
+
- lib/fastlane/plugin/flutter_versioncode_bump/version.rb
|
165
|
+
homepage: https://github.com/spmvanmierlo/fastlane-plugin-flutter_versioncode_bump
|
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.5'
|
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
|
185
|
+
signing_key:
|
186
|
+
specification_version: 4
|
187
|
+
summary: Bump the flutter version code
|
188
|
+
test_files: []
|