Permalink
Browse files

First pass at adding rake task for Git [fixes #42185331]

Change-Id: I7dc18f71b6d96a81218c3ab38435facd45324f82
  • Loading branch information...
1 parent ce74ee5 commit 48135144d4c13e5fa4045c2f9f13789991016da4 @vito vito committed Jan 14, 2013
Showing with 51 additions and 324 deletions.
  1. +2 −1 .travis.yml
  2. +6 −6 Gemfile
  3. +2 −2 Gemfile.lock
  4. +40 −23 Rakefile
  5. +1 −1 script/gpp
  6. +0 −291 script/release.rb
View
@@ -1,10 +1,11 @@
+language: ruby
rvm:
- "1.9.3"
- "1.9.2"
- "1.8.7"
-
env:
global:
- secure: "UE5QlcvsNEEIiaFVBThh9LFW3LyQG8endi10y1kislgdlVrkpx/b/REU0wwz\nLf1aPGMtKCWbRqBZk0zg8JYTQoig/2wXnct5IJuabOrtgcoWZl/pxGr/0U5A\n5/v0pEq1i3FtXBbOe4Oe2vQuJzhs/WrUXO6gGHsncwQsAreqJtw="
- secure: "IerTwFN0kvQ8zEXxoZJ/NQjwyRzSxh9HbDdr1IljNLyEgDIfx5i57ufemwlH\nVujsITuwg1Ut6b7OLfXFTmbdGHR21XhI3TMBoO34bLuChNlKFQaSkibVSXqe\nr1cTmnbsmVYM4IMImiS0c15WVpVZTYesZTB+P5EsIeQdFJ+j0cw="
- secure: "nZQ4n2D+pzOgWz9Rb75L0NQoKvHOOkms+EpRUlbpq/saSN1pITIpbwGtlbpm\nFGGZbilQxfmdgkp1Wg+3/BmRjgWbn7vjrmudZ5Y137uebmtFhI46/wcjaSTf\n3LBbxkxIQMnzNxGE6PgZgJBrow2pSJ6+ZGI6bk50n+PKQc0kVKY="
+after_success: "rake release:ci"
View
12 Gemfile
@@ -17,17 +17,17 @@ git "git://github.com/cloudfoundry/vmc-plugins.git" do
gem "tunnel-vmc-plugin"
end
-group :development, :test do
- gem "rake"
-end
-
group :development do
- gem "auto_tagger"
- gem "gerrit-cli"
+ gem "gem-release"
end
group :test do
gem "rspec", "~> 2.11"
gem "webmock", "~> 1.9"
gem "rr", "~> 1.0"
end
+
+group :development, :test do
+ gem "rake"
+ gem "auto_tagger"
+end
View
@@ -58,7 +58,7 @@ GEM
multi_json
crack (0.3.2)
diff-lcs (1.1.3)
- gerrit-cli (0.0.1)
+ gem-release (0.4.1)
highline (1.6.15)
json_pure (1.7.6)
mime-types (1.19)
@@ -96,7 +96,7 @@ DEPENDENCIES
auto_tagger
cfoundry!
clouseau!
- gerrit-cli
+ gem-release
interact!
json_pure (~> 1.6)
manifests-vmc-plugin!
View
@@ -1,39 +1,56 @@
require "rake"
+require "auto_tagger"
$LOAD_PATH.unshift File.expand_path("../lib", __FILE__)
require "vmc/version"
-task :default => :spec
+namespace :release do
-desc "Run specs"
-task :spec => "bundler:install" do
- sh("rspec")
-end
-namespace :bundler do
- desc "Install bundler and gems"
- task "install" do
- sh("(gem list --local bundler | grep bundler || gem install bundler) && (bundle check || bundle install)")
+ STAGES = %w[ci staging release].freeze
+ REFS_TO_KEEP = 100.freeze
+
+ def auto_tag(stage=nil)
+ @auto_tag ||= begin
+ raise ArgumentError if stage.nil?
+ AutoTagger::Base.new(:stages => STAGES, :stage => stage, :verbose => true, :push_refs => false, :refs_to_keep => REFS_TO_KEEP)
+ end
+ end
+
+ def create_tag_and_push
+ last_ref_from_previous_stage = auto_tag.last_ref_from_previous_stage
+ tag = auto_tag.create_ref(last_ref_from_previous_stage && last_ref_from_previous_stage.sha)
+ sh "git push origin #{tag.name}"
+ auto_tag.delete_locally
+ auto_tag.delete_on_remote
end
-end
-namespace :gem do
- desc "Build Gem"
- task :build do
- sh "gem build vmc.gemspec"
+ def last_sha_for(stage)
+ last = auto_tag.refs_for_stage(stage).last
+ last && last.sha
end
- desc "Install Gem"
- task :install => :build do
- sh "gem install --local vmc-#{VMC::VERSION}"
- sh "rm vmc-#{VMC::VERSION}.gem"
+ task :ci do
+ auto_tag "ci"
+
+ create_tag_and_push
end
- desc "Uninstall Gem"
- task :uninstall do
- sh "gem uninstall vmc"
+ task :stage, :ref do |_, args|
+ auto_tag "staging"
+
+ ref_to_stage = args.ref || last_sha_for("ci")
+ sh "git checkout #{ref_to_stage}" if ref_to_stage
+
+ last_sha_for_staging = last_sha_for("staging")
+ sh "gem bump --push" if last_sha_for_staging.nil? || (last_sha_for_staging == last_sha_for("release"))
+ create_tag_and_push
end
- desc "Reinstall Gem"
- task :reinstall => [:uninstall, :install]
+ task :rubygems do
+ auto_tag "release"
+
+ last_stage = auto_tag.last_ref_from_previous_stage
+ sh "git checkout #{last_stage.sha} && gem release --tag" if last_stage
+ end
end
View
@@ -1,3 +1,3 @@
#! /bin/sh
-git pull --rebase origin master && (bundle check || bundle) && rspec && gerrit push
+git pull --rebase origin master && (bundle check || bundle) && bundle exec rspec && git push origin master
Oops, something went wrong.

0 comments on commit 4813514

Please sign in to comment.