Commit f4d3673f authored by Eloy Duran's avatar Eloy Duran

Add a few more checks to gem:release task.

parent 3c34ade2
...@@ -68,24 +68,41 @@ namespace :gem do ...@@ -68,24 +68,41 @@ namespace :gem do
desc "Run all specs, build and install gem, commit version change, tag version change, and push everything" desc "Run all specs, build and install gem, commit version change, tag version change, and push everything"
task :release do task :release do
if `git symbolic-ref HEAD 2>/dev/null`.strip.split('/').last != 'master'
$stderr.puts "You need to be on the `master' branch in order to be able to do a release."
exit 1
end
if `git tag`.strip.split("\n").include?(gem_version)
$stderr.puts "A tag for version `#{gem_version}' already exists. Change the version in lib/cocoapods.rb"
exit 1
end
puts "You are about to release `#{gem_version}', is that correct? [y/n]" puts "You are about to release `#{gem_version}', is that correct? [y/n]"
exit if STDIN.gets.strip.downcase != 'y' exit if $stdin.gets.strip.downcase != 'y'
lines = `git diff --numstat`.strip.split("\n")
if lines.size == 0 diff_lines = `git diff --numstat`.strip.split("\n")
puts "Change the version number yourself in lib/cocoapods.rb"
elsif lines.size == 1 && lines.first.include?('lib/cocoapods.rb') if diff_lines.size == 0 || !diff_lines.first.include?('lib/cocoapods.rb')
# First see if the specs pass and gem builds and installs $stderr.puts "Change the version number yourself in lib/cocoapods.rb"
Rake::Task['spec:all'].invoke exit 1
Rake::Task['gem:install'].invoke end
# Then release
sh "git commit lib/cocoapods.rb -m 'Release #{gem_version}'" if diff_lines.size > 1 || !diff_lines.first.include?('lib/cocoapods.rb')
sh "git tag -a #{gem_version} -m 'Release #{gem_version}'" $stderr.puts "Only change the version number in a release commit!"
sh "git push origin master" exit 1
sh "git push --tags"
sh "gem push #{gem_filename}"
else
puts "Only change the version number in a release commit!"
end end
# First see if the specs pass and gem builds and installs
Rake::Task['spec:all'].invoke
Rake::Task['gem:install'].invoke
# Then release
sh "git commit lib/cocoapods.rb -m 'Release #{gem_version}'"
sh "git tag -a #{gem_version} -m 'Release #{gem_version}'"
sh "git push origin master"
sh "git push origin --tags"
sh "gem push #{gem_filename}"
end end
end end
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment