app-release 1.0.2
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.md +21 -0
- data/README.md +51 -0
- data/RELEASE.md +7 -0
- data/app_release.gemspec +24 -0
- data/bin/app_release +19 -0
- data/lib/app_release.rb +2 -0
- data/lib/app_release/console.rb +34 -0
- data/lib/app_release/constants.rb +11 -0
- data/lib/app_release/git.rb +38 -0
- data/lib/app_release/parser.rb +169 -0
- data/lib/app_release/version.rb +11 -0
- metadata +83 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: c212a7fccb68465ac63736e8f266f194fd6b6364a3e3f4da16ce4db2407bdc8b
|
4
|
+
data.tar.gz: 21f4dbb375edc4c737332e7f186b287a838f78cb934dd96556320d8baf3f4128
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 7ad4c88df6ef55fe715983d09ff7a7e9420d2613bbcba7e3bc9169cdbe84e136689ae6a5a8934b38612c7f46e5c68ab2ce859b3fb51a50415f277175dd3709ed
|
7
|
+
data.tar.gz: 6cd37588f8ff30193c1e576399f8489b3a8a9444e82b650a6178be06e9d8ed7f0ccef813c5042e576553db5a755921e943f0010075d766450cfada7e59718605
|
data/LICENSE.md
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
# MIT LICENSE
|
2
|
+
|
3
|
+
Copyright (c) 2020 Anton Sokolov <anton@sokolov.digital>
|
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
|
13
|
+
all 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
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,51 @@
|
|
1
|
+
# App Release for Rails
|
2
|
+
|
3
|
+
A simple tool for updating the version of a Rails application.
|
4
|
+
|
5
|
+
This library was implemented to simplify project versioning. With this tool can store, quickly create and push tags.
|
6
|
+
|
7
|
+
[Documentation](https://www.rubydoc.info/gems/app-release)
|
8
|
+
|
9
|
+
## Installation
|
10
|
+
|
11
|
+
```ruby
|
12
|
+
gem 'app-release', require: false
|
13
|
+
```
|
14
|
+
|
15
|
+
## Using
|
16
|
+
|
17
|
+
### Create a version file
|
18
|
+
|
19
|
+
```shell
|
20
|
+
bundle exec app_release --init
|
21
|
+
```
|
22
|
+
|
23
|
+
### Version upgrade
|
24
|
+
|
25
|
+
```shell
|
26
|
+
# Original version: 2.4.6
|
27
|
+
|
28
|
+
bundle exec app_release --patch # => 2.4.7
|
29
|
+
|
30
|
+
bundle exec app_release --minor # => 2.5.0
|
31
|
+
|
32
|
+
bundle exec app_release --major # => 3.0.0
|
33
|
+
```
|
34
|
+
|
35
|
+
### Version upgrade and git tag creation
|
36
|
+
|
37
|
+
```shell
|
38
|
+
bundle exec app_release --minor --create-git-tag
|
39
|
+
```
|
40
|
+
|
41
|
+
If need to create a tag in a specific directory, then need to use the following command:
|
42
|
+
|
43
|
+
```shell
|
44
|
+
bundle exec app_release --minor --create-git-tag-for dev
|
45
|
+
```
|
46
|
+
|
47
|
+
If need to push after creation, then:
|
48
|
+
|
49
|
+
```shell
|
50
|
+
bundle exec app_release --minor --create-git-tag-for dev --git-push
|
51
|
+
```
|
data/RELEASE.md
ADDED
data/app_release.gemspec
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
lib = File.expand_path('lib', __dir__)
|
2
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
3
|
+
|
4
|
+
require 'app_release/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = 'app-release'
|
8
|
+
spec.version = AppRelease::VERSION
|
9
|
+
spec.platform = Gem::Platform::RUBY
|
10
|
+
spec.authors = ['Anton Sokolov']
|
11
|
+
spec.email = ['anton@sokolov.digital']
|
12
|
+
spec.homepage = 'https://github.com/afuno/app-release'
|
13
|
+
spec.licenses = ['MIT']
|
14
|
+
spec.summary = 'A simple tool for updating the version of a Rails application'
|
15
|
+
spec.description = 'A simple tool for updating the version of a Rails application'
|
16
|
+
|
17
|
+
spec.files = `git ls-files -z *.md *.gemspec bin lib`.split("\x0")
|
18
|
+
spec.require_paths = ['lib']
|
19
|
+
|
20
|
+
spec.executables = ['app_release']
|
21
|
+
|
22
|
+
spec.add_dependency 'colorize', '~> 0.8.1'
|
23
|
+
spec.add_development_dependency 'rubocop', '= 0.88'
|
24
|
+
end
|
data/bin/app_release
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
unless File.exist?('./Gemfile')
|
4
|
+
abort 'Please run app_release from the root of the project'
|
5
|
+
end
|
6
|
+
|
7
|
+
require 'rubygems'
|
8
|
+
|
9
|
+
begin
|
10
|
+
require 'bundler'
|
11
|
+
Bundler.setup
|
12
|
+
rescue StandardError
|
13
|
+
end
|
14
|
+
|
15
|
+
$LOAD_PATH << "#{__dir__}/../lib"
|
16
|
+
|
17
|
+
require 'app_release/parser'
|
18
|
+
|
19
|
+
AppRelease::Parser.parse(ARGV)
|
data/lib/app_release.rb
ADDED
@@ -0,0 +1,34 @@
|
|
1
|
+
require 'colorize'
|
2
|
+
|
3
|
+
module AppRelease
|
4
|
+
class Console
|
5
|
+
def self.print(text, color = nil)
|
6
|
+
new(text, color).print
|
7
|
+
end
|
8
|
+
|
9
|
+
def self.log(text)
|
10
|
+
new(text, nil).print
|
11
|
+
end
|
12
|
+
|
13
|
+
def self.success(text)
|
14
|
+
new(text, :green).print
|
15
|
+
end
|
16
|
+
|
17
|
+
def self.warning(text)
|
18
|
+
new(text, :yellow).print
|
19
|
+
end
|
20
|
+
|
21
|
+
def self.danger(text)
|
22
|
+
new(text, :red).print
|
23
|
+
end
|
24
|
+
|
25
|
+
def initialize(text, color = nil)
|
26
|
+
@text = text
|
27
|
+
@color = color
|
28
|
+
end
|
29
|
+
|
30
|
+
def print
|
31
|
+
puts @text.colorize(@color)
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
require 'app_release/console'
|
2
|
+
|
3
|
+
module AppRelease
|
4
|
+
class Git
|
5
|
+
def self.create(version, prefix)
|
6
|
+
new(version, prefix).create
|
7
|
+
end
|
8
|
+
|
9
|
+
def self.push
|
10
|
+
`git push origin --tags`
|
11
|
+
|
12
|
+
AppRelease::Console.success('git push')
|
13
|
+
end
|
14
|
+
|
15
|
+
def initialize(version, prefix = nil)
|
16
|
+
@prefix = prefix
|
17
|
+
@version = "v#{version}"
|
18
|
+
end
|
19
|
+
|
20
|
+
def create
|
21
|
+
`git tag #{name_formatted}`
|
22
|
+
|
23
|
+
AppRelease::Console.success("Tag #{name_formatted} was created")
|
24
|
+
|
25
|
+
# rescue => e
|
26
|
+
# AppRelease::Console.danger(e)
|
27
|
+
end
|
28
|
+
|
29
|
+
private
|
30
|
+
|
31
|
+
def name_formatted
|
32
|
+
[
|
33
|
+
@prefix,
|
34
|
+
@version
|
35
|
+
].join('/')
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
@@ -0,0 +1,169 @@
|
|
1
|
+
require 'optparse'
|
2
|
+
require 'yaml'
|
3
|
+
|
4
|
+
require 'app_release/constants'
|
5
|
+
require 'app_release/console'
|
6
|
+
require 'app_release/git'
|
7
|
+
|
8
|
+
module AppRelease
|
9
|
+
class Parser
|
10
|
+
attr_reader :args
|
11
|
+
|
12
|
+
def self.parse(args)
|
13
|
+
new(args).parse
|
14
|
+
end
|
15
|
+
|
16
|
+
def initialize(args)
|
17
|
+
@args = args
|
18
|
+
end
|
19
|
+
|
20
|
+
def parse
|
21
|
+
parser.parse!(args)
|
22
|
+
rescue StandardError => e
|
23
|
+
AppRelease::Console.danger("Ambiguously completable string is encountered\n#{e}")
|
24
|
+
end
|
25
|
+
|
26
|
+
private
|
27
|
+
|
28
|
+
def parser
|
29
|
+
OptionParser.new do |opts|
|
30
|
+
opts.banner = 'Usage: app_release [options]'
|
31
|
+
|
32
|
+
opts.on('-i', '--init', 'Creates a version file at the root of the project') do
|
33
|
+
init_version_file
|
34
|
+
exit
|
35
|
+
end
|
36
|
+
|
37
|
+
opts.on('-v', '--version', 'The current version of the gem') do
|
38
|
+
AppRelease::Console.log(AppRelease::VERSION)
|
39
|
+
exit
|
40
|
+
end
|
41
|
+
|
42
|
+
opts.on('-h', '--help', 'Prints this help') do
|
43
|
+
AppRelease::Console.log(opts)
|
44
|
+
exit
|
45
|
+
end
|
46
|
+
|
47
|
+
opts.on('--major', 'Upgrading the major version') do
|
48
|
+
upgrading_version(:major)
|
49
|
+
end
|
50
|
+
|
51
|
+
opts.on('--minor', 'Upgrading the minor update') do
|
52
|
+
upgrading_version(:minor)
|
53
|
+
end
|
54
|
+
|
55
|
+
opts.on('--patch', 'Upgrading the patch update') do
|
56
|
+
upgrading_version(:patch)
|
57
|
+
end
|
58
|
+
|
59
|
+
opts.on('--create-git-tag', 'Create git tag') do
|
60
|
+
create_git_tag_with
|
61
|
+
end
|
62
|
+
|
63
|
+
opts.on('--create-git-tag-for PREFIX', 'Create git tag with prefix') do |prefix|
|
64
|
+
create_git_tag_with(prefix)
|
65
|
+
end
|
66
|
+
|
67
|
+
opts.on('--git-push', 'git push') do
|
68
|
+
AppRelease::Git.push
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
def init_version_file
|
74
|
+
if file_exists?
|
75
|
+
AppRelease::Console.warning("File #{AppRelease::Constants::FILE_NAME} has already been created")
|
76
|
+
else
|
77
|
+
create_version_file
|
78
|
+
|
79
|
+
AppRelease::Console.success("File #{AppRelease::Constants::FILE_NAME} was created")
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
def upgrading_version(section)
|
84
|
+
unless file_exists?
|
85
|
+
AppRelease::Console.danger(
|
86
|
+
"First, you need to create a version file.\nTo do this, run command `bundle exec app_release --init`"
|
87
|
+
)
|
88
|
+
exit
|
89
|
+
end
|
90
|
+
|
91
|
+
file = current_version_file.dup
|
92
|
+
|
93
|
+
major = file[:major]
|
94
|
+
minor = file[:minor]
|
95
|
+
patch = file[:patch]
|
96
|
+
|
97
|
+
if !major.positive? && !minor.positive? && !patch.positive?
|
98
|
+
AppRelease::Console.danger('Something is wrong with the versions')
|
99
|
+
exit
|
100
|
+
end
|
101
|
+
|
102
|
+
AppRelease::Console.warning("Previous version: #{version_formatted_for(file)}")
|
103
|
+
|
104
|
+
version_from_section = file[section]
|
105
|
+
|
106
|
+
file[section] = version_from_section + 1
|
107
|
+
|
108
|
+
if section == :major
|
109
|
+
file[:minor] = 0
|
110
|
+
file[:patch] = 0
|
111
|
+
elsif section == :minor
|
112
|
+
file[:patch] = 0
|
113
|
+
end
|
114
|
+
|
115
|
+
update_version_file_with(file)
|
116
|
+
|
117
|
+
AppRelease::Console.success("New version: #{version_formatted_for(file)}")
|
118
|
+
end
|
119
|
+
|
120
|
+
def version_formatted_for(file)
|
121
|
+
major = file[:major]
|
122
|
+
minor = file[:minor]
|
123
|
+
patch = file[:patch]
|
124
|
+
|
125
|
+
[
|
126
|
+
major,
|
127
|
+
minor,
|
128
|
+
patch
|
129
|
+
].join('.')
|
130
|
+
end
|
131
|
+
|
132
|
+
def current_version_file
|
133
|
+
@current_version_file ||= YAML.load_file(file_path)
|
134
|
+
end
|
135
|
+
|
136
|
+
def create_version_file
|
137
|
+
write_in_file_with(AppRelease::Constants::INIT_VERSION)
|
138
|
+
end
|
139
|
+
|
140
|
+
def update_version_file_with(data)
|
141
|
+
write_in_file_with(data)
|
142
|
+
end
|
143
|
+
|
144
|
+
def write_in_file_with(data)
|
145
|
+
File.open(file_path, 'w') do |file|
|
146
|
+
file.write("# Edit this file manually only if you know what you are doing\n\n")
|
147
|
+
file.write(data.to_yaml.gsub("---\n", ''))
|
148
|
+
end
|
149
|
+
end
|
150
|
+
|
151
|
+
def file_exists?
|
152
|
+
File.exist?(file_path)
|
153
|
+
end
|
154
|
+
|
155
|
+
def file_path
|
156
|
+
"#{Dir.pwd}/#{AppRelease::Constants::FILE_NAME}"
|
157
|
+
end
|
158
|
+
|
159
|
+
############################################################################
|
160
|
+
############################################################################
|
161
|
+
############################################################################
|
162
|
+
|
163
|
+
def create_git_tag_with(prefix = nil)
|
164
|
+
file = current_version_file.dup
|
165
|
+
version = version_formatted_for(file)
|
166
|
+
AppRelease::Git.create(version, prefix)
|
167
|
+
end
|
168
|
+
end
|
169
|
+
end
|
metadata
ADDED
@@ -0,0 +1,83 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: app-release
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.2
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Anton Sokolov
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2020-07-21 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: colorize
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 0.8.1
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 0.8.1
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rubocop
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - '='
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0.88'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - '='
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0.88'
|
41
|
+
description: A simple tool for updating the version of a Rails application
|
42
|
+
email:
|
43
|
+
- anton@sokolov.digital
|
44
|
+
executables:
|
45
|
+
- app_release
|
46
|
+
extensions: []
|
47
|
+
extra_rdoc_files: []
|
48
|
+
files:
|
49
|
+
- LICENSE.md
|
50
|
+
- README.md
|
51
|
+
- RELEASE.md
|
52
|
+
- app_release.gemspec
|
53
|
+
- bin/app_release
|
54
|
+
- lib/app_release.rb
|
55
|
+
- lib/app_release/console.rb
|
56
|
+
- lib/app_release/constants.rb
|
57
|
+
- lib/app_release/git.rb
|
58
|
+
- lib/app_release/parser.rb
|
59
|
+
- lib/app_release/version.rb
|
60
|
+
homepage: https://github.com/afuno/app-release
|
61
|
+
licenses:
|
62
|
+
- MIT
|
63
|
+
metadata: {}
|
64
|
+
post_install_message:
|
65
|
+
rdoc_options: []
|
66
|
+
require_paths:
|
67
|
+
- lib
|
68
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
69
|
+
requirements:
|
70
|
+
- - ">="
|
71
|
+
- !ruby/object:Gem::Version
|
72
|
+
version: '0'
|
73
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
74
|
+
requirements:
|
75
|
+
- - ">="
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: '0'
|
78
|
+
requirements: []
|
79
|
+
rubygems_version: 3.1.2
|
80
|
+
signing_key:
|
81
|
+
specification_version: 4
|
82
|
+
summary: A simple tool for updating the version of a Rails application
|
83
|
+
test_files: []
|