forked from minad/lmdb
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Rakefile
69 lines (54 loc) · 1.37 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
#!/usr/bin/env rake
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), "lib"))
GEMSPEC = Dir['*.gemspec'].first
PRJ = File.basename(GEMSPEC, ".gemspec")
require 'bundler/setup'
require 'rspec/core/rake_task'
require 'rake/extensiontask'
RSpec::Core::RakeTask.new :spec
Rake::ExtensionTask.new :lmdb_ext
task :default => [:compile, :spec]
def version
@version ||= begin
require "#{PRJ}/version"
warn "LMDB::VERSION not a string" unless LMDB::VERSION.kind_of? String
LMDB::VERSION
end
end
def tag
@tag ||= "v#{version}"
end
def latest
@latest ||= `git describe --abbrev=0 --tags --match 'v*'`.chomp
end
desc "Commit, tag, and push repo; build and push gem"
task :release => "release:is_new_version" do
require 'tempfile'
sh "gem build #{GEMSPEC}"
file = Tempfile.new "template"
begin
file.puts "release #{version}"
file.close
sh "git commit --allow-empty -a -v -t #{file.path}"
ensure
file.close unless file.closed?
file.unlink
end
sh "git tag #{tag}"
sh "git push"
sh "git push --tags"
sh "gem push #{PRJ}-#{version}.gem"
end
namespace :release do
desc "Diff to latest release"
task :diff do
sh "git diff #{latest}"
end
desc "Log to latest release"
task :log do
sh "git log #{latest}.."
end
task :is_new_version do
abort "#{tag} exists; update version!" unless `git tag -l #{tag}`.empty?
end
end