forked from evilsocket/bettercap
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Rakefile
107 lines (84 loc) · 2.53 KB
/
Rakefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
require 'rake'
VERSION_FILENAME = 'lib/bettercap/version.rb'
def get_current_version
current_version = nil
data = File.read( VERSION_FILENAME )
if data =~ /VERSION\s+=\s+'([^']+)'/i
current_version = $1
end
raise 'Could not extract current version.' if current_version.nil?
current_version
end
def change_version( currentv, newv )
puts "@ Upgrading from '#{currentv}' to '#{newv}' ..."
data = File.read( VERSION_FILENAME )
data = data.gsub( currentv, newv )
File.open( VERSION_FILENAME, 'w') {
|file| file.puts data
}
end
namespace :util do
desc "Build a GEM from the current source code and install it locally."
task :sync do
puts "@ Synchronizing codebase with GEM installation ..."
`rm -rf *.gem`
`gem build bettercap.gemspec`
`sudo gem install --no-rdoc --no-ri --local *.gem`
end
desc "Upgrade version to stable, push to github and upload the new GEM release."
task :release do
current_version = get_current_version
raise 'Current version is not a beta.' unless current_version.end_with?'b'
next_version = current_version.gsub('b','')
change_version( current_version, next_version )
current_version = next_version
puts "@ Pushing to github ..."
sh "git add #{VERSION_FILENAME}"
sh "git commit -m \"Version bump to #{current_version}\""
sh "git push"
Rake::Task["util:sync"].invoke
puts "@ Uploading GEM ..."
sh "gem push bettercap-#{current_version}.gem"
`rm -rf *.gem`
Rake::Task["util:sync"].invoke
end
desc "Print a markdown changelog for the current release."
task :changelog do
feats = []
fixes = []
style = []
puts "@ Fetching remote tags ...\n\n"
`git fetch --tags`
lines = `git log \`git describe --tags --abbrev=0\`..HEAD --oneline`.split("\n")
lines.each do |line|
if line =~ /^[^\s]+\s+(.+)$/
msg = $1.gsub( /([^\s]*[A-Z][^\s]*[A-Z][^\s]*)/, '`\1`' ).gsub( /([a-z]+_[a-z]+)/, '`\1`' )
dwn = msg.downcase
next if dwn.include?('version bump') or dwn.include?('rake')
if dwn.include?('fix')
fixes << msg
elsif dwn.include?('new')
feats << msg
else
style << msg
end
end
end
puts "Changelog"
puts "===\n\n"
puts "**New Features**\n\n"
feats.each do |m|
puts "* #{m}"
end
puts "\n**Fixes**\n\n"
fixes.each do |m|
puts "* #{m}"
end
puts "\n**Code Style**\n\n"
style.each do |m|
puts "* #{m}"
end
puts "\n"
end
end
task :default => 'util:sync'