Skip to content
This repository was archived by the owner on Jan 30, 2024. It is now read-only.

Commit b1e21a2

Browse files
committed
Merge branch 'release/9.1.0'
* release/9.1.0: prepare release v9.1.0 Always execute tasks for each server or at rollback Update capistrano 3.10.1 Do not load sshkit dsl Delete not needed copy strategy loading file. Use correct capistrano context at copy scm
2 parents 64bb2e2 + 51741a5 commit b1e21a2

File tree

10 files changed

+58
-70
lines changed

10 files changed

+58
-70
lines changed

CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,13 @@
22
All notable changes to this project will be documented in this file.
33
This project adheres to [Semantic Versioning](http://semver.org/).
44

5+
## [9.1.0]
6+
### Summary
7+
8+
- Use correct capistrano context at copy scm
9+
- Update capistrano 3.10.1
10+
- Always execute tasks for each server or at rollback
11+
512
## [9.0.0]
613
### Summary
714

@@ -33,6 +40,7 @@ This project adheres to [Semantic Versioning](http://semver.org/).
3340
- first public release
3441

3542
[Unreleased]: https://github.com/dkdeploy/dkdeploy-core/compare/master...develop
43+
[9.1.0]: https://github.com/dkdeploy/dkdeploy-core/releases/tag/v9.1.0
3644
[9.0.0]: https://github.com/dkdeploy/dkdeploy-core/releases/tag/v9.0.0
3745
[8.0.1]: https://github.com/dkdeploy/dkdeploy-core/releases/tag/v8.0.1
3846
[8.0.0]: https://github.com/dkdeploy/dkdeploy-core/releases/tag/v8.0.0

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ This Rubygem `dkdeploy-core` represents the extension of [Capistrano](http://cap
1313

1414
Add this line to your application's `Gemfile`
1515

16-
gem 'dkdeploy-core', '~> 9.0'
16+
gem 'dkdeploy-core', '~> 9.1'
1717

1818
and then execute
1919

dkdeploy-core.gemspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,6 @@ Gem::Specification.new do |spec|
2828
spec.add_development_dependency 'pry', '~> 0.10'
2929
spec.add_development_dependency 'dkdeploy-test_environment', '~> 2.0'
3030

31-
spec.add_dependency 'capistrano', '~> 3.9.0'
31+
spec.add_dependency 'capistrano', '~> 3.10.1'
3232
spec.add_dependency 'highline', '~> 1.7.1'
3333
end

lib/capistrano/copy.rb

Lines changed: 0 additions & 2 deletions
This file was deleted.

lib/dkdeploy/core/version.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ module Core
44
#
55
class Version
66
MAJOR = 9
7-
MINOR = 0
7+
MINOR = 1
88
PATCH = 0
99

1010
def self.to_s

lib/dkdeploy/dsl.rb

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,14 @@ module DSL
66
# @param server [Capistrano::Configuration::Server] Server to execute task
77
# @param task [String] Name of rake/capistrano task
88
# @param args [Array] Arguments of rake/capistrano task
9-
def invoke_for_server(server, task, *args) # rubocop:disable Metrics/AbcSize
9+
def invoke_for_server(server, task, *args)
1010
backup_filter = fetch :filter, {}
1111
new_server_filter = Marshal.load(Marshal.dump(backup_filter))
1212
new_server_filter[:host] = server.hostname
1313
set :filter, new_server_filter
1414
env.setup_filters
1515
info I18n.t('dsl.invoke_for_server.set_filter', task: task, host: server.hostname, scope: :dkdeploy)
16-
invoke task, *args
17-
Rake::Task[task].reenable
16+
invoke! task, *args
1817
ensure
1918
set :filter, backup_filter
2019
env.setup_filters

lib/dkdeploy/scm/copy.rake

Lines changed: 38 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
# This trick lets us access the copy plugin within `on` blocks.
2-
copy_plugin = self
3-
41
namespace :copy do
52
desc 'Check if all configuration variables and copy sources exist'
63
task :check do
@@ -24,11 +21,11 @@ namespace :copy do
2421

2522
# generate an exclude.txt file with the patterns to be excluded
2623
exclude_content = copy_exclude.join("\n")
27-
File.write(copy_plugin.local_exclude_path, exclude_content)
24+
File.write(local_exclude_path, exclude_content)
2825

2926
# build the tar archive excluding the patterns from exclude.txt
3027
within copy_source do
31-
execute :tar, '-X ' + copy_plugin.local_exclude_path, '-cpzf', copy_plugin.local_archive_path, '.'
28+
execute :tar, '-X ' + local_exclude_path, '-cpzf', local_archive_path, '.'
3229
end
3330
end
3431
end
@@ -38,17 +35,17 @@ namespace :copy do
3835
#
3936
task :copy_archive_to_server do
4037
on release_roles :all do
41-
info I18n.t('file.upload', file: 'archive', target: copy_plugin.remote_tmp_dir, scope: :dkdeploy)
42-
execute :mkdir, '-p', copy_plugin.remote_tmp_dir
38+
info I18n.t('file.upload', file: 'archive', target: remote_tmp_dir, scope: :dkdeploy)
39+
execute :mkdir, '-p', remote_tmp_dir
4340

44-
upload! copy_plugin.local_archive_path, copy_plugin.remote_tmp_dir
41+
upload! local_archive_path, remote_tmp_dir
4542

4643
info I18n.t('directory.create', directory: release_path, scope: :dkdeploy)
4744
execute :mkdir, '-p', release_path
4845

4946
within release_path do
5047
info I18n.t('tasks.copy.archive.extract', target: release_path, scope: :dkdeploy)
51-
execute :tar, '-xpzf', copy_plugin.remote_archive_path
48+
execute :tar, '-xpzf', remote_archive_path
5249
end
5350
end
5451
end
@@ -58,19 +55,47 @@ namespace :copy do
5855
task :clean_up_temporary_sources do
5956
# remove the local temporary directory
6057
run_locally do
61-
info I18n.t('file.remove', path: copy_plugin.local_tmp_dir, scope: :dkdeploy)
62-
execute :rm, '-rf', copy_plugin.local_tmp_dir
58+
info I18n.t('file.remove', path: fetch(:copy_local_tmp_dir), scope: :dkdeploy)
59+
execute :rm, '-rf', fetch(:copy_local_tmp_dir)
6360
end
6461

6562
# removes the remote temp path including the uploaded archive
6663
on release_roles :all do
67-
info I18n.t('file.remove', path: copy_plugin.remote_archive_path, scope: :dkdeploy)
68-
execute :rm, '-rf', copy_plugin.remote_tmp_dir
64+
info I18n.t('file.remove', path: remote_archive_path, scope: :dkdeploy)
65+
execute :rm, '-rf', remote_tmp_dir
6966
end
7067
end
7168

7269
desc 'Determine the revision that will be deployed'
7370
task :set_current_revision do
7471
set :current_revision, I18n.t('log.revision_log_message', copy_source: fetch(:copy_source), time: Time.now, scope: :dkdeploy)
7572
end
73+
74+
# Archive path in a local temporary directory
75+
#
76+
# @return [String]
77+
def local_exclude_path
78+
File.join fetch(:copy_local_tmp_dir), 'exclude.txt'
79+
end
80+
81+
# Archive path in a local temporary directory
82+
#
83+
# @return [String]
84+
def local_archive_path
85+
File.join fetch(:copy_local_tmp_dir), fetch(:copy_archive_filename)
86+
end
87+
88+
# Remote temporary directory path
89+
#
90+
# @return [String]
91+
def remote_tmp_dir
92+
File.join fetch(:tmp_dir), application
93+
end
94+
95+
# Archive path in a remote temporary directory
96+
#
97+
# @return [String]
98+
def remote_archive_path
99+
File.join remote_tmp_dir, fetch(:copy_archive_filename)
100+
end
76101
end

lib/dkdeploy/scm/copy.rb

Lines changed: 5 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ def set_defaults
2525
'Thumbs.db',
2626
'composer.lock'
2727
]
28+
set_if_empty :copy_archive_filename, -> { Dir::Tmpname.make_tmpname([fetch(:application) + '_', '.tar.gz'], nil) }
29+
set_if_empty :copy_local_tmp_dir, Dir.mktmpdir
2830
end
2931

3032
def register_hooks
@@ -34,51 +36,9 @@ def register_hooks
3436
end
3537

3638
def define_tasks
37-
eval_rakefile File.expand_path('../copy.rake', __FILE__)
38-
end
39-
40-
# Archive filename as singleton
41-
# Note: if the archive filename doesn't already exist it will be generated
42-
#
43-
# @return [String]
44-
def archive_filename
45-
@archive_filename ||= Dir::Tmpname.make_tmpname [application + '_', '.tar.gz'], nil
46-
end
47-
48-
# Local temporary directory path as singleton
49-
# Note: if the directory doesn't already exist it will be created
50-
#
51-
# @return [String]
52-
def local_tmp_dir
53-
@local_tmp_dir ||= Dir.mktmpdir
54-
end
55-
56-
# Archive path in a local temporary directory
57-
#
58-
# @return [String]
59-
def local_exclude_path
60-
File.join local_tmp_dir, 'exclude.txt'
61-
end
62-
63-
# Archive path in a local temporary directory
64-
#
65-
# @return [String]
66-
def local_archive_path
67-
File.join local_tmp_dir, archive_filename
68-
end
69-
70-
# Remote temporary directory path
71-
#
72-
# @return [String]
73-
def remote_tmp_dir
74-
File.join fetch(:tmp_dir), application
75-
end
76-
77-
# Archive path in a remote temporary directory
78-
#
79-
# @return [String]
80-
def remote_archive_path
81-
File.join remote_tmp_dir, archive_filename
39+
# Don not use method "eval_rakefile" to load rake tasks.
40+
# "eval_rakefile" defined wrong context and use sskit dsl api instead of capistrano dsl.
41+
load File.expand_path('../copy.rake', __FILE__)
8242
end
8343
end
8444
end

lib/dkdeploy/tasks/deploy.rake

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ namespace :deploy do
2222
end
2323
end
2424
# Backup and remove last release
25-
invoke 'deploy:cleanup_rollback'
25+
invoke! 'deploy:cleanup_rollback'
2626

2727
run_locally do
2828
error I18n.t('rollback_tasks', tasks_for_rollback: tasks_for_rollback.join(', '), scope: :dkdeploy) unless tasks_for_rollback.empty?
@@ -33,8 +33,7 @@ namespace :deploy do
3333
next unless Rake::Task.task_defined? task_name
3434

3535
# call rollback task
36-
Rake::Task[task_name].reenable
37-
invoke task_name
36+
invoke! task_name
3837
end
3938

4039
run_locally do

lib/dkdeploy/tasks/maintenance.rake

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
require 'json'
22
require 'i18n'
33
require 'dkdeploy/i18n'
4-
require 'sshkit/dsl'
54
require 'capistrano/dsl'
65

76
include Capistrano::DSL

0 commit comments

Comments
 (0)