-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathRakefile
114 lines (90 loc) · 2.69 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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
require 'rspec/core/rake_task'
require 'rubygems/package_task'
require './lib/txdb'
Bundler::GemHelper.install_tasks
desc 'Run specs'
RSpec::Core::RakeTask.new do |t|
t.pattern = './spec/**/*_spec.rb'
end
task default: :spec
namespace :spec do
desc 'Run full spec suite'
task full: [:full_spec_env, :spec]
task :full_spec_env do
ENV['FULL_SPEC'] = 'true'
end
end
namespace :version do
task :bump, [:level] do |t, args|
levels = %w(major minor patch)
level = args[:level]
until levels.include?(level)
STDOUT.write("Indicate version bump level (#{levels.join(', ')}): ")
level = STDIN.gets.strip
unless levels.include?(level)
puts "That's not a valid version bump level, try again."
end
end
level.strip!
major, minor, patch = Txdb::VERSION.split('.').map(&:to_i)
case level
when 'major'
major += 1; minor = 0; patch = 0
when 'minor'
minor += 1; patch = 0
when 'patch'
patch += 1
end
new_version = [major, minor, patch].join('.')
puts "Bumping from #{Txdb::VERSION} to #{new_version}"
# rewrite version.rb
version_file = './lib/txdb/version.rb'
contents = File.read(version_file)
contents.sub!(/VERSION\s*=\s['"][\d.]+['"]$/, "VERSION = '#{new_version}'")
File.write(version_file, contents)
# update constant in case other rake tasks run in this process afterwards
Txdb::VERSION.replace(new_version)
end
task :history do
history = File.read('History.txt')
history = "== #{Txdb::VERSION}\n* \n\n#{history}"
File.write('History.txt', history)
system "vi History.txt"
end
task :commit_and_push do
system "git add lib/txdb/version.rb"
system "git add History.txt"
system "git commit -m 'Bumping version to #{Txdb::VERSION}'"
system "git push origin HEAD"
end
end
DOCKER_REPO = 'quay.io/lumoslabs/txdb'
namespace :publish do
task :all do
task_names = %w(
version:bump version:history version:commit_and_push
publish:tag publish:build_gem publish:publish_gem
)
task_names.each do |task_name|
STDOUT.write "About to execute #{task_name}, continue? (yes/no/skip): "
answer = STDIN.gets
case answer.downcase
when /ye?s?/
Rake::Task[task_name].invoke
when /no?/
puts "Exiting!"
exit 0
else
puts "Skipping #{task_name}"
end
end
end
task :tag do
system("git tag -a v#{Txdb::VERSION} && git push origin --tags")
end
task :build_gem => [:build] # use preexisting build task from rubygems/package_task
task :publish_gem do
system("gem push pkg/txdb-#{Txdb::VERSION}.gem")
end
end
task publish: 'publish:all'