capistrano-deploytags 0.9.0 → 0.9.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- metadata +2 -3
- data/lib/capistrano/deploy_tags.rb.orig +0 -89
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: capistrano-deploytags
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.9.
|
4
|
+
version: 0.9.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2014-01-
|
12
|
+
date: 2014-01-14 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: capistrano
|
@@ -57,7 +57,6 @@ extensions: []
|
|
57
57
|
extra_rdoc_files: []
|
58
58
|
files:
|
59
59
|
- lib/capistrano/deploy_tags.rb
|
60
|
-
- lib/capistrano/deploy_tags.rb.orig
|
61
60
|
- lib/capistrano-deploytags.rb
|
62
61
|
- README.md
|
63
62
|
- LICENSE
|
@@ -1,89 +0,0 @@
|
|
1
|
-
module Capistrano
|
2
|
-
module DeployTags
|
3
|
-
def pending_git_changes?
|
4
|
-
# Do we have any changes vs HEAD on deployment branch?
|
5
|
-
!(`git fetch && git diff #{branch} --shortstat`.strip.empty?)
|
6
|
-
end
|
7
|
-
|
8
|
-
def git_tag_for(stage)
|
9
|
-
<<<<<<< HEAD
|
10
|
-
"#{stage}-#{Time.new.utc.strftime('%Y.%m.%d-%H%M%S')}"
|
11
|
-
=======
|
12
|
-
"#{stage}-#{Time.new.utc.strftime('%Y.%m.%d-%H%M%S-utc')}"
|
13
|
-
>>>>>>> Added utc to the tag to make the change obvious.
|
14
|
-
end
|
15
|
-
|
16
|
-
def safe_run(*args)
|
17
|
-
raise "#{args.join(" ")} failed!" unless system(*args)
|
18
|
-
end
|
19
|
-
|
20
|
-
def validate_git_vars
|
21
|
-
unless exists?(:branch) && exists?(:stage)
|
22
|
-
logger.log Capistrano::Logger::IMPORTANT, 'Capistrano Deploytags requires that :branch and :stage be defined.'
|
23
|
-
raise 'define :branch and :stage'
|
24
|
-
end
|
25
|
-
end
|
26
|
-
|
27
|
-
def git_tag?(tag)
|
28
|
-
!`git tag -l #{tag}`.strip.empty?
|
29
|
-
end
|
30
|
-
|
31
|
-
def has_remote?
|
32
|
-
!`git remote`.strip.empty?
|
33
|
-
end
|
34
|
-
|
35
|
-
def remote
|
36
|
-
exists?(:git_remote) ? git_remote : `git remote`.strip.split(/\n/).first
|
37
|
-
end
|
38
|
-
|
39
|
-
def self.load_into(configuration)
|
40
|
-
configuration.load do
|
41
|
-
before 'deploy', 'git:prepare_tree'
|
42
|
-
before 'deploy:migrations', 'git:prepare_tree'
|
43
|
-
after 'deploy', 'git:tagdeploy'
|
44
|
-
after 'deploy:migrations', 'git:tagdeploy'
|
45
|
-
|
46
|
-
desc 'prepare git tree so we can tag on successful deployment'
|
47
|
-
namespace :git do
|
48
|
-
task :prepare_tree, :except => { :no_release => true } do
|
49
|
-
next if fetch(:no_deploytags, false)
|
50
|
-
|
51
|
-
cdt.validate_git_vars
|
52
|
-
|
53
|
-
logger.log Capistrano::Logger::IMPORTANT, "Preparing to deploy HEAD from branch '#{branch}' to '#{stage}'"
|
54
|
-
|
55
|
-
if cdt.pending_git_changes?
|
56
|
-
logger.log Capistrano::Logger::IMPORTANT, "Whoa there, partner. Dirty trees can't deploy. Git yerself clean first."
|
57
|
-
raise 'Dirty git tree'
|
58
|
-
end
|
59
|
-
|
60
|
-
cdt.safe_run 'git', 'checkout', branch
|
61
|
-
logger.log Capistrano::Logger::IMPORTANT, "Pulling from #{branch}"
|
62
|
-
cdt.safe_run 'git', 'pull', cdt.remote, branch if cdt.has_remote?
|
63
|
-
end
|
64
|
-
|
65
|
-
desc 'add git tags for each successful deployment'
|
66
|
-
task :tagdeploy, :except => { :no_release => true } do
|
67
|
-
next if fetch(:no_deploytags, false)
|
68
|
-
|
69
|
-
cdt.validate_git_vars
|
70
|
-
|
71
|
-
current_sha = `git rev-parse #{branch} HEAD`.strip[0..8]
|
72
|
-
logger.log Capistrano::Logger::INFO, "Tagging #{current_sha} for deployment"
|
73
|
-
|
74
|
-
tag_user = (ENV['USER'] || ENV['USERNAME']).strip
|
75
|
-
cdt.safe_run 'git', 'tag', '-a', cdt.git_tag_for(stage), '-m', "#{tag_user} deployed #{current_sha} to #{stage}"
|
76
|
-
cdt.safe_run 'git', 'push', '--tags' if cdt.has_remote?
|
77
|
-
end
|
78
|
-
end
|
79
|
-
|
80
|
-
end
|
81
|
-
end
|
82
|
-
end
|
83
|
-
end
|
84
|
-
|
85
|
-
Capistrano.plugin :cdt, Capistrano::DeployTags
|
86
|
-
|
87
|
-
if Capistrano::Configuration.instance
|
88
|
-
Capistrano::DeployTags.load_into(Capistrano::Configuration.instance(:must_exist))
|
89
|
-
end
|