This gem provides a convenient interface for creating releases and deploying using Git and Capistrano.
main
/master
should only contain deployable code.- Each deployment environment has its own branch.
- Remote repository is assumed to be named 'origin'
Add this line to your application's Gemfile:
gem 'epi_deploy', github: 'epigenesys/epi_deploy'
And then execute:
$ bundle install
No initial setup is required as prerequisites are checked automatically before each command is run.
This command will bump the version in config/initializers/version.rb, create a Git tag in the format YYYYmonDD-HHMM-<short_commit_hash>-v<version> and push it to the remote repository. This can only be done on the main or master branch.
$ ed release
Optional flag to deploy to the given environment(s) after creating the release. Shorthand -d.
$ ed release --deploy demo:production
Deploy the latest release to the given environment(s).
$ ed deploy demo production
Optional flag to specify which tag, commit, or branch to deploy to the given environment(s). Shorthand -r. If the flag is provided without a reference you will be prompted to choose from the latest releases.
$ ed deploy demo production --ref <reference>
If you want to deploy to multiple customers, you can set it up as following:
- In
config/deploy
, create one config file for the environment you want to deploy to. (e.g.production.rb
)
-
In this file, include the setting for stage:
set :stage, :production
Also include any common settings across customers:
set :branch, 'production'
- In
config/deploy
, create one config file with the name in following format:{stage}.{customer}.rb
(e.g.production.epigenesys.rb
)
-
Include the following content (remember to replace the name of the stage and customer):
load File.expand_path('../production.rb', __FILE__)
-
Also include any other customer specific settings:
set :current_customer, 'epigenesys' server fetch(:server), user: fetch(:user), roles: %w{web app db}
- Include this line in
Capfile
:
require 'capistrano/epi_deploy'
Running ed release -d production
will now deploy the latest release of the code to all customers.
You can also deploy to a specific customer by doing e.g. ed release -d production.epigenesys
.
You can also deploy to all customers for a given environment by running e.g. cap production deploy_all
.
Using branches for stages, i.e. demo and production branches, can clutter up your branches screen. This can be particularly awkward when running CI and keeping track of multiple active branches. To resolve this you can optionally configure epi_deploy to use tags for this instead of branches.
- Update to epi_deploy 2.2.0 or greater.
- Add config/epi_deploy.rb to your application.
- Add
EpiDeploy.use_tags_for_deploy = true
to the newly created config file. - Delete your stage branches on gitlab (likely
production
,demo
,qa
). - Push your changes and deploy to a demo site to test it is working correctly.
Note: In the future we intend to change this configuration option to default to true.