Created
August 23, 2013 00:07
-
-
Save dallasmarlow/6314218 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
require 'capistrano/cli' | |
require 'gem_command' | |
cap_file = File.join File.dirname(__FILE__), '..', 'lib', 'tumblr_gem_publish.rb' | |
gem_file = ARGV.first | |
abort "usage: tumblr_gem_publish pants.gem" unless gem_file and File.exist? gem_file | |
# build gem if gemspec is passed | |
if gem_file.end_with? '.gemspec' | |
puts 'building gem from gemspec: ' + gem_file | |
GemCommand.new 'BuildCommand', gem_file | |
gem_file = Dir.entries('.').find {|entry| entry.end_with? '.gem'} | |
puts "\n" | |
end | |
task_parameters = [ | |
'--file', cap_file, | |
'publish:rubygem', | |
'-s', 'gem_file=' + gem_file, | |
] | |
puts 'publishing gem to remote server' | |
Capistrano::CLI.parse(task_parameters).execute! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
default_run_options[:pty] = true | |
ssh_options[:forward_agent] = true | |
role :gem_server, 'nexus' | |
set :gem_command, :tumblr_gem | |
namespace :publish do | |
task :rubygem do | |
abort "usage: cap publish:rubygem -s gem_file=pants.gem" unless exists?(:gem_file) | |
abort "gem file: #{gem_file} does not exist" unless File.exist?(gem_file) | |
remote_gem_path = File.join '/tmp', gem_file | |
upload gem_file, remote_gem_path | |
# install gem | |
sudo [gem_command, :install, remote_gem_path].join "\s" | |
# remove remote tmp gem | |
run 'rm ' + remote_gem_path | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment