Skip to content

Commit e596db1

Browse files
committed
Add release task to Rakefile
1 parent 8977e11 commit e596db1

File tree

2 files changed

+43
-0
lines changed

2 files changed

+43
-0
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@
22
Gemfile.lock
33
test/destination
44
.bundle
5+
pkg/

Rakefile

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@ rescue Bundler::BundlerError => e
1111
exit e.status_code
1212
end
1313

14+
15+
# Test task
16+
1417
require 'rake'
1518
require 'rake/testtask'
1619

@@ -21,3 +24,42 @@ Rake::TestTask.new(:test) do |test|
2124
end
2225

2326
task :default => 'test'
27+
28+
29+
# Release task
30+
31+
def name
32+
@name ||= File.basename(Dir['*.gemspec'].first, ".*")
33+
end
34+
35+
def version
36+
Jekyll::Archives::VERSION
37+
end
38+
39+
def gemspec_file
40+
"#{name}.gemspec"
41+
end
42+
43+
def gem_file
44+
"#{name}-#{version}.gem"
45+
end
46+
47+
desc "Release #{name} v#{version}"
48+
task :release => :build do
49+
unless `git branch` =~ /^\* master$/
50+
puts "You must be on the master branch to release!"
51+
exit!
52+
end
53+
sh "git commit --allow-empty -m 'Release :gem: #{version}'"
54+
sh "git tag v#{version}"
55+
sh "git push origin master"
56+
sh "git push origin v#{version}"
57+
sh "gem push pkg/#{name}-#{version}.gem"
58+
end
59+
60+
desc "Build #{name} v#{version} into pkg/"
61+
task :build do
62+
mkdir_p "pkg"
63+
sh "gem build #{gemspec_file}"
64+
sh "mv #{gem_file} pkg"
65+
end

0 commit comments

Comments
 (0)