frep 0.0.1 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 75fcd1b677aa16ab3ddc4a793d50b5c6aa1b99e7
4
- data.tar.gz: caf41ef8cd3876d70bc77591ece3780fe1e8fad8
3
+ metadata.gz: f49da54bd44a836272c1636d2c9987a20292d4db
4
+ data.tar.gz: 039cf92330579cad1fda40b027e6250ca386562f
5
5
  SHA512:
6
- metadata.gz: 45597658c1e06a286bf9e0df98e7053ff7b06709095d3ee8bb95d816dfa4348190a4f9d7140594b1b8fe56b2ca32b66b8e7d4e2dbcdde65c285506d5d0ce96b0
7
- data.tar.gz: ab52fddb6a178b04c58fa59348c5ac06843f455bfd4091dbba039af8bbcd83b926a4073046551e996e6473023f266c1d4926469e9c2ce45653efec5be0409400
6
+ metadata.gz: e6136798ac4a7bf4095d42cf8775bf5d07e80ef326cf24defc00f6a03679fdf6153b51f6f0f4c75d814dc35ff9dc7df376c29bf0248bbbc3f9e82092931eb656
7
+ data.tar.gz: 4855808eb6a1c406b17678a45e8c111d4aa4804ce490be5bf1180ad7c8b2dc6dfea568ff52eabef09f8766c57cc7916a424be65db3219ba355fb66ea8f803a6d
@@ -1,5 +1,9 @@
1
+ # require 'release/release'
2
+
1
3
  class Frep
2
- def self.hi
3
- puts "Frep me baby one more time"
4
+
5
+ def self.doit
6
+ Release.new.run_yaml File.expand_path('release.yml',__FILE__)
4
7
  end
