forked from rack/rack-test
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Thorfile
49 lines (41 loc) · 1.01 KB
/
Thorfile
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
module GemHelpers
def read_gemspec
@read_gemspec ||= eval(File.read('rack-test.gemspec'))
end
def sh(command)
puts command
system command
end
end
class Default < Thor
include GemHelpers
desc 'build', 'Build a rack-test gem'
def build
sh 'gem build rack-test.gemspec'
FileUtils.mkdir_p 'pkg'
FileUtils.mv read_gemspec.file_name, 'pkg'
end
desc 'install', 'Install the latest built gem'
def install
sh "gem install --local pkg/#{read_gemspec.file_name}"
end
desc 'release', 'Release the current branch to GitHub and RubyGems.org'
def release
build
Release.new.tag
Release.new.gem
end
end
class Release < Thor
include GemHelpers
desc 'tag', 'Tag the gem on the origin server'
def tag
release_tag = "v#{read_gemspec.version}"
sh "git tag -a #{release_tag} -m 'Tagging #{release_tag}'"
sh "git push origin #{release_tag}"
end
desc 'gem', 'Push the gem to RubyGems.org'
def gem
sh "gem push pkg/#{read_gemspec.file_name}"
end
end