forked from alpheios-project/arethusa-configs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Rakefile
57 lines (46 loc) · 1.14 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
require 'rake'
class Version
attr_accessor :major, :minor, :patch
def initialize
@major, @minor, @patch = File.read(file).split('.').map(&:to_i)
end
def file
"VERSION"
end
def bump(quality = :patch)
unless %i{ major minor patch }.include?(quality)
raise "Only major, minor or patch bumps are accepted"
end
send("#{quality}=", send(quality) + 1)
File.write(file, to_version)
to_version
end
def to_version
[@major, @minor, @patch].join('.')
end
end
desc 'Build configuration files'
task :build do
Dir.chdir('configs') do
Dir.glob('*') do |f|
if File.file?(f)
`arethusa merge #{f} -mb . > ../dist/#{f}`
puts "Created dist/#{f}"
end
end
end
end
def git(command)
system("git #{command}")
end
desc 'Update dist folder, raise version and release'
task :release, [:quality] do |t, args|
Rake::Task[:build].invoke
quality = (args[:quality] || :patch).to_sym
version = Version.new.bump(quality)
puts
puts "Raised version num to #{version}"
git('add -A')
git("commit -m 'Release version #{version}'")
git("tag -a v#{version} -m 'Version #{version}'")
end