forked from amerine/rack_clicky
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Rakefile
69 lines (57 loc) · 1.54 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
require 'rake/clean'
require 'rake/testtask'
require 'fileutils'
Rake::TestTask.new(:test) do |test|
test.libs << 'lib' << 'test'
test.pattern = 'test/**/test_*.rb'
test.verbose = true
end
task :default => :test
###### Packaging
def package_version
@package_version ||= begin
unless defined? RackClicky::Version
load './lib/rack_clicky/version.rb'
end
RackClicky::VERSION
end
end
if defined? Gem
def spec
require 'rubygems' unless defined? Gem::Specification
@spec || eval(File.read('rack_clicky.gemspec'))
end
def package(ext = '')
"pkg/rack_clicky-#{spec.version}" + ext
end
desc "Build rack_clicky packages"
task :package => %w[.gem .tar.gz].map {|e| package(e)}
desc "Install rack_clicky locally"
task :install => package('.gem') do
sh "gem install #{package('.gem')}"
end
directory "pkg/"
CLOBBER.include "pkg/"
file package(".gem") => %w[pkg/ rack_clicky.gemspec] + spec.files do |f|
sh "gem build rack_clicky.gemspec"
mv File.basename(f.name), f.name
end
file package(".tar.gz") => %w[pkg/] + spec.files do |f|
sh <<-SH
git archive \
--prefix=rack_clicky-#{package_version}/ \
--format=tar \
HEAD | gzip > #{f.name}
SH
end
desc "Release rack_clicky"
task :release => ['test', package(".gem")] do
sh <<-SH
gem push #{package(".gem")} &&
git commit --allow-empty -a -m '#{package_version} release' &&
git tag v#{package_version} -m '#{package_version} release' &&
git push &&
git push --tags
SH
end
end