forked from jekyll/jekyll-archives
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRakefile
64 lines (50 loc) · 1.17 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
# frozen_string_literal: true
# From jekyll/jekyll-mentions
require "rubygems"
require "bundler"
begin
Bundler.setup(:default, :development, :test)
rescue Bundler::BundlerError => e
warn e.message
warn "Run `bundle install` to install missing gems"
exit e.status_code
end
# Test task
require "rake"
require "rake/testtask"
Rake::TestTask.new(:test) do |test|
test.libs << "lib" << "test"
test.pattern = "test/**/test_*.rb"
end
task :default => "test"
# Release task
def name
@name ||= File.basename(Dir["*.gemspec"].first, ".*")
end
def version
Jekyll::Archives::VERSION
end
def gemspec_file
"#{name}.gemspec"
end
def gem_file
"#{name}-#{version}.gem"
end
desc "Release #{name} v#{version}"
task :release => :build do
unless `git branch` =~ %r!^\* master$!
puts "You must be on the master branch to release!"
exit!
end
sh "git commit --allow-empty -m 'Release :gem: #{version}'"
sh "git tag v#{version}"
sh "git push origin master"
sh "git push origin v#{version}"
sh "gem push pkg/#{name}-#{version}.gem"
end
desc "Build #{name} v#{version} into pkg/"
task :build do
mkdir_p "pkg"
sh "gem build #{gemspec_file}"
sh "mv #{gem_file} pkg"
end