renuo-cli 1.3.1 → 1.4.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 +4 -4
- data/.ruby-version +1 -1
- data/lib/renuo/cli.rb +3 -2
- data/lib/renuo/cli/app/release_project.rb +116 -88
- data/lib/renuo/cli/version.rb +1 -1
- data/renuo-cli.gemspec +1 -1
- metadata +5 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d06bce9aa4b4a3585383e216d0ec8a40934c744c0ef744ef6c5b93662bc48b7c
|
4
|
+
data.tar.gz: 38a4a1b6d6bdcf1e752b6e06ef35bde896f4369a51e7d6e1094b581d7e876445
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2287372eff3dd81ddb3c615b03aa8bc5509008b8e349450ac5c4bceb2ee5710456b5035f35e2f9fd5210cf81bf9c175240268610de422971d3c5f2a8a14eb6b9
|
7
|
+
data.tar.gz: ccb4f801d47581ce421ef865410e55456774ac98e1f3252430ee3ad1750dbceabb71253590add5e48d4f589f6b6babf993d6c6dfec9f1659bdfe1b891327024f
|
data/.ruby-version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
2.5.
|
1
|
+
2.5.1
|
data/lib/renuo/cli.rb
CHANGED
@@ -127,8 +127,9 @@ module Renuo
|
|
127
127
|
|
128
128
|
command 'release' do |c|
|
129
129
|
c.syntax = 'renuo release'
|
130
|
-
c.summary = '
|
131
|
-
c.description = '
|
130
|
+
c.summary = 'Release a projects state of develop (on github) to master in one command.'
|
131
|
+
c.description = 'Creates a new release version of a project on master as either a Major, Minor, '\
|
132
|
+
'Patch or Custom release based on the current state of develop on Github'
|
132
133
|
c.example 'renuo release my-project minor', 'release a minor release of my-project'
|
133
134
|
c.example 'renuo release my-project custom 2.5.0', 'release my-project as release 2.5.0'
|
134
135
|
c.action do|args|
|
@@ -1,136 +1,148 @@
|
|
1
1
|
class ReleaseProject
|
2
2
|
UPDATE_TYPES = %w[major minor patch custom].freeze
|
3
|
-
|
4
|
-
|
3
|
+
TMP_FOLDER_NAME = ('_RENUO_RELEASE_TEMP_' + rand(100_000_000).to_s).freeze
|
4
|
+
MOVE_TO_TMP_FOLDER = "mkdir -p #{TMP_FOLDER_NAME} && cd #{TMP_FOLDER_NAME}".freeze
|
5
5
|
|
6
6
|
def run(args)
|
7
|
-
project_name, @update_type, @version = args
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
compare_develop_master
|
12
|
-
|
7
|
+
@project_name, @update_type, @version = args
|
8
|
+
validate_project_name
|
9
|
+
validate_update_type
|
10
|
+
validate_custom_version_format
|
11
|
+
compare_develop_master
|
12
|
+
checkout_project
|
13
|
+
@version ||= calculate_version
|
14
|
+
release
|
13
15
|
ensure
|
14
16
|
cleanup
|
15
17
|
end
|
16
18
|
|
17
|
-
|
18
|
-
|
19
|
-
|
19
|
+
private
|
20
|
+
|
21
|
+
def validate_project_name
|
22
|
+
abort('>> No project name given.') unless @project_name
|
23
|
+
end
|
24
|
+
|
25
|
+
def validate_update_type
|
26
|
+
unless valid_update_type?
|
27
|
+
abort('>> Please provide the desired update type: major, minor, patch or custom. '\
|
28
|
+
'If you are unsure about the type please read https://semver.org')
|
20
29
|
end
|
21
30
|
|
22
|
-
if !
|
23
|
-
|
24
|
-
validate_update_type(@update_type, @version)
|
31
|
+
if !custom_version? && @version
|
32
|
+
abort('>> Do not specify a version for a non-custom release. Given version will be ignored.')
|
25
33
|
end
|
26
34
|
|
27
|
-
|
35
|
+
abort('>> Please enter your desired version for the custom release.') if custom_version? && @version.nil?
|
36
|
+
end
|
28
37
|
|
29
|
-
|
30
|
-
|
38
|
+
def valid_update_type?
|
39
|
+
UPDATE_TYPES.include? @update_type
|
31
40
|
end
|
32
41
|
|
33
|
-
def
|
34
|
-
|
35
|
-
version = version.match(/\d+\.\d+\.\d+/)
|
36
|
-
return version if version
|
37
|
-
abort('>> Invalid Version Number. Use format X.Y.Z for your version.')
|
42
|
+
def custom_version?
|
43
|
+
@update_type == UPDATE_TYPES[3]
|
38
44
|
end
|
39
45
|
|
40
|
-
def
|
41
|
-
|
42
|
-
|
43
|
-
"cd #{folder_name(project_name)} && git checkout master && git flow init -d")
|
44
|
-
cleanup
|
45
|
-
abort('>> Project not found on Github.')
|
46
|
-
end
|
46
|
+
def validate_custom_version_format
|
47
|
+
return if @version.nil?
|
48
|
+
abort('>> Invalid Version Number. Use format X.Y.Z for your version.') unless @version =~ /\d+\.\d+\.\d+/
|
47
49
|
end
|
48
50
|
|
49
|
-
def compare_develop_master
|
50
|
-
|
51
|
-
|
51
|
+
def compare_develop_master
|
52
|
+
puts 'Please double-check what is going to be deployed.'
|
53
|
+
open_comparison_page
|
52
54
|
abort unless agree('Are you fine with those changes?')
|
53
55
|
end
|
54
56
|
|
55
|
-
def
|
56
|
-
|
57
|
-
|
58
|
-
release_start project_name, update_type, version
|
59
|
-
|
60
|
-
say ">> Project successfully released with version #{version}."
|
57
|
+
def open_comparison_page
|
58
|
+
system "open https://github.com/#{@project_name}/compare/master...develop"
|
61
59
|
end
|
62
60
|
|
63
|
-
def
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
abort('>>
|
61
|
+
def checkout_project
|
62
|
+
unless system("#{MOVE_TO_TMP_FOLDER} && hub clone #{@project_name} && " \
|
63
|
+
"cd #{folder_name} && git checkout master && git pull origin master &&" \
|
64
|
+
'git checkout develop && git pull origin develop && git flow init -d')
|
65
|
+
abort('>> Project not found on Github.')
|
68
66
|
end
|
69
|
-
|
70
|
-
ask_for_final_confirmation(project_name, update_type, version)
|
71
|
-
|
72
|
-
return if release_flow(project_name, version)
|
73
|
-
abort('>> Unable to finish release and push to master. Cancelling release.')
|
74
67
|
end
|
75
68
|
|
76
|
-
def
|
77
|
-
|
78
|
-
|
79
|
-
|
69
|
+
def calculate_version
|
70
|
+
current_version_parts = current_version.split('.').map(&:to_i)
|
71
|
+
type_index = UPDATE_TYPES.index(@update_type)
|
72
|
+
current_version_parts[type_index + 1..-1] = [0] * (2 - type_index)
|
73
|
+
current_version_parts[type_index] += 1
|
74
|
+
current_version_parts.join('.')
|
80
75
|
end
|
81
76
|
|
82
|
-
def
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
77
|
+
def release
|
78
|
+
ask_for_final_confirmation
|
79
|
+
start_release_branch
|
80
|
+
bump_version
|
81
|
+
if finish_release_branch
|
82
|
+
puts ">> Project successfully released with version #{@version}."
|
87
83
|
else
|
88
|
-
|
84
|
+
abort('>> Unable to finish release and push to master. Cancelling release.')
|
89
85
|
end
|
90
86
|
end
|
91
87
|
|
92
|
-
def
|
93
|
-
|
94
|
-
|
95
|
-
"GIT_MERGE_AUTOEDIT=no git flow release finish -m #{version} #{version} && " \
|
96
|
-
'git checkout master && git push origin master && ' \
|
97
|
-
'git checkout develop && git push origin develop && ' \
|
98
|
-
'git push --tags')
|
99
|
-
end
|
100
|
-
|
101
|
-
def current_version(project_name)
|
102
|
-
describe = "#{move_and_cd(project_name)} && git describe --tags"
|
88
|
+
def current_version
|
89
|
+
return @current_version if @current_version
|
90
|
+
describe = cmd_in_folder('git describe --tags')
|
103
91
|
tag = '`git rev-list --tags --max-count=1`'
|
104
|
-
if `#{
|
105
|
-
|
106
|
-
|
107
|
-
|
92
|
+
@current_version = if `#{cmd_in_folder('git tag')}` == ''
|
93
|
+
'0.0.0'
|
94
|
+
else
|
95
|
+
`#{describe} #{tag}`.strip
|
96
|
+
end
|
97
|
+
end
|
98
|
+
|
99
|
+
def bump_version
|
100
|
+
version_bumped = find_and_replace_version
|
101
|
+
|
102
|
+
return unless version_bumped
|
103
|
+
system(cmd_in_folder("git add . && git commit -m \"bump version\" && git push -u origin release/#{@version}"))
|
104
|
+
end
|
105
|
+
|
106
|
+
def find_and_replace_version
|
107
|
+
find_files_with_version.split("\n").any? do |file_name|
|
108
|
+
puts "Replace the version in #{file_name}?"
|
109
|
+
print_version_found(file_name)
|
110
|
+
if agree('confirm?')
|
111
|
+
bump_version_in_file(file_name)
|
112
|
+
true
|
113
|
+
else
|
114
|
+
false
|
115
|
+
end
|
108
116
|
end
|
109
117
|
end
|
110
118
|
|
111
|
-
def
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
version[type_index] += 1
|
116
|
-
version.join('.')
|
119
|
+
def find_files_with_version
|
120
|
+
excluded_dirs = %w[.git node_modules tmp].map { |dir| "--exclude-dir=#{dir}" }.join(' ')
|
121
|
+
grep_current_version = "grep -rl -F #{excluded_dirs} --include='*.rb' #{current_version} ."
|
122
|
+
`#{cmd_in_folder(grep_current_version)}`
|
117
123
|
end
|
118
124
|
|
119
|
-
def
|
120
|
-
"#{
|
125
|
+
def print_version_found(file_name)
|
126
|
+
system(cmd_in_folder("grep -A 1 -B 1 --color #{current_version} #{file_name}"))
|
121
127
|
end
|
122
128
|
|
123
|
-
def
|
124
|
-
|
129
|
+
def bump_version_in_file(file_name)
|
130
|
+
system(cmd_in_folder("sed -i '' 's|#{current_version}|#{@version}|g' #{file_name}"))
|
125
131
|
end
|
126
132
|
|
127
|
-
def
|
128
|
-
system("
|
133
|
+
def start_release_branch
|
134
|
+
system(cmd_in_folder("git flow release start #{@version}"))
|
135
|
+
end
|
136
|
+
|
137
|
+
def finish_release_branch
|
138
|
+
system(cmd_in_folder("GIT_MERGE_AUTOEDIT=no git flow release finish -m #{@version} #{@version} && " \
|
139
|
+
'git checkout develop && git push origin develop && ' \
|
140
|
+
'git checkout master && git push origin master --tags'))
|
129
141
|
end
|
130
142
|
|
131
|
-
def ask_for_final_confirmation
|
132
|
-
unless agree(">> Are you sure you wish to deploy '#{project_name}' " \
|
133
|
-
"as a #{update_type} release (#{current_version
|
143
|
+
def ask_for_final_confirmation
|
144
|
+
unless agree(">> Are you sure you wish to deploy '#{@project_name}' " \
|
145
|
+
"as a #{@update_type} release (#{current_version} => #{@version})?")
|
134
146
|
abort('>> Cancelling Release.')
|
135
147
|
end
|
136
148
|
|
@@ -140,4 +152,20 @@ class ReleaseProject
|
|
140
152
|
abort('>> Very good. Go home now.')
|
141
153
|
end
|
142
154
|
end
|
155
|
+
|
156
|
+
def cmd_in_folder(command)
|
157
|
+
"#{move_and_cd} && #{command}"
|
158
|
+
end
|
159
|
+
|
160
|
+
def move_and_cd
|
161
|
+
"#{MOVE_TO_TMP_FOLDER} && cd #{folder_name}"
|
162
|
+
end
|
163
|
+
|
164
|
+
def folder_name
|
165
|
+
@project_name.split('/').last
|
166
|
+
end
|
167
|
+
|
168
|
+
def cleanup
|
169
|
+
system("rm -rf #{TMP_FOLDER_NAME}")
|
170
|
+
end
|
143
171
|
end
|
data/lib/renuo/cli/version.rb
CHANGED
data/renuo-cli.gemspec
CHANGED
@@ -23,7 +23,7 @@ Gem::Specification.new do |spec|
|
|
23
23
|
spec.add_dependency 'redcarpet', '~> 3.0'
|
24
24
|
|
25
25
|
spec.add_development_dependency 'aruba', '~> 0.14.5'
|
26
|
-
spec.add_development_dependency 'bundler', '~>
|
26
|
+
spec.add_development_dependency 'bundler', '~> 2.0'
|
27
27
|
spec.add_development_dependency 'coveralls', '~> 0.8.9'
|
28
28
|
spec.add_development_dependency 'cucumber', '~> 3.1'
|
29
29
|
spec.add_development_dependency 'mdl', '~> 0.4.0'
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: renuo-cli
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Renuo AG
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2019-03-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: colorize
|
@@ -86,14 +86,14 @@ dependencies:
|
|
86
86
|
requirements:
|
87
87
|
- - "~>"
|
88
88
|
- !ruby/object:Gem::Version
|
89
|
-
version: '
|
89
|
+
version: '2.0'
|
90
90
|
type: :development
|
91
91
|
prerelease: false
|
92
92
|
version_requirements: !ruby/object:Gem::Requirement
|
93
93
|
requirements:
|
94
94
|
- - "~>"
|
95
95
|
- !ruby/object:Gem::Version
|
96
|
-
version: '
|
96
|
+
version: '2.0'
|
97
97
|
- !ruby/object:Gem::Dependency
|
98
98
|
name: coveralls
|
99
99
|
requirement: !ruby/object:Gem::Requirement
|
@@ -273,7 +273,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
273
273
|
version: '0'
|
274
274
|
requirements: []
|
275
275
|
rubyforge_project:
|
276
|
-
rubygems_version: 2.7.
|
276
|
+
rubygems_version: 2.7.6
|
277
277
|
signing_key:
|
278
278
|
specification_version: 4
|
279
279
|
summary: The Renuo CLI automates some common workflows.
|