├── .github ├── release-drafter.yml └── workflows │ └── push.yml ├── .gitignore ├── .travis.yml ├── CHANGELOG.md ├── Dangerfile ├── Gemfile ├── LICENSE.txt ├── README.md ├── Rakefile ├── capistrano-rbenv.gemspec └── lib ├── capistrano-rbenv.rb └── capistrano ├── rbenv.rb └── tasks └── rbenv.rake /.github/release-drafter.yml: -------------------------------------------------------------------------------- 1 | name-template: "$NEXT_PATCH_VERSION" 2 | tag-template: "v$NEXT_PATCH_VERSION" 3 | categories: 4 | - title: "⚠️ Breaking Changes" 5 | label: "⚠️ Breaking" 6 | - title: "✨ New Features" 7 | label: "✨ Feature" 8 | - title: "🐛 Bug Fixes" 9 | label: "🐛 Bug Fix" 10 | - title: "📚 Documentation" 11 | label: "📚 Docs" 12 | - title: "🏠 Housekeeping" 13 | label: "🏠 Housekeeping" 14 | change-template: "- $TITLE (#$NUMBER) @$AUTHOR" 15 | no-changes-template: "- No changes" 16 | template: | 17 | $CHANGES 18 | -------------------------------------------------------------------------------- /.github/workflows/push.yml: -------------------------------------------------------------------------------- 1 | name: Release Drafter 2 | 3 | on: 4 | push: 5 | branches: 6 | - master 7 | 8 | jobs: 9 | update_release_draft: 10 | runs-on: ubuntu-latest 11 | steps: 12 | - uses: release-drafter/release-drafter@v5 13 | env: 14 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 15 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.gem 2 | Gemfile.lock 3 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | sudo: false 2 | language: ruby 3 | rvm: 4 | - 2.3.3 5 | before_install: gem install bundler -v '~> 1.14' --conservative 6 | before_script: bundle exec danger 7 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | Release notes for this project are kept here: https://github.com/capistrano/rbenv/releases 2 | -------------------------------------------------------------------------------- /Dangerfile: -------------------------------------------------------------------------------- 1 | danger.import_dangerfile(github: "capistrano/danger", branch: "no-changelog") 2 | -------------------------------------------------------------------------------- /Gemfile: -------------------------------------------------------------------------------- 1 | source 'https://rubygems.org' 2 | 3 | # Specify your gem's dependencies in capistrano-rbenv.gemspec 4 | gemspec 5 | -------------------------------------------------------------------------------- /LICENSE.txt: -------------------------------------------------------------------------------- 1 | MIT License (MIT) 2 | 3 | Copyright (c) 2013-2014 Kir Shatrov 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in 13 | all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | THE SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Capistrano::rbenv 2 | 3 | This gem provides idiomatic rbenv support for Capistrano 3.x (and 3.x 4 | *only*). 5 | 6 | ## Please Note 7 | 8 | If you want to use this plugin with Cap 2.x, please use 1.x version of the gem. 9 | Source code and docs for older integration is available in [another repo](https://github.com/yyuu/capistrano-rbenv) 10 | 11 | Thanks a lot to [@yyuu](https://github.com/yyuu) for merging his gem with official one. 12 | 13 | ## Installation 14 | 15 | Add this line to your application's Gemfile: 16 | 17 | gem 'capistrano', '~> 3.9' 18 | gem 'capistrano-rbenv', '~> 2.2' 19 | 20 | And then execute: 21 | 22 | $ bundle install 23 | 24 | ## Usage 25 | 26 | # Capfile 27 | require 'capistrano/rbenv' 28 | 29 | 30 | # config/deploy.rb 31 | set :rbenv_type, :user # or :system, or :fullstaq (for Fullstaq Ruby), depends on your rbenv setup 32 | set :rbenv_ruby, '2.4.2' 33 | 34 | # in case you want to set ruby version from the file: 35 | # set :rbenv_ruby, File.read('.ruby-version').strip 36 | 37 | set :rbenv_prefix, "RBENV_ROOT=#{fetch(:rbenv_path)} RBENV_VERSION=#{fetch(:rbenv_ruby)} #{fetch(:rbenv_path)}/bin/rbenv exec" 38 | set :rbenv_map_bins, %w{rake gem bundle ruby rails} 39 | set :rbenv_roles, :all # default value 40 | 41 | If your rbenv is located in some custom path, you can use `rbenv_custom_path` to set it. 42 | 43 | ### Defining the ruby version 44 | 45 | To set the Ruby version explicitly, add `:rbenv_ruby` to your Capistrano configuration: 46 | 47 | # config/deploy.rb 48 | set :rbenv_ruby, '2.4.2' 49 | 50 | Alternatively, allow the remote host's `rbenv` to [determine the appropriate Ruby version](https://github.com/rbenv/rbenv#choosing-the-ruby-version) by omitting `:rbenv_ruby`. This approach is useful if you have a `.ruby-version` file in your project. 51 | 52 | ## Contributing 53 | 54 | 1. Fork it 55 | 2. Create your feature branch (`git checkout -b my-new-feature`) 56 | 3. Commit your changes (`git commit -am 'Add some feature'`) 57 | 4. Push to the branch (`git push origin my-new-feature`) 58 | 5. Create new Pull Request 59 | -------------------------------------------------------------------------------- /Rakefile: -------------------------------------------------------------------------------- 1 | require "bundler/gem_tasks" 2 | 3 | # Do nothing by default 4 | task :default 5 | 6 | Rake::Task["release"].enhance do 7 | puts "Don't forget to publish the release on GitHub!" 8 | system "open https://github.com/capistrano/rbenv/releases" 9 | end 10 | -------------------------------------------------------------------------------- /capistrano-rbenv.gemspec: -------------------------------------------------------------------------------- 1 | # -*- encoding: utf-8 -*- 2 | lib = File.expand_path('../lib', __FILE__) 3 | $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) 4 | 5 | Gem::Specification.new do |gem| 6 | gem.name = "capistrano-rbenv" 7 | gem.version = '2.2.0' 8 | gem.authors = ["Kir Shatrov", "Yamashita Yuu"] 9 | gem.email = ["shatrov@me.com", "yamashita@geishatokyo.com"] 10 | gem.description = %q{rbenv integration for Capistrano} 11 | gem.summary = %q{rbenv integration for Capistrano} 12 | gem.homepage = "https://github.com/capistrano/rbenv" 13 | gem.metadata = { 14 | "changelog_uri" => "https://github.com/capistrano/rbenv/releases" 15 | } 16 | 17 | gem.files = `git ls-files`.split($/) 18 | gem.test_files = gem.files.grep(%r{^(test|spec|features)/}) 19 | gem.require_paths = ["lib"] 20 | 21 | gem.licenses = ["MIT"] 22 | 23 | gem.add_dependency 'capistrano', '~> 3.1' 24 | gem.add_dependency 'sshkit', '~> 1.3' 25 | 26 | gem.add_development_dependency 'danger' 27 | end 28 | -------------------------------------------------------------------------------- /lib/capistrano-rbenv.rb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/capistrano/rbenv/1fdb93a6dd4a4ab3fb786c995055cf6949daf7a4/lib/capistrano-rbenv.rb -------------------------------------------------------------------------------- /lib/capistrano/rbenv.rb: -------------------------------------------------------------------------------- 1 | load File.expand_path("../tasks/rbenv.rake", __FILE__) 2 | -------------------------------------------------------------------------------- /lib/capistrano/tasks/rbenv.rake: -------------------------------------------------------------------------------- 1 | namespace :rbenv do 2 | task :validate do 3 | on release_roles(fetch(:rbenv_roles)) do |host| 4 | rbenv_ruby = fetch(:rbenv_ruby) 5 | if rbenv_ruby.nil? 6 | info 'rbenv: rbenv_ruby is not set; ruby version will be defined by the remote hosts via rbenv' 7 | end 8 | 9 | # don't check the rbenv_ruby_dir if :rbenv_ruby is not set (it will always fail) 10 | unless rbenv_ruby.nil? || (test "[ -d #{fetch(:rbenv_ruby_dir)} ]") 11 | warn "rbenv: #{rbenv_ruby} is not installed or not found in #{fetch(:rbenv_ruby_dir)} on #{host}" 12 | exit 1 13 | end 14 | end 15 | end 16 | 17 | task :map_bins do 18 | SSHKit.config.default_env.merge!({ rbenv_root: fetch(:rbenv_path), rbenv_version: fetch(:rbenv_ruby) }) 19 | rbenv_prefix = fetch(:rbenv_prefix, proc { "#{fetch(:rbenv_path)}/bin/rbenv exec" }) 20 | SSHKit.config.command_map[:rbenv] = "#{fetch(:rbenv_path)}/bin/rbenv" 21 | 22 | fetch(:rbenv_map_bins).uniq.each do |command| 23 | SSHKit.config.command_map.prefix[command.to_sym].unshift(rbenv_prefix) 24 | end 25 | end 26 | end 27 | 28 | Capistrano::DSL.stages.each do |stage| 29 | after stage, 'rbenv:validate' 30 | after stage, 'rbenv:map_bins' 31 | end 32 | 33 | namespace :load do 34 | task :defaults do 35 | set :rbenv_path, -> { 36 | rbenv_path = fetch(:rbenv_custom_path) 37 | rbenv_path ||= case fetch(:rbenv_type, :user) 38 | when :system 39 | '/usr/local/rbenv' 40 | when :fullstaq 41 | '/usr/lib/rbenv' 42 | else 43 | '$HOME/.rbenv' 44 | end 45 | } 46 | 47 | set :rbenv_roles, fetch(:rbenv_roles, :all) 48 | 49 | set :rbenv_ruby_dir, -> { "#{fetch(:rbenv_path)}/versions/#{fetch(:rbenv_ruby)}" } 50 | set :rbenv_map_bins, %w{rake gem bundle ruby rails} 51 | end 52 | end 53 | --------------------------------------------------------------------------------