5
- end
8
+
9
+ end
@@ -0,0 +1,46 @@
1
+ Rebase master and develop:
2
+ - git checkout master
3
+ - git pull
4
+ - git checkout develop
5
+ - git pull
6
+ Do a clean install before doing any changes:
7
+ - mvn clean install
8
+ Create the release branch from develop:
9
+ - git checkout -b %{release_branch} develop
10
+ Changing maven version to %{release_version}:
11
+ - mvn versions:set -DnewVersion=%{release_version}
12
+ Change snapshot versions to release versions:
13
+ - $$set_release_versions
14
+ Commit version change:
15
+ - git add pom.xml
16
+ - git commit -m "Updated pom version to %{release_version}"
17
+ Switching to master branch:
18
+ - git checkout master
19
+ Merge %{release_branch} into master:
20
+ - git merge --no-ff %{release_branch} --commit -m "Merge %{release_branch} into master" --log
21
+ Tag the release %{release_version}:
22
+ - git tag -a %{release_version} -m "%{release_version}"
23
+ Switch on develop branch:
24
+ - git checkout develop
25
+ Merge release branch into develop:
26
+ - git merge --no-ff %{release_branch} --commit -m "Merge %{release_branch} into develop" --log
27
+ Remove the release branch %{release_branch}:
28
+ - git branch -d %{release_branch}
29
+ Push master to origin:
30
+ - git push origin master
31
+ Push develop to origin:
32
+ - git push origin develop
33
+ Push tags to origin:
34
+ - git push --tag
35
+ Deploy to Nexus:
36
+ - mvn clean deploy
37
+ Preparing for next iteration, increase version number to %{next_version}:
38
+ - mvn versions:set -DnewVersion=%{next_version}
39
+ Increase internal dependencies to latest SNAPSHOT versions:
40
+ - $$set_snapshot_versions
41
+ Commit changes to pom.xml:
42
+ - git add pom.xml
43
+ - git commit -m "[Prepare for next iteration] Increasing version number to %{next_version}"
44
+ - git push origin develop
45
+ Summary:
46
+ - $$show_summary
@@ -0,0 +1,38 @@
1
+ require 'yaml'
2
+
3
+ # require 'util/utilities'
4
+
5
+ class Release
6
+
7
+ include Utilities
8
+
9
+ def run_yaml(yaml_path)
10
+ @release_model = ReleaseModel.new
11
+
12
+ wait_or_do "\nStarting the release process" do
13
+ terminate
14
+ end
15
+
16
+ puts
17
+
18
+ release = ReleaseProcess.new(@release_model.dry_run, @release_model.snapshots)
19
+
20
+ config = YAML::load_file(yaml_path)
21
+
22
+ index=1
23
+ config.each do |section_description, commands|
24
+ variables_replaced = commands.map { |command| replace_vars(command) }
25
+ release.step("#{index}. #{replace_vars section_description}",variables_replaced)
26
+ index+=1
27
+ end
28
+ end
29
+
30
+ def replace_vars(yaml_content)
31
+ yaml_content % {
32
+ :release_branch => @release_model.release_branch,
33
+ :release_version => @release_model.release_version,
34
+ :next_version => @release_model.next_version
35
+ }
36
+ end
37
+
38
+ end
@@ -0,0 +1,87 @@
1
+ require 'rexml/document'
2
+
3
+ # require 'util/utilities'
4
+
5
+ $snapshot_dependency=/<(.+version)>(.+\-SNAPSHOT)<\//
6
+ $snapshot_version=/(.+)\-SNAPSHOT/
7
+ $version=/(.+\.)([0-9]+)/
8
+
9
+ class ReleaseModel
10
+
11
+ include Utilities
12
+
13
+ def initialize
14
+
15
+ @dry_run = (ask 'Dry run?','n') == 'y'
16
+
17
+ @release_version = ask 'What should the release version be?', read_release_version
18
+ verify_pattern_terminate @release_version, $version
19
+
20
+ @next_version = ask 'What should the next SNAPSHOT version be?', (next_snapshot @release_version)
21
+ verify_pattern_terminate @next_version, $snapshot_version
22
+
23
+ @release_branch = "release/#{@release_version}"
24
+ @snapshots = File.open('pom.xml').read.scan($snapshot_dependency)
25
+
26
+ read_snapshot_versions
27
+ prepare_new_iteration_deps
28
+
29
+ echo_with_color "\n\n====================Release information========================================================",'green'
30
+ puts "\nDry run: #{@dry_run}"
31
+ if @dry_run
32
+ help_info "---> IMPORTANT: Dry run will still change the snapshot dependencies versions (if any), don't forget to revert those changes\n"
33
+ end
34
+
35
+ help_info "\n1. Release version: "; puts release_version
36
+ help_info "\n2. Next snapshot version: ";puts next_version
37
+ help_info "\n3. Snapshot dependencies found:\n"
38
+
39
+ unless @snapshots.size==0
40
+
41
+ help_info "#{column 'Dependency'} : #{column 'Current version'} -> #{column 'Release version'} -> #{column 'New iteration version'}\n"
42
+ @snapshots.each do |snapshot|
43
+ puts "#{column snapshot[0]} : #{column snapshot[1]} -> #{column snapshot[2]} -> #{column snapshot[3]}"
44
+ end
45
+ end
46
+ echo_with_color "\n=================================================================================================",'green'
47
+ end
48
+
49
+ def column(value)
50
+ right_padding value,30;
51
+ end
52
+
53
+ attr_reader :release_version, :next_version, :release_branch, :dry_run, :snapshots
54
+
55
+ def read_release_version
56
+ artifact_version = REXML::Document.new(File.new('pom.xml')).elements['/project/version'].text
57
+ verify_pattern_terminate artifact_version, $snapshot_version
58
+ $snapshot_version.match(artifact_version).captures[0]
59
+ end
60
+
61
+ def read_snapshot_versions
62
+ unless @snapshots
63
+ return
64
+ end
65
+
66
+ help_info "\n\nFound dependencies with SNAPSHOT versions:"
67
+ @snapshots.each do |snapshot|
68
+ default_version=$snapshot_version.match(snapshot[1]).captures[0]
69
+ release_version=self.ask "What release version to use for ==> #{snapshot[0]}?", default_version
70
+ snapshot << (release_version == 'y' ? default_version : release_version)
71
+ end
72
+ end
73
+
74
+ def prepare_new_iteration_deps
75
+ unless @snapshots
76
+ return
77
+ end
78
+
79
+ help_info "\n\nSet SNAPSHOT versions for dependencies for the next iteration"
80
+ @snapshots.each do |snapshot|
81
+ default_version = next_snapshot snapshot[2]
82
+ snap_version=self.ask "For the next iteration, what snapshot version to use for ==> #{snapshot[0]}?", default_version
83
+ snapshot << (snap_version == 'y' ? default_version : snap_version)
84
+ end
85
+ end
86
+
87
+ end
@@ -0,0 +1,88 @@
1
+ # require 'util/utilities'
2
+
3
+ class ReleaseProcess
4
+
5
+ include Utilities
6
+
7
+ def initialize(dry_run, snapshots)
8
+ @summary ||=[]
9
+ @dry_run=dry_run
10
+ @snapshots=snapshots
11
+ end
12
+
13
+ def show_summary
14
+
15
+ if @summary.size==0
16
+ return
17
+ end
18
+
19
+ help_info "\nSummary"
20
+
21
+ @summary.each_with_index do |step, index|
22
+ help_info "\n#{index}. #{step}"
23
+ end
24
+
25
+ end
26
+
27
+ def step(info, commands)
28
+ echo_with_color "#{info}", 'green'
29
+ puts "\n#{commands.join("\n")}"
30
+
31
+ log_commands ||=[]
32
+ commands.each do |command|
33
+
34
+ internal_call_match = /^\$\$(.+)$/.match(command)
35
+ if internal_call_match
36
+ internal_method_call = internal_call_match.captures[0]
37
+ log_commands << internal_method_call
38
+ eval("#{internal_method_call}")
39
+ else
40
+ log_commands << command
41
+ unless @dry_run
42
+ system(command)
43
+ end
44
+ end
45
+
46
+ end
47
+
48
+ @summary << "#{info}: \n\t#{log_commands.join("\n\t")}"
49
+ self
50
+ end
51
+
52
+ def set_release_versions
53
+ pom=read_file 'pom.xml'
54
+
55
+ @snapshots.each do |snapshot|
56
+
57
+ dependency_tag = snapshot[0]
58
+ snapshot_version = snapshot[1]
59
+ release_version = snapshot[2]
60
+
61
+ pom=pom.gsub(
62
+ /<#{dependency_tag}>#{snapshot_version}<\/#{dependency_tag}>/,
63
+ "<#{dependency_tag}>#{release_version}</#{dependency_tag}>"
64
+ )
65
+ end
66
+
67
+ write_file 'pom.xml',pom
68
+ end
69
+
70
+ def set_snapshot_versions
71
+ pom=read_file 'pom.xml'
72
+
73
+ @snapshots.each do |snapshot|
74
+
75
+ dependency_tag = snapshot[0]
76
+ release_version = snapshot[2]
77
+ next_snapshot_version = snapshot[3]
78
+
79
+ pom=pom.gsub(
80
+ /<#{dependency_tag}>#{release_version}<\/#{dependency_tag}>/,
81
+ "<#{dependency_tag}>#{next_snapshot_version}</#{dependency_tag}>"
82
+ )
83
+ end
84
+
85
+ write_file 'pom.xml',pom
86
+ end
87
+
88
+ end
@@ -0,0 +1,72 @@
1
+ require 'colorize'
2
+ require 'io/console'
3
+
4
+ module Utilities
5
+
6
+ def echo_with_color(text, color)
7
+ print text.send("#{color}")
8
+ end
9
+
10
+ def terminate
11
+ abort 'Program terminated'
12
+ end
13
+
14
+ def help_info(text)
15
+ echo_with_color text, 'yellow'
16
+ end
17
+
18
+ def verify_pattern_terminate(value, regex)
19
+ verify_pattern value, regex do
20
+ terminate
21
+ end
22
+ end
23
+
24
+ def verify_pattern(value, regex)
25
+ unless regex.match(value)
26
+ echo_with_color "#{value} must match #{regex}", 'red'
27
+ yield
28
+ end
29
+ end
30
+
31
+ def ask(question, suggestion)
32
+ puts
33
+ echo_with_color "#{question} #{suggestion} : ", 'green'
34
+ $stdout.flush
35
+
36
+ answer = gets.chomp
37
+
38
+ unless answer == ''
39
+ return answer
40
+ end
41
+
42
+ echo_with_color suggestion, 'yellow'
43
+ suggestion
44
+ end
45
+
46
+ def wait_or_do(message)
47
+ echo_with_color message, 'red'
48
+ unless (ask 'Continue?', 'y') == 'y'
49
+ yield
50
+ end
51
+ end
52
+
53
+ def read_file(file_name)
54
+ File.open(file_name).read
55
+ end
56
+
57
+ def write_file(file_name, file_content)
58
+ File.open(file_name, 'w') do |file|
59
+ file.write(file_content)
60
+ end
61
+ end
62
+
63
+ def next_snapshot(version)
64
+ parts = $version.match(version).captures
65
+ "#{parts[0]}#{Integer(parts[1])+1}-SNAPSHOT"
66
+ end
67
+
68
+ def right_padding(string,length)
69
+ (string + ' ' * length)[0,length]
70
+ end
71
+
72
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: frep
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Robert's Software Limited
@@ -17,6 +17,11 @@ extensions: []
17
17
  extra_rdoc_files: []
18
18
  files:
19
19
  - lib/frep.rb
20
+ - lib/release.yml
21
+ - lib/release/release.rb
22
+ - lib/release/release_model.rb
23
+ - lib/release/release_process.rb
24
+ - lib/release/util/utilities.rb
20
25
  homepage: http://rubygems.org/gems/frep
21
26
  licenses:
22
27
  - GPL-3.0