Bundler's rake release with geminabox?

2019-06-24 07:26发布

Is there a way to configure bundler so that when I do rake release it would submit the gem to my own gem server (a gem in a box instance) rather than to rubygems?

Ideally this configuration would be something I can omit from my git repository.

4条回答
神经病院院长
2楼-- · 2019-06-24 07:59

I managed to change the task which uploads the gem to rubygems, that's less intrusive then the solution provided by JohnIV, though the concept is the same.

Rake::Task['release:rubygem_push'].clear
namespace :release do
    task :rubygem_push do
      version = ModuleName::VERSION
      name = 'module_name'
      cmd = "gem nexus pkg/#{name}-#{version}.gem"
      puts `#{cmd} 2>&1`
    end
end
查看更多
虎瘦雄心在
3楼-- · 2019-06-24 08:08

Add 'bundler_geminabox' to your Gemfile:

group :development do
  gem 'bundler_geminabox'
end

Then, in your rakefile, instead of requiring 'bundler/gem_tasks':

require 'bundler_geminabox/gem_tasks'

You don't need to add any tasks to the rakefile; you will automatically get rake build, rake install, and rake release, the last of which uploads to the server listed in ~/.gem/geminabox. Otherwise, the behavior is the same as the equivalent tasks provided by bundler/gem_tasks.

Gem on Github: https://github.com/joshkrueger/bundler_geminabox

查看更多
男人必须洒脱
4楼-- · 2019-06-24 08:12

i made a dependency free gem for this which imitates the geminabox http post request and overwrites bundlers rake release with rake release:inabox

https://github.com/dfherr/geminabox-release

查看更多
smile是对你的礼貌
5楼-- · 2019-06-24 08:15

Rubygems is actually hard-coded into bundler and I've found only one way around it.

The following monkeypatch should get you what you want:

module Bundler
  class GemHelper
    protected
    def rubygem_push(path)
      if Pathname.new("~/.gem/nexus").expand_path.exist?
        sh("gem nexus '#{path}'")
        Bundler.ui.confirm "Pushed #{name} #{version} to https://<your-url-here>/."
      else
        raise "Your Nexus credentials aren't set. Run `gem nexus #{path}` to push your gem and set credentials."
      end
    end
  end
end

The above is for Nexus instead of Geminabox, but the concept should apply to either.

As far as omitting it from git, I'm afraid we're out of luck. However, you can share this appropriately between projects so it will only have to be checked into one place rather than many. Hope this helps!

查看更多
登录 后发表回答