Skip to content
This repository
Browse code

Add some sanity checks to the gem push script

  • Loading branch information...
commit dab1d8dcc6030a5c1f5e88744d3c40d771be23a3 1 parent 6b3f521
Carl Lerche authored November 16, 2010

Showing 1 changed file with 16 additions and 2 deletions. Show diff stats Hide diff stats

  1. 18  tasks/release.rb
18  tasks/release.rb
@@ -2,6 +2,7 @@
2 2
 
3 3
 root    = File.expand_path('../../', __FILE__)
4 4
 version = File.read("#{root}/RAILS_VERSION").strip
  5
+tag     = "v#{version}"
5 6
 
6 7
 directory "dist"
7 8
 
@@ -52,15 +53,28 @@
52 53
       sh "gem install #{gem}"
53 54
     end
54 55
 
  56
+    task :prep_release => [:ensure_clean_state, :build]
  57
+
55 58
     task :push => :build do
56 59
       sh "gem push #{gem}"
57 60
     end
58 61
   end
59 62
 end
60 63
 
61  
-namespace :git do
  64
+namespace :release do
  65
+  task :ensure_clean_state do
  66
+    unless `git status -s | grep -v RAILS_VERSION`.strip.empty?
  67
+      abort "[ABORTING] `git status` reports a dirty tree. Make sure all changes are committed"
  68
+    end
  69
+
  70
+    unless ENV['SKIP_TAG'] || `git tag | grep #{tag}`.strip.empty?
  71
+      abort "[ABORTING] `git tag` shows that #{tag} already exists. Has this version already\n"\
  72
+            "           been released? Git tagging can be skipped by setting SKIP_TAG=1"
  73
+    end
  74
+  end
  75
+
62 76
   task :tag do
63  
-    sh "git tag v#{version}"
  77
+    sh "git tag #{tag}"
64 78
   end
65 79
 end
66 80
 

0 notes on commit dab1d8d

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