capistrano-scm-local_git_upload 0.1.0
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 +7 -0
- data/LICENSE.txt +21 -0
- data/README.md +55 -0
- data/lib/capistrano/scm/local_git_upload/version.rb +9 -0
- data/lib/capistrano/scm/local_git_upload.rb +61 -0
- data/lib/capistrano/scm/tasks/git_local.rake +62 -0
- data/lib/capistrano/scm/tasks/upload.rake +24 -0
- metadata +66 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: a183d852f5deb9279bb479403d129b5fa3c5d496a35717d002a9886d2f9dc721
|
4
|
+
data.tar.gz: cf3064d8ab73d3ebe516f7e4ac9df4b313e33512e71675be092d7ff3b7979cd7
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: d4c971ab1addca8f49adb79168b1682781791d2a5d61cca319fcd54756a940df0d96768af4136d08596083b63574c1460540348acc98f72e942f6a4fea915de1
|
7
|
+
data.tar.gz: f17b3448bc0fef5821706d1b109335bd5481e9a99bc76baa73d9fa1a0306cd85b08ceab776a5d6a42744bde74ebb61bbd9e2a1f05bc744c6f41c47642d00cac4
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2022 TODO: Write your name
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,55 @@
|
|
1
|
+
# Capistrano::Scm::LocalGitUpload
|
2
|
+
|
3
|
+
Capistrano SCM Plugin for local git clone and upload.
|
4
|
+
|
5
|
+
This plugin firstly clones the git repository to the local host
|
6
|
+
and thereafter uploads files on the local host to the remote servers.
|
7
|
+
|
8
|
+
|
9
|
+
## Installation
|
10
|
+
|
11
|
+
Add this line to your application's Gemfile:
|
12
|
+
```ruby
|
13
|
+
gem 'capistrano-scm-local_git_upload'
|
14
|
+
```
|
15
|
+
And execute:
|
16
|
+
```bash
|
17
|
+
$ bundle install
|
18
|
+
```
|
19
|
+
|
20
|
+
Add to Capfile:
|
21
|
+
```ruby
|
22
|
+
require "capistrano/scm/local_git_upload"
|
23
|
+
install_plugin Capistrano::SCM::LocalGitUpload
|
24
|
+
```
|
25
|
+
|
26
|
+
## Usage
|
27
|
+
|
28
|
+
The git repository is cloned
|
29
|
+
to `work_path` (default: `work`) on the local host
|
30
|
+
before `deploy:started`.
|
31
|
+
|
32
|
+
Then,
|
33
|
+
files under `upload_path` (default: `upload`) on the local host
|
34
|
+
are uploaded to `release_path` on the remote servers
|
35
|
+
after `deploy:new_release_path`.
|
36
|
+
|
37
|
+
Therefore, you need to prepare `upload_path` using `work_path` files
|
38
|
+
until `deploy:new_release_path`.
|
39
|
+
|
40
|
+
This is a simple copy example from `work/public` to `upload/public`.
|
41
|
+
```ruby
|
42
|
+
namespace :sample_app do
|
43
|
+
task :copy_to_upload do
|
44
|
+
run_locally do
|
45
|
+
execute :cp, '-pr', work_path.join('public'), upload_path
|
46
|
+
end
|
47
|
+
end
|
48
|
+
before 'deploy:new_release_path', 'sample_app:copy_to_upload'
|
49
|
+
end
|
50
|
+
```
|
51
|
+
|
52
|
+
|
53
|
+
## License
|
54
|
+
|
55
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
@@ -0,0 +1,61 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'capistrano/scm/plugin'
|
4
|
+
require 'capistrano/scm/git'
|
5
|
+
|
6
|
+
module Capistrano
|
7
|
+
module DSL
|
8
|
+
# DSL extension for LocalGitUpload
|
9
|
+
module LocalGitUpload
|
10
|
+
def work_path
|
11
|
+
Pathname.new fetch(:work_path)
|
12
|
+
end
|
13
|
+
|
14
|
+
def upload_path
|
15
|
+
Pathname.new fetch(:upload_path)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
extend Capistrano::DSL::LocalGitUpload # rubocop:disable Style/MixinUsage
|
21
|
+
include Capistrano::DSL::LocalGitUpload # rubocop:disable Style/MixinUsage
|
22
|
+
|
23
|
+
module Capistrano
|
24
|
+
class SCM
|
25
|
+
# Capistrano SCM plugin for local git clone followed by upload
|
26
|
+
class LocalGitUpload < ::Capistrano::SCM::Plugin
|
27
|
+
def initialize
|
28
|
+
super
|
29
|
+
@git_plugin = Capistrano::SCM::Git.new
|
30
|
+
end
|
31
|
+
|
32
|
+
def set_defaults
|
33
|
+
@git_plugin.set_defaults
|
34
|
+
set_if_empty :local_top, Dir.getwd
|
35
|
+
set_if_empty :repo_path, local_path('repo')
|
36
|
+
set_if_empty :work_path, local_path('work')
|
37
|
+
set_if_empty :upload_path, local_path('upload')
|
38
|
+
end
|
39
|
+
|
40
|
+
def define_tasks
|
41
|
+
eval_rakefile File.expand_path('tasks/git_local.rake', __dir__)
|
42
|
+
eval_rakefile File.expand_path('tasks/upload.rake', __dir__)
|
43
|
+
end
|
44
|
+
|
45
|
+
def register_hooks
|
46
|
+
before 'deploy:check', 'upload:check_directory'
|
47
|
+
before 'deploy:started', 'git_local:create_work'
|
48
|
+
after 'deploy:new_release_path', 'upload:create_release'
|
49
|
+
before 'deploy:set_current_revision', 'git_local:set_current_revision'
|
50
|
+
after 'deploy:finishing', 'git_local:remove_directory'
|
51
|
+
after 'deploy:finishing', 'upload:remove_directory'
|
52
|
+
end
|
53
|
+
|
54
|
+
private
|
55
|
+
|
56
|
+
def local_path(path)
|
57
|
+
Pathname.new(fetch(:local_top)).join(path).to_s
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
@@ -0,0 +1,62 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
git_plugin = @git_plugin
|
4
|
+
|
5
|
+
namespace :git_local do
|
6
|
+
desc 'Clone the repo to the local cache'
|
7
|
+
task :clone do
|
8
|
+
run_locally do
|
9
|
+
execute :mkdir, '-p', repo_path
|
10
|
+
if git_plugin.repo_mirror_exists?
|
11
|
+
info t(:mirror_exists, at: repo_path)
|
12
|
+
else
|
13
|
+
with fetch(:git_environmental_variables) do
|
14
|
+
git_plugin.clone_repo
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
desc 'Update the local repo mirror to reflect the origin state'
|
21
|
+
task update: :clone do
|
22
|
+
run_locally do
|
23
|
+
within repo_path do
|
24
|
+
with fetch(:git_environmental_variables) do
|
25
|
+
git_plugin.update_mirror
|
26
|
+
git_plugin.verify_commit if fetch(:git_verify_commit)
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
desc 'Copy repo to the working directory'
|
33
|
+
task create_work: :update do
|
34
|
+
run_locally do
|
35
|
+
with fetch(:git_environmental_variables) do
|
36
|
+
set :release_path, work_path
|
37
|
+
within repo_path do
|
38
|
+
execute :mkdir, '-p', release_path
|
39
|
+
git_plugin.archive_to_release_path
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
desc 'Determine the revision that will be deployed'
|
46
|
+
task :set_current_revision do
|
47
|
+
run_locally do
|
48
|
+
within repo_path do
|
49
|
+
with fetch(:git_environmental_variables) do
|
50
|
+
set :current_revision, git_plugin.fetch_revision
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
desc 'Remove the working directory'
|
57
|
+
task :remove_directory do
|
58
|
+
run_locally do
|
59
|
+
execute :rm, '-rf', work_path
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
namespace :upload do
|
4
|
+
desc 'Check the local upload directory'
|
5
|
+
task :check_directory do
|
6
|
+
run_locally do
|
7
|
+
execute :mkdir, '-p', upload_path
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
desc 'Upload the local upload directory recursively'
|
12
|
+
task :create_release do
|
13
|
+
on release_roles :all do
|
14
|
+
upload! upload_path.to_s, release_path, recursive: true
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
desc 'Remove the local upload directory'
|
19
|
+
task :remove_directory do
|
20
|
+
run_locally do
|
21
|
+
execute :rm, '-rf', upload_path
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
metadata
ADDED
@@ -0,0 +1,66 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: capistrano-scm-local_git_upload
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- SHIMAYOSHI, Takao
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2022-03-16 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.1'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '3.1'
|
27
|
+
description: Capistrano SCM plugin for local git clone and upload.
|
28
|
+
email:
|
29
|
+
- simayosi@cc.kyushu-u.ac.jp
|
30
|
+
executables: []
|
31
|
+
extensions: []
|
32
|
+
extra_rdoc_files: []
|
33
|
+
files:
|
34
|
+
- LICENSE.txt
|
35
|
+
- README.md
|
36
|
+
- lib/capistrano/scm/local_git_upload.rb
|
37
|
+
- lib/capistrano/scm/local_git_upload/version.rb
|
38
|
+
- lib/capistrano/scm/tasks/git_local.rake
|
39
|
+
- lib/capistrano/scm/tasks/upload.rake
|
40
|
+
homepage: https://github.com/simayosi/capistrano-scm-local_git_upload
|
41
|
+
licenses:
|
42
|
+
- MIT
|
43
|
+
metadata:
|
44
|
+
homepage_uri: https://github.com/simayosi/capistrano-scm-local_git_upload
|
45
|
+
source_code_uri: https://github.com/simayosi/capistrano-scm-local_git_upload
|
46
|
+
documentation_uri: https://github.com/simayosi/capistrano-scm-local_git_upload
|
47
|
+
post_install_message:
|
48
|
+
rdoc_options: []
|
49
|
+
require_paths:
|
50
|
+
- lib
|
51
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
52
|
+
requirements:
|
53
|
+
- - ">="
|
54
|
+
- !ruby/object:Gem::Version
|
55
|
+
version: 2.6.0
|
56
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
57
|
+
requirements:
|
58
|
+
- - ">="
|
59
|
+
- !ruby/object:Gem::Version
|
60
|
+
version: '0'
|
61
|
+
requirements: []
|
62
|
+
rubygems_version: 3.0.3.1
|
63
|
+
signing_key:
|
64
|
+
specification_version: 4
|
65
|
+
summary: Capistrano::SCM::LocalGitUpload
|
66
|
+
test_files: []
|