ongr_deploy 0.0.6

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.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: fbff794e477e1b05c77b0dfac5019769ac601ccb
4
+ data.tar.gz: 5e269e178c88637b8c1ae6a7d35158662ed49ed3
5
+ SHA512:
6
+ metadata.gz: 4012e6595d89e8ac2b88c7d8597787da25e55650c5602848e6a7c7975e184b7ad3f64ca6e94ee3f3b5a77be2445c690fa1acc4119063f20a81fcebbf130a3b72
7
+ data.tar.gz: 0e11addd5a6804c37913354f92562cc55aa85cb17430e5c42435863d26d88a06ed8b5cb08589dde89fea5c4c11e4c4b2d773f1a9188072ef161154693ed1e834
data/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2014-2015 NFQ Technologies UAB
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.rdoc ADDED
@@ -0,0 +1,3 @@
1
+ = OngrDeploy
2
+
3
+ This project rocks and uses MIT-LICENSE.
data/Rakefile ADDED
@@ -0,0 +1,32 @@
1
+ begin
2
+ require 'bundler/setup'
3
+ rescue LoadError
4
+ puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
5
+ end
6
+
7
+ require 'rdoc/task'
8
+
9
+ RDoc::Task.new(:rdoc) do |rdoc|
10
+ rdoc.rdoc_dir = 'rdoc'
11
+ rdoc.title = 'OngrDeploy'
12
+ rdoc.options << '--line-numbers'
13
+ rdoc.rdoc_files.include('README.rdoc')
14
+ rdoc.rdoc_files.include('lib/**/*.rb')
15
+ end
16
+
17
+
18
+
19
+
20
+ Bundler::GemHelper.install_tasks
21
+
22
+ require 'rake/testtask'
23
+
24
+ Rake::TestTask.new(:test) do |t|
25
+ t.libs << 'lib'
26
+ t.libs << 'test'
27
+ t.pattern = 'test/**/*_test.rb'
28
+ t.verbose = false
29
+ end
30
+
31
+
32
+ task default: :test
data/bin/ongr ADDED
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "ongr_deploy/application"
4
+
5
+ OngrDeploy::Application.new.run
@@ -0,0 +1,21 @@
1
+ require "rake"
2
+
3
+ module OngrDeploy
4
+
5
+ class Application < Rake::Application
6
+
7
+ def initialize
8
+ super
9
+
10
+ @rakefiles = [File.expand_path( "../../tasks/ongr_deploy.rake", __FILE__ )]
11
+ end
12
+
13
+ def run
14
+ Rake.application = self
15
+
16
+ super
17
+ end
18
+
19
+ end
20
+
21
+ end
@@ -0,0 +1,27 @@
1
+ require "capistrano/scm"
2
+
3
+ load File.expand_path( "../../../tasks/scm/archive.rake", __FILE__ )
4
+
5
+ module OngrDeploy
6
+
7
+ module Capistrano
8
+
9
+ class Archive < ::Capistrano::SCM
10
+
11
+ module DefaultStrategy
12
+
13
+ def release
14
+ context.execute :tar, "-xzf", "#{repo_path}/current", "-C", release_path
15
+ end
16
+
17
+ def fetch_revision
18
+ "" # context.capture :git, "rev-parse --short origin/#{fetch :branch}"
19
+ end
20
+
21
+ end
22
+
23
+ end
24
+
25
+ end
26
+
27
+ end
@@ -0,0 +1,27 @@
1
+ require "capistrano/scm"
2
+
3
+ load File.expand_path( "../../../tasks/scm/rsync.rake", __FILE__ )
4
+
5
+ module OngrDeploy
6
+
7
+ module Capistrano
8
+
9
+ class Rsync < ::Capistrano::SCM
10
+
11
+ module DefaultStrategy
12
+
13
+ def release
14
+ context.execute :cp, "-R", "#{repo_path}/.", release_path
15
+ end
16
+
17
+ def fetch_revision
18
+ "" # context.capture :git, "rev-parse --short origin/#{fetch :branch}"
19
+ end
20
+
21
+ end
22
+
23
+ end
24
+
25
+ end
26
+
27
+ end
@@ -0,0 +1,5 @@
1
+ module OngrDeploy
2
+
3
+ VERSION = "0.0.6"
4
+
5
+ end
@@ -0,0 +1,35 @@
1
+ module OngrDeploy
2
+
3
+ def ongr_setup
4
+ set :stage_config_path, "app/deploy"
5
+ set :deploy_config_path, "app/deploy.rb"
6
+
7
+ require "capistrano/setup"
8
+
9
+ stages.each do |stage|
10
+ Rake::Task[stage].clear_actions
11
+
12
+ Rake::Task.define_task( stage ) do
13
+ invoke "load:defaults"
14
+
15
+ load deploy_config_path
16
+ load stage_config_path.join "#{stage}.rb"
17
+
18
+ begin
19
+ load File.expand_path( "../ongr_deploy/scm/#{fetch( :scm )}.rb", __FILE__ )
20
+ rescue LoadError
21
+ load "capistrano/#{fetch( :scm )}.rb"
22
+ end
23
+
24
+ I18n.locale = fetch :locale, :en
25
+
26
+ configure_backend
27
+ end
28
+ end
29
+ end
30
+
31
+ end
32
+
33
+ self.extend OngrDeploy
34
+
35
+ ongr_setup
@@ -0,0 +1,8 @@
1
+ # Load DSL and Setup Up Stages
2
+ require 'ongr_deploy'
3
+
4
+ # Includes default deployment tasks
5
+ require 'capistrano/deploy'
6
+
7
+ # Load custom tasks from `app/tasks' if you have any defined
8
+ Dir.glob( 'app/tasks/*.rake' ).each { |r| import r }
@@ -0,0 +1,48 @@
1
+ # config valid only for current version of Capistrano
2
+ # lock '3.3.x'
3
+
4
+ set :application, 'my_app_name'
5
+ set :repo_url, 'git@example.com:me/my_repo.git'
6
+
7
+ # Default branch is :master
8
+ # ask :branch, proc { `git rev-parse --abbrev-ref HEAD`.chomp }.call
9
+
10
+ # Default deploy_to directory is /var/www/my_app_name
11
+ # set :deploy_to, '/var/www/my_app_name'
12
+
13
+ # Default value for :scm is :git
14
+ set :scm, :archive
15
+
16
+ # Default value for :format is :pretty
17
+ # set :format, :pretty
18
+
19
+ # Default value for :log_level is :debug
20
+ # set :log_level, :debug
21
+
22
+ # Default value for :pty is false
23
+ # set :pty, true
24
+
25
+ # Default value for :linked_files is []
26
+ set :linked_files, fetch(:linked_files, []).push('app/config/parameters.yml')
27
+
28
+ # Default value for linked_dirs is []
29
+ set :linked_dirs, fetch(:linked_dirs, []).push('app/logs')
30
+
31
+ # Default value for default_env is {}
32
+ # set :default_env, { path: "/opt/ruby/bin:$PATH" }
33
+
34
+ # Default value for keep_releases is 5
35
+ # set :keep_releases, 5
36
+
37
+ namespace :deploy do
38
+
39
+ after :restart, :clear_cache do
40
+ on roles(:web), in: :groups, limit: 3, wait: 10 do
41
+ # Here we can do anything such as:
42
+ # within release_path do
43
+ # execute :rake, 'cache:clear'
44
+ # end
45
+ end
46
+ end
47
+
48
+ end
@@ -0,0 +1,45 @@
1
+ # Simple Role Syntax
2
+ # ==================
3
+ # Supports bulk-adding hosts to roles, the primary server in each group
4
+ # is considered to be the first unless any hosts have the primary
5
+ # property set. Don't declare `role :all`, it's a meta role.
6
+
7
+ role :app, %w{deploy@example.com}
8
+ role :web, %w{deploy@example.com}
9
+ role :db, %w{deploy@example.com}
10
+
11
+
12
+ # Extended Server Syntax
13
+ # ======================
14
+ # This can be used to drop a more detailed server definition into the
15
+ # server list. The second argument is a, or duck-types, Hash and is
16
+ # used to set extended properties on the server.
17
+
18
+ server 'example.com', user: 'deploy', roles: %w{web app}, my_property: :my_value
19
+
20
+
21
+ # Custom SSH Options
22
+ # ==================
23
+ # You may pass any option but keep in mind that net/ssh understands a
24
+ # limited set of options, consult[net/ssh documentation](http://net-ssh.github.io/net-ssh/classes/Net/SSH.html#method-c-start).
25
+ #
26
+ # Global options
27
+ # --------------
28
+ # set :ssh_options, {
29
+ # keys: %w(/home/rlisowski/.ssh/id_rsa),
30
+ # forward_agent: false,
31
+ # auth_methods: %w(password)
32
+ # }
33
+ #
34
+ # And/or per server (overrides global)
35
+ # ------------------------------------
36
+ # server 'example.com',
37
+ # user: 'user_name',
38
+ # roles: %w{web app},
39
+ # ssh_options: {
40
+ # user: 'user_name', # overrides user setting above
41
+ # keys: %w(/home/user_name/.ssh/id_rsa),
42
+ # forward_agent: false,
43
+ # auth_methods: %w(publickey password)
44
+ # # password: 'please use keys'
45
+ # }
@@ -0,0 +1,23 @@
1
+ require "pathname"
2
+
3
+ task :default do
4
+ puts "Use ongr install to setup capistrano"
5
+ end
6
+
7
+ task :install do
8
+ config_dir = Pathname.new "app"
9
+
10
+ deploy_dir = config_dir.join "deploy"
11
+ tasks_dir = config_dir.join "tasks"
12
+
13
+ deploy_rb = File.expand_path "../../sample/deploy.rb", __FILE__
14
+ stage_rb = File.expand_path "../../sample/stage.rb", __FILE__
15
+ capfile = File.expand_path "../../sample/Capfile", __FILE__
16
+
17
+ mkdir_p deploy_dir
18
+ mkdir_p tasks_dir
19
+
20
+ FileUtils.cp deploy_rb, config_dir
21
+ FileUtils.cp stage_rb, deploy_dir
22
+ FileUtils.cp capfile, "Capfile"
23
+ end
@@ -0,0 +1,100 @@
1
+ namespace :archive do
2
+
3
+ def strategy
4
+ @strategy ||= OngrDeploy::Capistrano::Archive.new(
5
+ self, fetch( :strategy, OngrDeploy::Capistrano::Archive::DefaultStrategy )
6
+ )
7
+ end
8
+
9
+ task :check do
10
+ set :cache_path, "#{fetch :tmp_dir}/#{fetch :application}/#{fetch :branch }"
11
+
12
+ run_locally do
13
+ set :origin_revision, capture( :git, "rev-parse --short origin/#{fetch :branch }" ).chomp
14
+
15
+ execute :mkdir, "-p", fetch( :cache_path )
16
+ end
17
+
18
+ on release_roles :all do
19
+ execute :mkdir, "-p", repo_path
20
+ end
21
+ end
22
+
23
+ task :pack_release do
24
+ exclude = []
25
+
26
+ fetch( :exclude, [] ).each do |e|
27
+ exclude << "--exclude=#{e}"
28
+ end
29
+
30
+ set :archive_path, "#{fetch :cache_path}/#{fetch :application}_#{fetch :origin_revision}.tar.gz"
31
+
32
+ run_locally do
33
+ execute :tar, "-c", "-z", "-f", fetch( :archive_path ), exclude.join( " " ), "."
34
+ execute :ln, "-f", "-s", fetch( :archive_path ), "#{fetch :cache_path}/current"
35
+ end
36
+
37
+ invoke :"archive:cleanup"
38
+ end
39
+
40
+ task :create_release do
41
+ if fetch( :archive_cache, false )
42
+ run_locally do
43
+ unless test "[ -L #{fetch :cache_path}/current ]"
44
+ error "Deploy only allowed for already packed releases"
45
+ exit 1
46
+ end
47
+ end
48
+ else
49
+ invoke :"archive:pack_release"
50
+ end
51
+
52
+ run_locally do
53
+ unless test "[ -f #{fetch :cache_path}/current ]"
54
+ error "Cache symlink is broken"
55
+ exit 1
56
+ end
57
+ end
58
+
59
+ on release_roles :all do
60
+ execute :mkdir, "-p", release_path
61
+ upload! "#{fetch :cache_path}/current", repo_path
62
+ strategy.release
63
+ end
64
+ end
65
+
66
+ task :set_current_revision do
67
+ on release_roles :all do
68
+ within release_path do
69
+ set :current_revision, strategy.fetch_revision
70
+ end
71
+ end
72
+ end
73
+
74
+ task :cleanup do
75
+ run_locally do
76
+ releases = capture( :ls, "-xtr", fetch( :cache_path ) ).split
77
+ releases.reject! { |r| r =~ /current/ }
78
+
79
+ if releases.count >= fetch( :keep_releases )
80
+ expired = releases - releases.last( fetch :keep_releases )
81
+
82
+ if expired.any?
83
+ within fetch( :cache_path ) do
84
+ execute :rm, "-rf", expired.join( " " )
85
+ end
86
+ end
87
+ end
88
+ end
89
+ end
90
+
91
+ end
92
+
93
+ namespace :deploy do
94
+
95
+ task :pack do
96
+ invoke :"deploy:check"
97
+ invoke :"archive:pack_release"
98
+ end
99
+
100
+ end
@@ -0,0 +1,106 @@
1
+ namespace :rsync do
2
+
3
+ def strategy
4
+ @strategy ||= OngrDeploy::Capistrano::Rsync.new(
5
+ self, fetch( :strategy, OngrDeploy::Capistrano::Rsync::DefaultStrategy )
6
+ )
7
+ end
8
+
9
+ task :check do
10
+ set :cache_path, "#{fetch :tmp_dir}/#{fetch :application}/#{fetch :branch }"
11
+
12
+ run_locally do
13
+ set :origin_revision, capture( :git, "rev-parse --short origin/#{fetch :branch }" ).chomp
14
+
15
+ execute :mkdir, "-p", fetch( :cache_path )
16
+ end
17
+
18
+ on release_roles :all do
19
+ execute :mkdir, "-p", repo_path
20
+ end
21
+ end
22
+
23
+ task :pack_release do
24
+ exclude = []
25
+
26
+ fetch( :exclude, [] ).each do |e|
27
+ exclude << "--exclude=#{e}"
28
+ end
29
+
30
+ set :archive_path, "#{fetch :cache_path}/#{fetch :origin_revision}/"
31
+
32
+ run_locally do
33
+ execute :mkdir, "-p", fetch( :archive_path )
34
+ execute :rsync, "-rlp", "--delete", "--delete-excluded", exclude.join( " " ), "./", fetch( :archive_path )
35
+ execute :rm, "-f", "#{fetch :cache_path}/current"
36
+ execute :ln, "-s", fetch( :archive_path ), "#{fetch :cache_path}/current"
37
+ end
38
+
39
+ invoke :"rsync:cleanup"
40
+ end
41
+
42
+ task :create_release do
43
+ if fetch( :archive_cache, false )
44
+ run_locally do
45
+ unless test "[ -L #{fetch :cache_path}/current ]"
46
+ error "Deploy only allowed for already packed releases"
47
+ exit 1
48
+ end
49
+ end
50
+ else
51
+ invoke :"archive:pack_release"
52
+ end
53
+
54
+ run_locally do
55
+ unless test "[ -d #{fetch :cache_path}/current ]"
56
+ error "Cache symlink is broken"
57
+ exit 1
58
+ end
59
+ end
60
+
61
+ on release_roles :all do |host|
62
+ execute :mkdir, "-p", release_path
63
+
64
+ run_locally do
65
+ execute :rsync, "-crlpz", "--delete", "--stats", "#{fetch :cache_path}/current/", "#{host.username}@#{host.hostname}:#{repo_path}"
66
+ end
67
+
68
+ strategy.release
69
+ end
70
+ end
71
+
72
+ task :set_current_revision do
73
+ on release_roles :all do
74
+ within release_path do
75
+ set :current_revision, strategy.fetch_revision
76
+ end
77
+ end
78
+ end
79
+
80
+ task :cleanup do
81
+ run_locally do
82
+ releases = capture( :ls, "-xtr", fetch( :cache_path ) ).split
83
+ releases.reject! { |r| r =~ /current/ }
84
+
85
+ if releases.count >= fetch( :keep_releases )
86
+ expired = releases - releases.last( fetch :keep_releases )
87
+
88
+ if expired.any?
89
+ within fetch( :cache_path ) do
90
+ execute :rm, "-rf", expired.join( " " )
91
+ end
92
+ end
93
+ end
94
+ end
95
+ end
96
+
97
+ end
98
+
99
+ namespace :deploy do
100
+
101
+ task :pack do
102
+ invoke :"deploy:check"
103
+ invoke :"rsync:pack_release"
104
+ end
105
+
106
+ end
metadata ADDED
@@ -0,0 +1,73 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: ongr_deploy
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.6
5
+ platform: ruby
6
+ authors:
7
+ - Voldemaras Kadys
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-04-29 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: capistrano
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '3.3'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '3.3'
27
+ description: Capistrano extension
28
+ email: info@ongr.io
29
+ executables:
30
+ - ongr
31
+ extensions: []
32
+ extra_rdoc_files: []
33
+ files:
34
+ - LICENSE
35
+ - README.rdoc
36
+ - Rakefile
37
+ - bin/ongr
38
+ - lib/ongr_deploy.rb
39
+ - lib/ongr_deploy/application.rb
40
+ - lib/ongr_deploy/scm/archive.rb
41
+ - lib/ongr_deploy/scm/rsync.rb
42
+ - lib/ongr_deploy/version.rb
43
+ - lib/sample/Capfile
44
+ - lib/sample/deploy.rb
45
+ - lib/sample/stage.rb
46
+ - lib/tasks/ongr_deploy.rake
47
+ - lib/tasks/scm/archive.rake
48
+ - lib/tasks/scm/rsync.rake
49
+ homepage: https://github.com/ongr-io/ongr_deploy
50
+ licenses:
51
+ - MIT
52
+ metadata: {}
53
+ post_install_message:
54
+ rdoc_options: []
55
+ require_paths:
56
+ - lib
57
+ required_ruby_version: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ required_rubygems_version: !ruby/object:Gem::Requirement
63
+ requirements:
64
+ - - ">="
65
+ - !ruby/object:Gem::Version
66
+ version: '0'
67
+ requirements: []
68
+ rubyforge_project:
69
+ rubygems_version: 2.4.5
70
+ signing_key:
71
+ specification_version: 4
72
+ summary: Capistrano extension for Symfony2 & ONGR projects
73
+ test_files: []