2010-07-28 19:30:56 +00:00
|
|
|
namespace :git do
|
|
|
|
namespace :tag do
|
2010-08-17 01:21:17 +00:00
|
|
|
desc 'List tags from the Git repository'
|
2010-07-28 19:30:56 +00:00
|
|
|
task :list do
|
|
|
|
tags = `git tag -l`
|
2012-02-10 14:49:52 +00:00
|
|
|
tags.gsub!("\r", '')
|
|
|
|
tags = tags.split("\n").sort {|a, b| b <=> a }
|
|
|
|
puts tags.join("\n")
|
2010-07-28 19:30:56 +00:00
|
|
|
end
|
|
|
|
|
2010-08-17 01:21:17 +00:00
|
|
|
desc 'Create a new tag in the Git repository'
|
2010-07-28 19:30:56 +00:00
|
|
|
task :create do
|
2011-12-02 13:41:05 +00:00
|
|
|
changelog = File.open('CHANGELOG.md', 'r') { |file| file.read }
|
2010-08-17 01:21:17 +00:00
|
|
|
puts '-' * 80
|
2010-07-28 19:30:56 +00:00
|
|
|
puts changelog
|
2010-08-17 01:21:17 +00:00
|
|
|
puts '-' * 80
|
2010-07-28 19:30:56 +00:00
|
|
|
puts
|
|
|
|
|
2010-08-17 01:21:17 +00:00
|
|
|
v = ENV['VERSION'] or abort 'Must supply VERSION=x.y.z'
|
2010-07-28 19:30:56 +00:00
|
|
|
abort "Versions don't match #{v} vs #{PKG_VERSION}" if v != PKG_VERSION
|
|
|
|
|
2012-02-10 14:49:52 +00:00
|
|
|
git_status = `git status`
|
|
|
|
if git_status !~ /nothing to commit \(working directory clean\)/
|
|
|
|
abort "Working directory isn't clean."
|
|
|
|
end
|
|
|
|
|
2010-07-28 19:30:56 +00:00
|
|
|
tag = "#{PKG_NAME}-#{PKG_VERSION}"
|
|
|
|
msg = "Release #{PKG_NAME}-#{PKG_VERSION}"
|
|
|
|
|
2010-08-17 01:21:17 +00:00
|
|
|
existing_tags = `git tag -l #{PKG_NAME}-*`.split('\n')
|
2010-07-28 19:30:56 +00:00
|
|
|
if existing_tags.include?(tag)
|
2010-08-17 01:21:17 +00:00
|
|
|
warn('Tag already exists, deleting...')
|
2010-07-28 19:30:56 +00:00
|
|
|
unless system "git tag -d #{tag}"
|
2010-08-17 01:21:17 +00:00
|
|
|
abort 'Tag deletion failed.'
|
2010-07-28 19:30:56 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
puts "Creating git tag '#{tag}'..."
|
|
|
|
unless system "git tag -a -m \"#{msg}\" #{tag}"
|
2010-08-17 01:21:17 +00:00
|
|
|
abort 'Tag creation failed.'
|
2010-07-28 19:30:56 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2014-12-15 19:44:51 +00:00
|
|
|
task 'gem:release' => 'git:tag:create'
|