forked from ruby/stringio
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Rakefile
65 lines (52 loc) · 1.61 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
require "bundler/gem_tasks"
require "rake/testtask"
name = "stringio"
Rake::TestTask.new(:test) do |t|
ENV["RUBYOPT"] = "-Ilib"
t.libs << "test" << "test/lib"
t.ruby_opts << "-rhelper"
t.test_files = FileList["test/**/test_*.rb"]
end
task :sync_tool do
require 'fileutils'
FileUtils.cp "../ruby/tool/lib/test/unit/core_assertions.rb", "./test/lib"
FileUtils.cp "../ruby/tool/lib/envutil.rb", "./test/lib"
FileUtils.cp "../ruby/tool/lib/find_executable.rb", "./test/lib"
end
require 'rake/extensiontask'
Rake::ExtensionTask.new(name)
task :default => [:compile, :test]
task "build" => "date_epoch"
task "date_epoch" do
ENV["SOURCE_DATE_EPOCH"] = IO.popen(%W[git -C #{__dir__} log -1 --format=%ct], &:read).chomp
end
helper = Bundler::GemHelper.instance
def helper.version=(v)
gemspec.version = v
tag_version
end
def helper.tag_version
v = version.to_s
src = "ext/stringio/stringio.c"
File.open(File.join(__dir__, src), "r+b") do |f|
code = f.read
code.sub!(/^#define\s+STRINGIO_VERSION\s+\K".*"/) {v.dump}
f.rewind
f.write(code)
f.truncate(f.pos)
end
# system("git", "--no-pager", "-C", __dir__, "diff", "-U0", src, exception: true)
system("git", "-C", __dir__, "commit", "-mBump version to #{version}", src, exception: true)
super
end
major, minor, teeny = helper.gemspec.version.segments
task "bump:teeny" do
helper.version = Gem::Version.new("#{major}.#{minor}.#{teeny+1}")
end
task "bump:minor" do
helper.version = Gem::Version.new("#{major}.#{minor+1}.0")
end
task "bump:major" do
helper.version = Gem::Version.new("#{major+1}.0.0")
end
task "bump" => "bump:teeny"