capistrano-tarball_scm 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +10 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +21 -0
- data/README.md +72 -0
- data/Rakefile +6 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/capistrano-tarball_scm.gemspec +26 -0
- data/lib/capistrano/tarball_scm/plugin.rb +61 -0
- data/lib/capistrano/tarball_scm/tasks/tarball.rake +23 -0
- data/lib/capistrano/tarball_scm/version.rb +5 -0
- data/lib/capistrano/tarball_scm.rb +7 -0
- metadata +98 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 73fd598841adbab220f20a62d3f2899ba51b23b7
|
4
|
+
data.tar.gz: 62a0b76251c6be18128e9404b25ed8b98255d363
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 42c680d2de279d5c6aae60f55101a1ec7d4258a26d18ee3a1d2fd1526a1ebfb560d3796413a5f15c366e4611af18d785e35898fc0042ddbda33b31c1bcd724bc
|
7
|
+
data.tar.gz: 6f6ed21a4064ab94d227ae3757b2c98ce58ad1a14b2e4c7fa8cb720c3c51f930a84783f286ecfd30a56ed6a75a7c64c6e0d189124dda8eb25eb1a0d6bcf3c5e1
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2017 Artem Chistyakov
|
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,72 @@
|
|
1
|
+
# capistrano-tarball_scm
|
2
|
+
|
3
|
+
This plugin helps you deploy compiled artifacts via [Capistrano](http://capistranorb.com). It packages (locally built) artifacts as [tarballs](https://en.wikipedia.org/wiki/Tar_(computing)) and forwards them to the target server(s).
|
4
|
+
|
5
|
+
## Rationale
|
6
|
+
|
7
|
+
Capistrano’s defaults demand that your target servers have direct access to your VCS repository in order to pull updates to the application code. This implies that any derivative or dependent resources not stored in the source code repository (e.g. config files, dependencies, compiled resources, etc.) must be delivered via a side channel. This may easily become cumbersome (or even problematic), if any of the following is true for your project:
|
8
|
+
|
9
|
+
* You don’t want to grant your application servers direct access to your VCS.
|
10
|
+
* You’re not using a VCS for this particular project.
|
11
|
+
* There’s an explicit compilation step involving a separate toolset that is unavailable (or unnecessary) on your application servers.
|
12
|
+
|
13
|
+
Despite presented drawbacks, the default approach has been proven to work well for typical Ruby applications, where dependencies are installed on each server individually, and external tools are rarely needed to get the app running.
|
14
|
+
|
15
|
+
The `capistrano-tarball_scm` gem is not a replacement, or a generally superior alternative to the defaults. Instead, it’s just a convenient option for deploying static content and compiled artifacts.
|
16
|
+
|
17
|
+
The gem is similar to [capistrano-git-copy](https://github.com/ydkn/capistrano-git-copy) and [capistrano-scm-tar](https://github.com/ziguzagu/capistrano-scm-tar). Although, while sharing the goal of *pushing* updates to the server, it’s distinct in two major areas:
|
18
|
+
|
19
|
+
* It builds the deployed tarball from a provided filesystem path. Conversely, `capistrano-git-copy` loads deployed artifacts directly from Git, while `capistrano-scm-tar` expects the user to provide a prepared tarball.
|
20
|
+
* In contrast to `capistrano-scm-tar`, it relies on the modern SCM plugin API introduced in Capistrano 3.7.
|
21
|
+
|
22
|
+
## Installation
|
23
|
+
|
24
|
+
Add this line to your application's Gemfile:
|
25
|
+
|
26
|
+
```ruby
|
27
|
+
gem 'capistrano-tarball_scm'
|
28
|
+
```
|
29
|
+
|
30
|
+
And then execute:
|
31
|
+
|
32
|
+
$ bundle
|
33
|
+
|
34
|
+
Or install it yourself as:
|
35
|
+
|
36
|
+
$ gem install capistrano-tarball_scm
|
37
|
+
|
38
|
+
Replace any existing SCM plugins in your Capfile with these two lines:
|
39
|
+
|
40
|
+
```ruby
|
41
|
+
require 'capistrano/tarball_scm'
|
42
|
+
install_plugin Capistrano::TarballScm::Plugin
|
43
|
+
```
|
44
|
+
|
45
|
+
## Usage
|
46
|
+
|
47
|
+
By default, a tarball of your working dir will be created in the Capistrano temporary directory (usually, same as your system’s). You can configure this behavior using the following configuration parameters:
|
48
|
+
|
49
|
+
* `:repo_url`
|
50
|
+
* **default:** `.`
|
51
|
+
* The path to the directory containing the deployed artifact.
|
52
|
+
* `:tarball_dir`
|
53
|
+
* **default:** equals Capistrano’s `:tmp_dir`
|
54
|
+
* The path to the directory where to store the create tarball.
|
55
|
+
* `:tarball_exclude`
|
56
|
+
* **default:** `[]`
|
57
|
+
* A list of paths to be excluded from the created tarball.
|
58
|
+
|
59
|
+
## Development
|
60
|
+
|
61
|
+
After cloning the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
62
|
+
|
63
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
64
|
+
|
65
|
+
## Contributing
|
66
|
+
|
67
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/temochka/capistrano-tarball_scm.
|
68
|
+
|
69
|
+
|
70
|
+
## License
|
71
|
+
|
72
|
+
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'bundler/setup'
|
4
|
+
require 'capistrano/tarball_scm'
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require 'irb'
|
14
|
+
IRB.start
|
data/bin/setup
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'capistrano/tarball_scm/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = 'capistrano-tarball_scm'
|
8
|
+
spec.version = Capistrano::TarballScm::VERSION
|
9
|
+
spec.authors = ['Artem Chistyakov']
|
10
|
+
spec.email = ['chistyakov.artem@gmail.com']
|
11
|
+
|
12
|
+
spec.summary = %q{Create and deploy tarballs via Capistrano}
|
13
|
+
spec.homepage = 'https://github.com/temochka/capistrano-tarball_scm'
|
14
|
+
spec.license = 'MIT'
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
17
|
+
f.match(%r{^(test|spec|features)/})
|
18
|
+
end
|
19
|
+
spec.bindir = 'exe'
|
20
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
21
|
+
spec.require_paths = ['lib']
|
22
|
+
|
23
|
+
spec.add_development_dependency 'bundler', '~> 1.13'
|
24
|
+
spec.add_development_dependency 'rake', '~> 10.0'
|
25
|
+
spec.add_development_dependency 'rspec', '~> 3.0'
|
26
|
+
end
|
@@ -0,0 +1,61 @@
|
|
1
|
+
require 'capistrano/scm/plugin'
|
2
|
+
|
3
|
+
module Capistrano
|
4
|
+
module TarballScm
|
5
|
+
class Plugin < Capistrano::SCM::Plugin
|
6
|
+
def set_defaults
|
7
|
+
set_if_empty :repo_url, '.'
|
8
|
+
set_if_empty :repo_tree, '.'
|
9
|
+
set_if_empty :tarball_dir, fetch(:tmp_dir)
|
10
|
+
set_if_empty :tarball_exclude, []
|
11
|
+
end
|
12
|
+
|
13
|
+
def define_tasks
|
14
|
+
eval_rakefile File.expand_path('../tasks/tarball.rake', __FILE__)
|
15
|
+
end
|
16
|
+
|
17
|
+
def register_hooks
|
18
|
+
after 'deploy:new_release_path', 'tarball:create_release'
|
19
|
+
before 'deploy:set_current_revision', 'tarball:set_current_revision'
|
20
|
+
end
|
21
|
+
|
22
|
+
def create
|
23
|
+
excludes = fetch(:tarball_exclude).map { |d| "--exclude #{d}" }.join
|
24
|
+
backend.execute(:mkdir, '-p', tarball_dir)
|
25
|
+
backend.execute(:tar, '-C', tarball_root, '--exclude', tarball_dir, excludes, '-cjf', tarball_path, '.')
|
26
|
+
end
|
27
|
+
|
28
|
+
def release
|
29
|
+
backend.execute(:mkdir, '-p', release_path)
|
30
|
+
backend.upload!(tarball_path, release_path)
|
31
|
+
|
32
|
+
backend.within(release_path) do
|
33
|
+
backend.execute :tar, '-xjf', File.basename(tarball_path)
|
34
|
+
backend.execute :rm, '-f', File.basename(tarball_path)
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
def fetch_revision
|
39
|
+
backend.capture(:git, 'rev-parse', 'HEAD').strip
|
40
|
+
end
|
41
|
+
|
42
|
+
private
|
43
|
+
|
44
|
+
def tarball_dir
|
45
|
+
fetch(:tarball_dir)
|
46
|
+
end
|
47
|
+
|
48
|
+
def tarball_name
|
49
|
+
"#{release_timestamp}.tar.bz2"
|
50
|
+
end
|
51
|
+
|
52
|
+
def tarball_path
|
53
|
+
File.join(tarball_dir, tarball_name)
|
54
|
+
end
|
55
|
+
|
56
|
+
def tarball_root
|
57
|
+
File.join(fetch(:repo_url), fetch(:repo_tree))
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
tarball_scm = self
|
2
|
+
|
3
|
+
namespace :tarball do
|
4
|
+
desc 'Create tarball'
|
5
|
+
task :create do
|
6
|
+
run_locally do
|
7
|
+
tarball_scm.create
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
desc 'Create and upload the tarball'
|
12
|
+
task create_release: :'tarball:create' do
|
13
|
+
on release_roles :all do
|
14
|
+
tarball_scm.release
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
task :set_current_revision do
|
19
|
+
run_locally do
|
20
|
+
set :current_revision, tarball_scm.fetch_revision
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
metadata
ADDED
@@ -0,0 +1,98 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: capistrano-tarball_scm
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Artem Chistyakov
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2017-01-02 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.13'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.13'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rspec
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '3.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '3.0'
|
55
|
+
description:
|
56
|
+
email:
|
57
|
+
- chistyakov.artem@gmail.com
|
58
|
+
executables: []
|
59
|
+
extensions: []
|
60
|
+
extra_rdoc_files: []
|
61
|
+
files:
|
62
|
+
- ".gitignore"
|
63
|
+
- Gemfile
|
64
|
+
- LICENSE.txt
|
65
|
+
- README.md
|
66
|
+
- Rakefile
|
67
|
+
- bin/console
|
68
|
+
- bin/setup
|
69
|
+
- capistrano-tarball_scm.gemspec
|
70
|
+
- lib/capistrano/tarball_scm.rb
|
71
|
+
- lib/capistrano/tarball_scm/plugin.rb
|
72
|
+
- lib/capistrano/tarball_scm/tasks/tarball.rake
|
73
|
+
- lib/capistrano/tarball_scm/version.rb
|
74
|
+
homepage: https://github.com/temochka/capistrano-tarball_scm
|
75
|
+
licenses:
|
76
|
+
- MIT
|
77
|
+
metadata: {}
|
78
|
+
post_install_message:
|
79
|
+
rdoc_options: []
|
80
|
+
require_paths:
|
81
|
+
- lib
|
82
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
83
|
+
requirements:
|
84
|
+
- - ">="
|
85
|
+
- !ruby/object:Gem::Version
|
86
|
+
version: '0'
|
87
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
88
|
+
requirements:
|
89
|
+
- - ">="
|
90
|
+
- !ruby/object:Gem::Version
|
91
|
+
version: '0'
|
92
|
+
requirements: []
|
93
|
+
rubyforge_project:
|
94
|
+
rubygems_version: 2.5.1
|
95
|
+
signing_key:
|
96
|
+
specification_version: 4
|
97
|
+
summary: Create and deploy tarballs via Capistrano
|
98
|
+
test_files: []
|