Permalink
Browse files

adding rake tasks for gem building

  • Loading branch information...
1 parent b9cc85a commit 260340b12fcfae55219148321c874b2bbdf91c29 @outerim outerim committed Jun 2, 2009
Showing with 103 additions and 0 deletions.
  1. +33 −0 Rakefile
  2. +1 −0 lib/pelvis.rb
  3. +3 −0 lib/pelvis/version.rb
  4. +66 −0 tasks/release.rake
View
@@ -1,5 +1,38 @@
require 'rubygems'
require 'spec/rake/spectask'
+require 'rake/gempackagetask'
+
+require File.dirname(__FILE__) + '/lib/pelvis/version'
+
+@lib_module = Pelvis
+@spec = Gem::Specification.new do |s|
+ s.name = 'pelvis'
+ s.version = Pelvis::VERSION
+ s.platform = Gem::Platform::RUBY
+ s.has_rdoc = false
+ s.author = 'Engine Yard'
+ s.email = 'tech@engineyard.com'
+ s.homepage = 'http://github.com/halorgium/pelvis'
+ s.summary = 'A vertebra-like framework'
+ s.description = s.summary
+
+ s.require_path = 'lib'
+ s.files = %w(Rakefile) + Dir.glob("{lib,spec}/**/*")
+
+ s.add_dependency 'eventmachine', '>= 0.12.7'
+ s.add_dependency 'blather', '>= 0.3.4'
+
+ # this is because rubygems is lame
+ s.add_dependency('mime-types', '>= 1.16')
+ s.add_dependency('echoe', '>= 3.1.1')
+ s.add_dependency('highline')
+end
+
+Rake::GemPackageTask.new(@spec) do |pkg|
+ pkg.gem_spec = @spec
+end
+
+load 'tasks/release.rake'
desc 'Default: run spec examples'
task :default => 'spec'
View
@@ -5,6 +5,7 @@
$:.unshift File.dirname(__FILE__)
+require 'pelvis/version'
require 'pelvis/util'
require 'pelvis/logging'
View
@@ -0,0 +1,3 @@
+module Pelvis
+ VERSION = '0.1.0'
+end
View
@@ -0,0 +1,66 @@
+desc "Release the version"
+task :release do
+ puts "Releasing #{@spec.version}"
+
+ `git show-ref tags/v#{@spec.version}`
+ unless $?.success?
+ abort "There is no tag for v#{@spec.version}"
+ end
+
+ base_dir = File.expand_path(File.dirname(__FILE__) + '/..')
+ release_directory = "#{base_dir}/.releasing"
+
+ if File.exists?(release_directory)
+ abort "Removing the #{release_directory} directory, we need it!"
+ end
+
+ Dir.mkdir(release_directory)
+
+ puts "Extracting the tag's contents to #{release_directory}"
+ system("git archive --format tar tags/v#{@spec.version} | tar -C #{release_directory} -xpf -")
+ unless $?.success?
+ abort "There was a problem extracting"
+ end
+
+ puts "Creating a gem inside #{release_directory}"
+ system("cd #{release_directory} && rake gem")
+ unless $?.success?
+ abort "There was a problem creating the gem"
+ end
+
+ puts "Uploading gem to internal gem server"
+ ENV.delete("GEM_PATH")
+ system("samurai", "gem_upload", "#{release_directory}/pkg/#{@spec.name}-#{@spec.version}.gem") || abort("Could not upload gem")
+
+ puts "Removing #{release_directory}"
+ FileUtils.rm_rf(release_directory)
+
+ ints = @spec.version.ints + [0]
+ next_version = Gem::Version.new(ints.join(".")).bump
+
+ puts "Changing the version to #{next_version}."
+
+ version_file = "#{base_dir}/lib/#{@spec.name}/version.rb"
+ File.open(version_file, "w") do |f|
+ f.puts <<-EOT
+module #{@lib_module}
+ VERSION = "#{next_version}"
+end
+ EOT
+ end
+
+ puts "Committing the version change"
+ system("git", "commit", version_file, "-m", "Next version: #{next_version}")
+
+ puts "Pushing tag and commits up in..."
+ 5.times do |i|
+ print "#{5 - i}.. "
+ $stdout.flush
+ end
+ puts
+
+ system("git", "push")
+ system("git", "push", "--tags")
+
+ puts "Finished"
+end

0 comments on commit 260340b

Please sign in to comment.