easy-deployment 0.1.2 → 0.1.3
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.
- data/lib/easy-deployment/version.rb +1 -1
- data/lib/easy/deployment/capistrano.rb +16 -20
- data/lib/easy/deployment/dbreference.rb +19 -0
- metadata +5 -4
@@ -3,6 +3,22 @@
|
|
3
3
|
|
4
4
|
Capistrano::Configuration.instance(:must_exist).load do
|
5
5
|
|
6
|
+
# color the string
|
7
|
+
def red(str)
|
8
|
+
"\e[31m#{str}\e[0m"
|
9
|
+
end
|
10
|
+
|
11
|
+
# Get the name of the current local branch
|
12
|
+
def current_git_branch
|
13
|
+
current_branch = `git symbolic-ref HEAD 2> /dev/null`.strip.gsub(/^refs\/heads\//, '')
|
14
|
+
puts red("Warning: Redundant use of 'tag'. Your current branch is deployed by default") if ENV['tag'] == current_branch
|
15
|
+
branch_to_deploy = ENV['tag'] || current_branch
|
16
|
+
puts "Deploying branch #{red branch_to_deploy}"
|
17
|
+
branch_to_deploy
|
18
|
+
end
|
19
|
+
|
20
|
+
set :branch, current_git_branch
|
21
|
+
|
6
22
|
# ssh options
|
7
23
|
set :use_sudo, false
|
8
24
|
ssh_options[:forward_agent] = true # run `ssh-add ;` to ensure your identity file is added
|
@@ -30,19 +46,6 @@ Capistrano::Configuration.instance(:must_exist).load do
|
|
30
46
|
run "cd #{directory}; RAILS_ENV=#{stage} bundle exec rake db:create"
|
31
47
|
end
|
32
48
|
|
33
|
-
desc "Load reference data"
|
34
|
-
task :reference_data, :roles => :db, :only => { :primary => true } do
|
35
|
-
migrate_target = fetch(:migrate_target, :latest)
|
36
|
-
|
37
|
-
directory = case migrate_target.to_sym
|
38
|
-
when :current then current_path
|
39
|
-
when :latest then latest_release
|
40
|
-
else raise ArgumentError, "unknown migration target #{migrate_target.inspect}"
|
41
|
-
end
|
42
|
-
|
43
|
-
run "cd #{directory} && RAILS_ENV=#{stage} bundle exec rake reference:load"
|
44
|
-
end
|
45
|
-
|
46
49
|
# By default, we deploy using passenger as an app server
|
47
50
|
task :start do ; end
|
48
51
|
task :stop do ; end
|
@@ -58,12 +61,5 @@ Capistrano::Configuration.instance(:must_exist).load do
|
|
58
61
|
puts "Skipping copying of config/deploy/#{stage}/database.yml as the file is not present"
|
59
62
|
end
|
60
63
|
end
|
61
|
-
|
62
|
-
desc "Allow deployment of a branch, commit or tag"
|
63
|
-
task :set_branch do
|
64
|
-
set :branch, ENV['tag'] || 'master'
|
65
|
-
end
|
66
64
|
end
|
67
|
-
|
68
|
-
before 'deploy:update_code', 'deploy:set_branch' # allow specification of branch, tag or commit on the command line
|
69
65
|
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
# To load this capistrano configuration, require 'easy/deployment/dbreference' from deploy.rb
|
2
|
+
Capistrano::Configuration.instance(:must_exist).load do
|
3
|
+
namespace :deploy do
|
4
|
+
desc "Load reference data"
|
5
|
+
task :reference_data, :roles => :db, :only => { :primary => true } do
|
6
|
+
migrate_target = fetch(:migrate_target, :latest)
|
7
|
+
|
8
|
+
directory = case migrate_target.to_sym
|
9
|
+
when :current then current_path
|
10
|
+
when :latest then latest_release
|
11
|
+
else raise ArgumentError, "unknown migration target #{migrate_target.inspect}"
|
12
|
+
end
|
13
|
+
|
14
|
+
run "cd #{directory} && RAILS_ENV=#{stage} bundle exec rake reference:load"
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
after 'deploy:migrate', 'deploy:reference_data'
|
19
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: easy-deployment
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.3
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -12,7 +12,7 @@ authors:
|
|
12
12
|
autorequire:
|
13
13
|
bindir: bin
|
14
14
|
cert_chain: []
|
15
|
-
date: 2012-07-
|
15
|
+
date: 2012-07-09 00:00:00.000000000 Z
|
16
16
|
dependencies:
|
17
17
|
- !ruby/object:Gem::Dependency
|
18
18
|
name: rails
|
@@ -132,6 +132,7 @@ files:
|
|
132
132
|
- lib/easy/deployment/apache.rb
|
133
133
|
- lib/easy/deployment/backup.rb
|
134
134
|
- lib/easy/deployment/capistrano.rb
|
135
|
+
- lib/easy/deployment/dbreference.rb
|
135
136
|
- lib/easy/deployment/logrotate.rb
|
136
137
|
- lib/easy/deployment/niet.rb
|
137
138
|
- lib/easy/deployment/whenever.rb
|
@@ -157,7 +158,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
157
158
|
version: '0'
|
158
159
|
segments:
|
159
160
|
- 0
|
160
|
-
hash:
|
161
|
+
hash: -1446539074970372509
|
161
162
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
162
163
|
none: false
|
163
164
|
requirements:
|
@@ -166,7 +167,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
166
167
|
version: '0'
|
167
168
|
segments:
|
168
169
|
- 0
|
169
|
-
hash:
|
170
|
+
hash: -1446539074970372509
|
170
171
|
requirements: []
|
171
172
|
rubyforge_project:
|
172
173
|
rubygems_version: 1.8.24
|