Skip to content
Browse files

Merge branch 'master' into develop

  • Loading branch information...
2 parents 590ece6 + f4d3673 commit 7eded4833f2bb94562edd9133ae988c54516409a @alloy alloy committed Jun 6, 2012
Showing with 33 additions and 16 deletions.
  1. +33 −16 Rakefile
View
49 Rakefile
@@ -68,24 +68,41 @@ namespace :gem do
desc "Run all specs, build and install gem, commit version change, tag version change, and push everything"
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]"
- exit if STDIN.gets.strip.downcase != 'y'
- lines = `git diff --numstat`.strip.split("\n")
- if lines.size == 0
- puts "Change the version number yourself in lib/cocoapods.rb"
- elsif lines.size == 1 && lines.first.include?('lib/cocoapods.rb')
- # 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 --tags"
- sh "gem push #{gem_filename}"
- else
- puts "Only change the version number in a release commit!"
+ exit if $stdin.gets.strip.downcase != 'y'
+
+ diff_lines = `git diff --numstat`.strip.split("\n")
+
+ if diff_lines.size == 0 || !diff_lines.first.include?('lib/cocoapods.rb')
+ $stderr.puts "Change the version number yourself in lib/cocoapods.rb"
+ exit 1
+ end
+
+ if diff_lines.size > 1 || !diff_lines.first.include?('lib/cocoapods.rb')
+ $stderr.puts "Only change the version number in a release commit!"
+ exit 1
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

0 comments on commit 7eded48

Please sign in to comment.
Something went wrong with that request. Please try again.