forked from creative-co/rumeme
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Rakefile
95 lines (80 loc) · 2.13 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
require 'rake'
require 'rake/testtask'
require 'bundler/gem_tasks'
desc 'Test the rumeme gem'
Rake::TestTask.new(:test) do |t|
t.libs << 'lib'
t.pattern = 'test/**/*_test.rb'
t.verbose = true
end
task :default => [:test]
desc "Bumps the version by a minor or patch version, depending on what was passed in."
task :bump, :part do |t, args|
if Rumeme::VERSION =~ /^(\d+)\.(\d+)\.(\d+)(?:\.(.*?))?$/
major = $1.to_i
minor = $2.to_i
patch = $3.to_i
else
abort
end
case args[:part]
when /minor/
minor += 1
patch = 0
when /patch/
patch += 1
else
abort
abort
end
version = [major, minor, patch].compact.join('.')
File.open(File.join("lib", "rumeme", "version.rb"), "w") do |f|
f.write <<EOF
module Rumeme
VERSION = "#{version}"
end
EOF
end
end
desc "Writes out the new CHANGELOG and prepares the release"
task :change do
load 'lib/rumeme/version.rb'
file = "CHANGELOG"
old = File.read(file)
version = Rumeme::VERSION
message = "Bumping to version #{version}"
File.open(file, "w") do |f|
f.write <<EOF
Version #{version} - #{Date.today}
===============================================================================
#{`git log $(git tag | tail -1)..HEAD | git shortlog`}
#{old}
EOF
end
editor = ENV["EDITOR"] || 'mvim'
system ["#{editor} #{file}",
"git commit -aqm '#{message}'",
"git tag -a -m '#{message}' v#{version}",
"echo '\n\n\033[32mMarked v#{version} /' `git show-ref -s refs/heads/master` 'for release.\033[0m\n\n'"].join(' && ')
end
desc "Bump by a minor version (1.2.3 => 1.3.0)"
task :minor do |t|
Rake::Task['bump'].invoke(t.name)
Rake::Task['change'].invoke
end
desc "Bump by a patch version, (1.2.3 => 1.2.4)"
task :patch do |t|
Rake::Task['bump'].invoke(t.name)
Rake::Task['change'].invoke
end
desc "Push the latest version and tags"
task :push do
system("git push origin master")
system("git push origin $(git tag | tail -1)")
end
#desc 'Preparing release'
#task :prepare_release, :part do |t, args|
# Rake::Task['bump'].invoke(args[:part])
# Rake::Task['change'].invoke
# Rake::Task['push'].invoke
#end