Compare commits
24 Commits
1.0.0
...
local_call
| Author | SHA1 | Date | |
|---|---|---|---|
| 62465d2973 | |||
| 396b2a9972 | |||
| dcca41a841 | |||
|
|
6ef8f3ec46 | ||
|
|
63b13affee | ||
|
|
7ee61ce716 | ||
|
|
6156bbe4e5 | ||
|
|
4a3560b753 | ||
|
|
561331b263 | ||
|
|
57efd74341 | ||
|
|
5d31bd7df6 | ||
|
|
1a8635a98b | ||
|
|
1cff76230d | ||
|
|
eeb75048ba | ||
|
|
1ac8d2f9c4 | ||
|
|
36f2405a31 | ||
|
|
e9ba5e715c | ||
|
|
11eabe5b7c | ||
|
|
7eaf0a83f8 | ||
|
|
95b1cc15b9 | ||
|
|
9f9a0c3d6a | ||
|
|
536214fd03 | ||
|
|
964c57d21f | ||
|
|
675361e5d9 |
17
README.md
17
README.md
@@ -8,10 +8,13 @@ but as Capistrano 3 is multistage by default (unlike Cap 2) :stage should
|
||||
already be set, but you can override the variable if you want to change the
|
||||
name of the tag.
|
||||
|
||||
### Requires Capistrano 3
|
||||
### Requires Capistrano 3.7
|
||||
|
||||
As of version 1.0.0, this plugin requires Cap 3. If you need a Capistrano
|
||||
2 compatible version, then use `gem 'capistrano-deploytags', '~> 0.9.2'`
|
||||
As of version 1.0.7, this plugin requires Cap 3.7.
|
||||
|
||||
If you need a Capistrano < 3.7 compatible version, then use `gem 'capistrano-deploytags', '1.0.6'`
|
||||
|
||||
If you need a Capistrano 2 compatible version, then use `gem 'capistrano-deploytags', '~> 0.9.2'`
|
||||
|
||||
### What It Does
|
||||
|
||||
@@ -39,7 +42,7 @@ to the `development` group of your Gemfile with `require: false`:
|
||||
|
||||
```ruby
|
||||
# Gemfile
|
||||
group :deployment do
|
||||
group :development do
|
||||
gem 'capistrano-deploytags', '~> 1.0.0', require: false
|
||||
end
|
||||
```
|
||||
@@ -109,6 +112,12 @@ You may override the time format in `deploy.rb` or your stage:
|
||||
set :deploytag_time_format, "%Y.%m.%d-%H%M%S-utc"
|
||||
```
|
||||
|
||||
To use your local time and not UTC (so that ```Time.now``` and not ```Time.now.utc``` is used internally):
|
||||
|
||||
```ruby
|
||||
set :deploytag_utc, false
|
||||
```
|
||||
|
||||
### Customizing the Tag Commit Message
|
||||
|
||||
By default, Capistrano Deploytags will create a tag with a message that indicates
|
||||
|
||||
@@ -1,16 +1,17 @@
|
||||
Gem::Specification.new do |s|
|
||||
s.name = 'capistrano-deploytags'
|
||||
s.version = '1.0.0'
|
||||
s.date = '2014-06-14'
|
||||
s.license = 'BSD-2-Clause'
|
||||
s.version = '1.0.7'
|
||||
s.date = '2017-02-07'
|
||||
s.summary = 'Add dated, environment-specific tags to your git repo at each deployment.'
|
||||
s.description = <<-EOS
|
||||
s.description = <<-EOS
|
||||
Capistrano Deploytags is a simple plugin to Capistrano 3 that works with your deployment framework to track your code releases. All you have to do is require capistrano-deploytags/capistrano and each deployment will add a new tag for that deployment, pointing to the latest commit. This lets you easily see which code is deployed on each environment, and allows you to figure out which code was running in an environment at any time in the past.
|
||||
EOS
|
||||
s.authors = ['Karl Matthias', 'Gavin Heavyside']
|
||||
s.email = ['relistan@gmail.com', 'gavin.heavyside@mydrivesolutions.com']
|
||||
s.files = `git ls-files lib`.split(/\n/) + %w{ README.md LICENSE }
|
||||
s.homepage = 'http://github.com/mydrive/capistrano-deploytags'
|
||||
s.add_dependency 'capistrano', '>= 3.2.0'
|
||||
s.add_dependency 'capistrano', '>= 3.7.0'
|
||||
# s.add_development_dependency 'capistrano-spec'
|
||||
s.add_development_dependency 'rake'
|
||||
s.add_development_dependency 'rspec', '~> 3.0.0'
|
||||
|
||||
@@ -1,6 +1,21 @@
|
||||
# Ensure deploy tasks are loaded before we run
|
||||
require 'capistrano/deploy'
|
||||
|
||||
module SSHKit
|
||||
class CommandMap
|
||||
def defaults
|
||||
Hash.new do |hash, command|
|
||||
if %w{if test time exec git}.include? command.to_s || !File.executable?('/usr/bin/env')
|
||||
hash[command] = command.to_s
|
||||
else
|
||||
hash[command] = "/usr/bin/env #{command}"
|
||||
#hash[command] = "#{command}"
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# Load extra tasks into the deploy namespace
|
||||
load File.expand_path("../tasks/deploytags.rake", __FILE__)
|
||||
|
||||
@@ -11,12 +26,18 @@ module CapistranoDeploytags
|
||||
end
|
||||
|
||||
def self.formatted_time
|
||||
Time.new.utc.strftime(fetch(:deploytag_time_format, "%Y.%m.%d-%H%M%S-utc"))
|
||||
now = if fetch(:deploytag_utc, true)
|
||||
Time.now.utc
|
||||
else
|
||||
Time.now
|
||||
end
|
||||
|
||||
now.strftime(fetch(:deploytag_time_format, "%Y.%m.%d-%H%M%S-#{now.zone.downcase}"))
|
||||
end
|
||||
|
||||
def self.commit_message(current_sha, stage)
|
||||
if fetch(:deploytag_commit_message, false)
|
||||
deploytag_commit_message
|
||||
fetch(:deploytag_commit_message)
|
||||
else
|
||||
tag_user = (ENV['USER'] || ENV['USERNAME'] || 'deployer').strip
|
||||
"#{tag_user} deployed #{current_sha} to #{stage}"
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
namespace :deploy do
|
||||
desc 'prepare git tree so we can tag on successful deployment'
|
||||
before :deploy, :prepare_tree do
|
||||
SSHKit.config.default_env = {}
|
||||
run_locally do
|
||||
if ENV['NO_DEPLOYTAGS'] || fetch(:no_deploytags, false)
|
||||
info "[deploytags] Skipping deploytags"
|
||||
@@ -13,7 +14,7 @@ namespace :deploy do
|
||||
raise 'define :branch and :stage'
|
||||
end
|
||||
|
||||
strategy.git "fetch #{fetch(:git_remote, 'origin')}"
|
||||
execute :git, "fetch #{fetch(:git_remote, 'origin')}"
|
||||
|
||||
diff_output = capture :git, "diff #{branch} --shortstat"
|
||||
|
||||
@@ -22,9 +23,9 @@ namespace :deploy do
|
||||
raise 'Dirty git tree'
|
||||
end
|
||||
|
||||
strategy.git "checkout #{branch}"
|
||||
execute :git, "checkout #{branch}"
|
||||
info "Pulling from #{branch}"
|
||||
strategy.git "pull #{fetch(:git_remote, 'origin')} #{branch}"
|
||||
execute :git, "pull #{fetch(:git_remote, 'origin')} #{branch}"
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -35,12 +36,14 @@ namespace :deploy do
|
||||
if ENV['NO_DEPLOYTAGS'] || fetch(:no_deploytags, false)
|
||||
info "[deploytags] Skipping deploytags"
|
||||
else
|
||||
tag_name = CapistranoDeploytags::Helper.git_tag_for(fetch(:stage))
|
||||
tag_name = ENV['CUSTOM_DEPLOYTAG'] || fetch(:custom_deploytag) || CapistranoDeploytags::Helper.git_tag_for(fetch(:stage))
|
||||
latest_revision = fetch(:current_revision)
|
||||
commit_message = CapistranoDeploytags::Helper.commit_message(latest_revision, fetch(:stage))
|
||||
|
||||
strategy.git "tag -a #{tag_name} -m \"#{commit_message}\" #{latest_revision}"
|
||||
strategy.git "push #{fetch(:git_remote, 'origin')} #{tag_name}"
|
||||
unless fetch(:sshkit_backend) == SSHKit::Backend::Printer # unless --dry-run flag present
|
||||
execute :git, "tag -a #{tag_name} -m \"#{commit_message}\" #{latest_revision}"
|
||||
execute :git, "push #{fetch(:git_remote, 'origin')} #{tag_name}"
|
||||
end
|
||||
|
||||
info "[cap-deploy-tagger] Tagged #{latest_revision} with #{tag_name}"
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user