diff options
author | Ryan Davis <ryand-ruby@zenspider.com> | 2022-08-17 23:10:10 -0800 |
---|---|---|
committer | Ryan Davis <ryand-ruby@zenspider.com> | 2022-08-17 23:10:10 -0800 |
commit | 696fd98ffb3eeae166d11c24396ef8c3367ad966 (patch) | |
tree | c051c7b0258df082966bb329d819c690112a672b /lib | |
parent | 365edd63a3eb85b74f003d0a5f12286ab2d4d97d (diff) | |
download | hoe-696fd98ffb3eeae166d11c24396ef8c3367ad966.tar.gz |
+ Added otp_command config option for OTP auth on gem push.
This sets $GEM_HOST_OTP_CODE to the output of the command.
eg:
otp_command: "op item get rubygems.org --otp"
This will be used by rake release if defined.
[git-p4: depot-paths = "//src/hoe/dev/": change = 13514]
Diffstat (limited to 'lib')
-rw-r--r-- | lib/hoe/gemcutter.rb | 28 |
1 files changed, 23 insertions, 5 deletions
diff --git a/lib/hoe/gemcutter.rb b/lib/hoe/gemcutter.rb index 08ccbb8..851d11c 100644 --- a/lib/hoe/gemcutter.rb +++ b/lib/hoe/gemcutter.rb @@ -1,8 +1,29 @@ require "rake" +## +# Gemcutter plugin for hoe. +# +# === Extra Configuration Options: +# +# otp_command:: Shell command to run to populate GEM_HOST_OTP_CODE. + module Hoe::Gemcutter include Rake::DSL if defined?(Rake::DSL) + Hoe::DEFAULT_CONFIG["otp_command"] = false + + def gem_push gems + with_config do |config, _| + otp_command = config["otp_command"] + + ENV["GEM_HOST_OTP_CODE"] = `#{otp_command}`.chomp if otp_command + end + + gems.each do |g| + sh Gem.ruby, "-S", "gem", "push", g + end + end + ## # Define release_to_gemcutter and attach it to the release task. @@ -11,11 +32,8 @@ module Hoe::Gemcutter task :release_to_gemcutter => [:clean, :package, :release_sanity] do pkg = "pkg/#{spec.name}-#{spec.version}" gems = Dir["#{pkg}*.gem"] - gems.each do |g| - # TODO - once gemcutter supports command invocation, use it. - # We could still fail here due to --format executable - sh Gem.ruby, "-S", "gem", "push", g - end + + gem_push gems end task :release_to => :release_to_gemcutter |