forked from nackd/redmine_cmi
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Rakefile
29 lines (27 loc) · 1.07 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
desc 'Add a tag in git'
task :tag, :version do |t, args|
tagname = args.version
raise 'Please, specify a tagname' unless tagname
puts "Adding tag #{tagname}..."
system "git tag #{tagname}"
end
desc "Update plugin version info in init.rb"
task :update_version, :version do |t, args|
version = args.version
raise 'Please, specify a version number' unless version
puts "Changing plugin version to #{version}..."
text = File.open(File.join(File.dirname(__FILE__), 'init.rb'), 'r') { |file| file.read }
File.open(File.join(File.dirname(__FILE__), 'init.rb'), 'w') { |file|
file.write(text)
} if text.gsub!(/\bversion\b.*$/, "version '#{version}'")
end
desc 'Release a new version'
task :release, [:version] => :update_version do |t, args|
version = args.version
puts 'Committing...'
system "git commit -m 'release: #{args.version}' init.rb"
Rake::Task[:tag].invoke args.version
puts 'Archiving...'
filename = File.join(File.dirname(__FILE__), "redmine_cmi-#{version}.tar.gz")
system "git archive --prefix=redmine_cmi/ --format=tar HEAD | gzip > #{filename}"
end