openteam-capistrano 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore ADDED
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in openteam-capistrano.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2013 Dmitry Lihachev
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,29 @@
1
+ # Openteam::Capistrano
2
+
3
+ TODO: Write a gem description
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'openteam-capistrano'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install openteam-capistrano
18
+
19
+ ## Usage
20
+
21
+ TODO: Write usage instructions here
22
+
23
+ ## Contributing
24
+
25
+ 1. Fork it
26
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
27
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
28
+ 4. Push to the branch (`git push origin my-new-feature`)
29
+ 5. Create new Pull Request
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,4 @@
1
+ require "openteam/capistrano/dependencies"
2
+ require "openteam/capistrano/setup"
3
+ require "openteam/capistrano/hooks"
4
+ require "openteam/capistrano/tagging"
@@ -0,0 +1,9 @@
1
+ require 'capistrano/ext/multistage'
2
+
3
+ require 'bundler/capistrano'
4
+ require 'rvm/capistrano'
5
+
6
+ require 'capistrano-db-tasks'
7
+ require 'capistrano-unicorn'
8
+ begin; require 'airbrake/capistrano'; rescue LoadError; end
9
+
@@ -0,0 +1,15 @@
1
+ # set up hooks
2
+ Capistrano::Configuration.instance.load do
3
+ after('multistage:ensure') do
4
+ server domain, :app, :web, :db, :primary => true
5
+ end
6
+
7
+ after 'deploy:update_code', 'deploy:migrate'
8
+
9
+ after 'deploy:restart', 'unicorn:restart'
10
+
11
+ after 'deploy', 'deploy:cleanup'
12
+ before 'deploy:cleanup', 'tagging:cleanup'
13
+
14
+ after 'deploy', 'tagging:deploy'
15
+ end
@@ -0,0 +1,38 @@
1
+ Capistrano::Configuration.instance.load do
2
+ def deploy_config
3
+ @deploy_config ||= YAML::load(File.open('config/deploy.yml'))[stage.to_s]
4
+ end
5
+
6
+ set(:application) { deploy_config['application'] }
7
+ set(:domain) { deploy_config['domain'] }
8
+ set(:gateway) { deploy_config['gateway'] }
9
+
10
+ set(:deploy_to) { "/srv/#{application}" }
11
+
12
+ # source repostitory settings
13
+ set :scm, :git
14
+ set(:repository) { `git config --get remote.origin.url`.strip }
15
+ set :branch, :master
16
+ set :deploy_via, :remote_cache
17
+ set :ssh_options, { :forward_agent => true }
18
+
19
+ # this files will be symlinked from shared to current path on deploy
20
+ set :shared_children, %w[config/settings.yml config/database.yml log tmp/sockets tmp/pids]
21
+
22
+ # for assets compilation on host with nodejs
23
+ set :default_shell, 'bash -l'
24
+
25
+ # make bin stubs for candy console rails runs
26
+ set :bundle_flags, '--binstubs --deployment --quiet'
27
+
28
+ # gem capistrano-db-tasks
29
+ # we do not need dump file after db:pull
30
+ set :db_local_clean, true
31
+
32
+ # gem whenever
33
+ # point to bundled version of whenever command
34
+ set :whenever_command, 'bundle exec whenever'
35
+
36
+ # tagging needs this
37
+ set :local_user, ENV['USER'] || ENV['USERNAME']
38
+ end
@@ -0,0 +1,38 @@
1
+ Capistrano::Configuration.instance.load do
2
+ namespace :tagging do
3
+ def tag_name(options={})
4
+ formatted_local_time = DateTime.strptime(options[:for], '%Y%m%d%H%M%S').to_time.strftime("%Y.%m.%d-%H%M")
5
+ "#{fetch(:stage)}-#{formatted_local_time}"
6
+ end
7
+
8
+ def create_tag(tag_name)
9
+ run_locally "git tag -a #{tag_name} -m 'Deployed by #{fetch(:local_user)}' origin/#{fetch(:branch)}"
10
+ run_locally "git push origin --tags"
11
+ end
12
+
13
+ def remove_tag(tag_name)
14
+ run_locally "git tag -d #{tag_name} || true"
15
+ run_locally "git push origin :refs/tags/#{tag_name}"
16
+ end
17
+
18
+ desc "Create release tag in local and origin repo"
19
+ task :deploy do
20
+ logger.info "tag current release"
21
+ create_tag tag_name(:for => release_name)
22
+ end
23
+
24
+ desc "Remove release tag from local and origin repo"
25
+ task :cleanup do
26
+ count = fetch(:keep_releases, 5)
27
+
28
+ if count >= releases.size
29
+ logger.important "no old release tags to clean up"
30
+ else
31
+ logger.info "keeping #{count} of #{releases.size} release tags"
32
+ releases.first(releases.size - count).map do |release|
33
+ remove_tag tag_name(:for => release)
34
+ end
35
+ end
36
+ end
37
+ end
38
+ end
@@ -0,0 +1,25 @@
1
+ # -*- encoding: utf-8 -*-
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+
5
+ Gem::Specification.new do |gem|
6
+ gem.name = 'openteam-capistrano'
7
+ gem.version = '0.0.1'
8
+ gem.authors = ["OpenTeam developers"]
9
+ gem.email = ["developers@openteam.ru"]
10
+ gem.description = %q{OpenTeam common capistrano recipe}
11
+ gem.summary = %q{Adds common use case tasks (import db, reload unicorn, send airbrake notice, tag deploy)}
12
+ gem.homepage = ""
13
+
14
+ gem.files = `git ls-files`.split($/)
15
+ gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
16
+ gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
17
+ gem.require_paths = ["lib"]
18
+
19
+ gem.add_dependency 'capistrano-db-tasks'
20
+ gem.add_dependency 'capistrano-ext'
21
+ gem.add_dependency 'capistrano-unicorn'
22
+ gem.add_dependency 'rvm-capistrano'
23
+
24
+ gem.add_development_dependency 'rake'
25
+ end
metadata ADDED
@@ -0,0 +1,143 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: openteam-capistrano
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - OpenTeam developers
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2013-03-22 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: capistrano-db-tasks
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: '0'
30
+ - !ruby/object:Gem::Dependency
31
+ name: capistrano-ext
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ! '>='
36
+ - !ruby/object:Gem::Version
37
+ version: '0'
38
+ type: :runtime
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: '0'
46
+ - !ruby/object:Gem::Dependency
47
+ name: capistrano-unicorn
48
+ requirement: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ! '>='
52
+ - !ruby/object:Gem::Version
53
+ version: '0'
54
+ type: :runtime
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ! '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ - !ruby/object:Gem::Dependency
63
+ name: rvm-capistrano
64
+ requirement: !ruby/object:Gem::Requirement
65
+ none: false
66
+ requirements:
67
+ - - ! '>='
68
+ - !ruby/object:Gem::Version
69
+ version: '0'
70
+ type: :runtime
71
+ prerelease: false
72
+ version_requirements: !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ! '>='
76
+ - !ruby/object:Gem::Version
77
+ version: '0'
78
+ - !ruby/object:Gem::Dependency
79
+ name: rake
80
+ requirement: !ruby/object:Gem::Requirement
81
+ none: false
82
+ requirements:
83
+ - - ! '>='
84
+ - !ruby/object:Gem::Version
85
+ version: '0'
86
+ type: :development
87
+ prerelease: false
88
+ version_requirements: !ruby/object:Gem::Requirement
89
+ none: false
90
+ requirements:
91
+ - - ! '>='
92
+ - !ruby/object:Gem::Version
93
+ version: '0'
94
+ description: OpenTeam common capistrano recipe
95
+ email:
96
+ - developers@openteam.ru
97
+ executables: []
98
+ extensions: []
99
+ extra_rdoc_files: []
100
+ files:
101
+ - .gitignore
102
+ - Gemfile
103
+ - LICENSE.txt
104
+ - README.md
105
+ - Rakefile
106
+ - lib/openteam/capistrano.rb
107
+ - lib/openteam/capistrano/dependencies.rb
108
+ - lib/openteam/capistrano/hooks.rb
109
+ - lib/openteam/capistrano/setup.rb
110
+ - lib/openteam/capistrano/tagging.rb
111
+ - openteam-capistrano.gemspec
112
+ homepage: ''
113
+ licenses: []
114
+ post_install_message:
115
+ rdoc_options: []
116
+ require_paths:
117
+ - lib
118
+ required_ruby_version: !ruby/object:Gem::Requirement
119
+ none: false
120
+ requirements:
121
+ - - ! '>='
122
+ - !ruby/object:Gem::Version
123
+ version: '0'
124
+ segments:
125
+ - 0
126
+ hash: 3262326284942122593
127
+ required_rubygems_version: !ruby/object:Gem::Requirement
128
+ none: false
129
+ requirements:
130
+ - - ! '>='
131
+ - !ruby/object:Gem::Version
132
+ version: '0'
133
+ segments:
134
+ - 0
135
+ hash: 3262326284942122593
136
+ requirements: []
137
+ rubyforge_project:
138
+ rubygems_version: 1.8.24
139
+ signing_key:
140
+ specification_version: 3
141
+ summary: Adds common use case tasks (import db, reload unicorn, send airbrake notice,
142
+ tag deploy)
143
+ test_files: []