Capistrano Distribution: More Than Just Git Deployments

Flexible distribution for Capistrano 3.x.

DESCRIPTION

This gem hooks into the SCM functionality of Capistrano 3.x in order to provide a more generic distribution strategy. Not only is it possible to deploy from a simple Git repository, but deployment of contents from Tar and ZIP files is also possible. It is even easy to create deployments based on multiple sources.

With the exception of the Git push method, all distribution operations pull content from providers on each target host. For Git-based distributions whether using the push or pull method, this is very efficient after the first deployment because a mirror git repository is saved on each host such that only differentials are needed for future deployments. All other types perform a full download of the source artifact, so these could be expensive and/or slow.

Features

  • Distribute from Git repositories and Tar/Zip archives.
  • Use remote and local sources, anything supported by Git and Curl.
  • Create homogenous deployments from multiple sources.

Known Bugs/Limitations

  • None so far...

SYNOPSIS

Add this to your Capfile in all cases:

# Capfile
...
require 'capistrano/distribution'
...

Simple Git-based distribution (master branch of the current repository):

# config/deploy.rb
...
set :scm, :distribution
set :release_id, ->{ `git rev-parse HEAD`.chomp }
set :distribution, ->{
  [[
    'http://example.com/repositories/example.git',
    fetch(:release_id)
  ]]
}
...

Simple Tar-based distribution (everything in the example.tar.gz archive is within an example subdirectory):

# config/deploy.rb
...
set :scm, :distribution
set :release_id, ->{ "example-#{fetch(:release_timestamp)}" }
set :distribution, 'http://example.com/tarballs/example.tar.gz'
...

Heterogenous distribution (a Redmine deployment with plugins):

# config/deploy.rb
...
set :scm, :distribution
set :release_id, ->{ "2.3.4-#{fetch(:release_timestamp)}" }
set :distribution,
  [
    'http://www.redmine.org/releases/redmine-2.3.4.tar.gz'
  ],
  [
    'https://bitbucket.org/akiko_pusu/redmine_issue_templates/get/0.0.4.tar.gz',
    {
      subtree: 'akiko_pusu-redmine_issue_templates-b885dfe8263d',
      target: 'plugins/redmine_issue_templates'
    }
  ],
  [
    'https://bitbucket.org/haru_iida/redmine_code_review/get/0.6.2.tar.gz',
    {
      subtree: 'haru_iida-redmine_code_review-e79f98b8a77f',
      target: 'plugins/redmine_code_review'
    }
  ],
  [
    'https://github.com/Undev/notify_custom_users/archive/0.0.5.tar.gz',
    {
      subtree: 'notify_custom_users-0.0.5',
      target: 'plugins/notify_custom_users'
    }
  ],
  [
    'https://github.com/thorin/redmine_ldap_sync/archive/2.0.3.tar.gz',
    {
      subtree: 'redmine_ldap_sync-2.0.3',
      target: 'plugins/redmine_ldap_sync'
    }
  ]
...

REQUIREMENTS

  • Git binary (for Git repositories)
  • Curl binary (for remote archives)
  • Unzip binary (for ZIP archives)
  • Tar binary (for Tar archives)

DEVELOPERS

After checking out the source, run:

$ bundle install
$ bundle exec rake test yard

This will install all dependencies, run the tests/specs, and generate the documentation.

AUTHORS

Thanks to all contributors. Without your help this project would not exist.

Contributing

Contributions for bug fixes, documentation, extensions, tests, etc. are encouraged.

  1. Clone the repository.
  2. Fix a bug or add a feature.
  3. Add tests for the fix or feature.
  4. Make a pull request.

LICENSE

(The MIT License)

Copyright (c) 2016 Spiceworks, Inc.

Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
'Software'), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:

The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.