-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRakefile
52 lines (43 loc) · 1.23 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
require 'pathname'
class ThisProject
def self.this_file_path
Pathname.new( __FILE__ ).expand_path
end
def self.project_root
this_file_path.dirname
end
def self.this_file_path
Pathname.new( __FILE__ ).expand_path
end
def self.project_path( *relative_path )
project_root.join( *relative_path )
end
def self.version
path = project_path( "init.rb" )
line = path.read[/^\s*VERSION\s*=\s*.*/]
if line then
return line.match(/.*VERSION\s*=\s*['"](.*)['"]/)[1]
end
end
def self.release_branch
"main"
end
end
task :version do
puts ThisProject.version
end
task :release_check do
unless `git branch` =~ /^\* #{ThisProject.release_branch}/
abort "You must be on the #{ThisProject.release_branch} branch to release!"
end
unless `git status` =~ /^nothing to commit/m
abort "Nope, sorry, you have unfinished business"
end
end
desc "Create tag v#{ThisProject.version} and generate release on github"
task :release => [ :release_check ] do
sh "git commit --allow-empty -a -m 'Release #{ThisProject.version}'"
sh "git tag -a -m 'v#{ThisProject.version}' v#{ThisProject.version}"
sh "git push origin #{ThisProject.release_branch}"
sh "git push origin v#{ThisProject.version}"
end