middleman-deploy 0.0.5 → 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.
- data/.gitignore +1 -0
- data/Gemfile +1 -0
- data/README.md +35 -7
- data/features/support/env.rb +3 -1
- data/lib/middleman-deploy/commands.rb +39 -21
- data/lib/middleman-deploy/extension.rb +3 -1
- data/lib/middleman-deploy/pkg-info.rb +1 -1
- data/middleman-deploy.gemspec +2 -2
- metadata +9 -8
data/.gitignore
CHANGED
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
Middleman Delpoy -- Deploy a [middleman](http://middlemanapp.com/) built site over rsync or
|
1
|
+
Middleman Delpoy -- Deploy a [middleman](http://middlemanapp.com/) built site over rsync or via git (e.g. gh-pages on github).
|
2
2
|
|
3
3
|
[](http://travis-ci.org/tvaughan/middleman-deploy)
|
4
4
|
|
@@ -6,8 +6,6 @@ Middleman Delpoy -- Deploy a [middleman](http://middlemanapp.com/) built site ov
|
|
6
6
|
|
7
7
|
## QUICK START
|
8
8
|
|
9
|
-
If deploying through `rsync`, be sure it is installed.
|
10
|
-
|
11
9
|
### Step 1
|
12
10
|
|
13
11
|
gem install middleman-deploy
|
@@ -29,6 +27,8 @@ Then run:
|
|
29
27
|
|
30
28
|
### Step 4a - Rsync setup
|
31
29
|
|
30
|
+
First be sure that `rsync` is installed.
|
31
|
+
|
32
32
|
#### These settings are required.
|
33
33
|
|
34
34
|
Edit `config.rb`, and add:
|
@@ -56,7 +56,22 @@ To remove orphaned files or directories on the remote host, add:
|
|
56
56
|
|
57
57
|
Default is `false`.
|
58
58
|
|
59
|
-
### Step 4b -
|
59
|
+
### Step 4b - Git setup
|
60
|
+
|
61
|
+
First be sure that you have already placed your project under revision
|
62
|
+
control using git.
|
63
|
+
|
64
|
+
For example, for the default values of remote="master" and
|
65
|
+
branch="gh-pages", the output of `git branch -a` should look like:
|
66
|
+
|
67
|
+
gh-pages
|
68
|
+
* master
|
69
|
+
remotes/origin/HEAD -> origin/master
|
70
|
+
remotes/origin/gh-pages
|
71
|
+
remotes/origin/master
|
72
|
+
|
73
|
+
This shows that "gh-pages" exists in the remote and local repos. There
|
74
|
+
needs to be at least one commit in "gh-pages" with which to start.
|
60
75
|
|
61
76
|
Edit `config.rb`, and add:
|
62
77
|
|
@@ -64,13 +79,26 @@ Edit `config.rb`, and add:
|
|
64
79
|
deploy.method = :git
|
65
80
|
end
|
66
81
|
|
67
|
-
|
68
|
-
|
82
|
+
#### These settings are optional.
|
83
|
+
|
84
|
+
To use a particular remote, add:
|
85
|
+
|
86
|
+
deploy.remote = "some-other-remote-name"
|
87
|
+
|
88
|
+
Default is `origin`. Run `git remote -v` to see a list of possible
|
89
|
+
remotes.
|
90
|
+
|
91
|
+
To use a particular branch, add:
|
92
|
+
|
93
|
+
deploy.branch = "some-other-branch-name"
|
94
|
+
|
95
|
+
Default is `gh-pages`. Run `git branch -a` to see a list of possible
|
96
|
+
branches.
|
69
97
|
|
70
98
|
### Step 5
|
71
99
|
|
72
100
|
middleman build [--clean]
|
73
|
-
middleman deploy
|
101
|
+
middleman deploy [--clean]
|
74
102
|
|
75
103
|
### NOTES
|
76
104
|
|
data/features/support/env.rb
CHANGED
@@ -1,4 +1,6 @@
|
|
1
|
+
require "simplecov"
|
2
|
+
SimpleCov.start
|
1
3
|
PROJECT_ROOT_PATH = File.dirname(File.dirname(File.dirname(__FILE__)))
|
2
4
|
require "middleman-core"
|
3
5
|
require "middleman-core/step_definitions"
|
4
|
-
require File.join(PROJECT_ROOT_PATH, 'lib', 'middleman-deploy')
|
6
|
+
require File.join(PROJECT_ROOT_PATH, 'lib', 'middleman-deploy')
|
@@ -1,8 +1,12 @@
|
|
1
1
|
require "middleman-core/cli"
|
2
2
|
|
3
3
|
require "middleman-deploy/extension"
|
4
|
+
require "middleman-deploy/pkg-info"
|
4
5
|
|
5
|
-
require
|
6
|
+
require "git"
|
7
|
+
|
8
|
+
PACKAGE = "#{Middleman::Deploy::PACKAGE}"
|
9
|
+
VERSION = "#{Middleman::Deploy::VERSION}"
|
6
10
|
|
7
11
|
module Middleman
|
8
12
|
module Cli
|
@@ -20,7 +24,7 @@ module Middleman
|
|
20
24
|
true
|
21
25
|
end
|
22
26
|
|
23
|
-
desc "deploy", "
|
27
|
+
desc "deploy", "Deploy build directory to a remote host via rsync or git"
|
24
28
|
method_option "clean",
|
25
29
|
:type => :boolean,
|
26
30
|
:aliases => "-c",
|
@@ -37,20 +41,26 @@ module Middleman
|
|
37
41
|
You should follow one of the two examples below to setup the deploy
|
38
42
|
extension in config.rb.
|
39
43
|
|
40
|
-
# To
|
44
|
+
# To deploy the build directory to a remote host via rsync:
|
41
45
|
activate :deploy do |deploy|
|
42
46
|
deploy.method = :rsync
|
43
47
|
# host, user, and path *must* be set
|
44
48
|
deploy.user = "tvaughan"
|
45
49
|
deploy.host = "www.example.com"
|
46
50
|
deploy.path = "/srv/www/site"
|
47
|
-
# clean is optional (default is false)
|
51
|
+
# clean is optional (default is false)
|
48
52
|
deploy.clean = true
|
49
53
|
end
|
50
54
|
|
51
|
-
# To
|
55
|
+
# To deploy to a remote branch via git (e.g. gh-pages on github):
|
52
56
|
activate :deploy do |deploy|
|
53
57
|
deploy.method = :git
|
58
|
+
# remote is optional (default is "origin")
|
59
|
+
# run `git remote -v` to see a list of possible remotes
|
60
|
+
deploy.remote = "some-other-remote-name"
|
61
|
+
# branch is optional (default is "gh-pages")
|
62
|
+
# run `git branch -a` to see a list of possible branches
|
63
|
+
deploy.branch = "some-other-branch-name"
|
54
64
|
end
|
55
65
|
EOF
|
56
66
|
end
|
@@ -61,16 +71,16 @@ EOF
|
|
61
71
|
begin
|
62
72
|
options = ::Middleman::Application.server.inst.options
|
63
73
|
rescue
|
64
|
-
print_usage_and_die "You need to activate the deploy extension in config.rb"
|
74
|
+
print_usage_and_die "You need to activate the deploy extension in config.rb."
|
65
75
|
end
|
66
76
|
|
67
77
|
if (!options.method)
|
68
|
-
print_usage_and_die "The deploy extension requires you to set a method"
|
78
|
+
print_usage_and_die "The deploy extension requires you to set a method."
|
69
79
|
end
|
70
80
|
|
71
81
|
if (options.method == :rsync)
|
72
82
|
if (!options.host || !options.user || !options.path)
|
73
|
-
print_usage_and_die "The rsync deploy method requires host, user, and path to be set"
|
83
|
+
print_usage_and_die "The rsync deploy method requires host, user, and path to be set."
|
74
84
|
end
|
75
85
|
end
|
76
86
|
|
@@ -83,6 +93,8 @@ EOF
|
|
83
93
|
user = self.deploy_options.user
|
84
94
|
path = self.deploy_options.path
|
85
95
|
|
96
|
+
puts "## Deploying via rsync to #{user}@#{host}:#{path} port=#{port}"
|
97
|
+
|
86
98
|
command = "rsync -avze '" + "ssh -p #{port}" + "' build/ #{user}@#{host}:#{path}"
|
87
99
|
|
88
100
|
if options.has_key? "clean"
|
@@ -99,27 +111,33 @@ EOF
|
|
99
111
|
end
|
100
112
|
|
101
113
|
def deploy_git
|
102
|
-
|
114
|
+
remote = self.deploy_options.remote
|
115
|
+
branch = self.deploy_options.branch
|
116
|
+
|
117
|
+
puts "## Deploying via git to remote=\"#{remote}\" and branch=\"#{branch}\""
|
118
|
+
|
119
|
+
# ensure that the remote branch exists in ENV["MM_ROOT"]
|
120
|
+
orig = Git.open(ENV["MM_ROOT"])
|
121
|
+
# TODO: orig.branch(branch, "#{remote}/#{branch}")
|
122
|
+
|
103
123
|
Dir.mktmpdir do |tmp|
|
104
|
-
# clone
|
105
|
-
repo = Git.clone(ENV[
|
106
|
-
repo.checkout(
|
124
|
+
# clone ENV["MM_ROOT"] to tmp (ENV["MM_ROOT"] is now "origin")
|
125
|
+
repo = Git.clone(ENV["MM_ROOT"], tmp)
|
126
|
+
repo.checkout("origin/#{branch}", :new_branch => branch)
|
107
127
|
|
108
128
|
# copy ./build/* to tmp
|
109
|
-
FileUtils.cp_r(Dir.glob(File.join(ENV[
|
129
|
+
FileUtils.cp_r(Dir.glob(File.join(ENV["MM_ROOT"], "build", "*")), tmp)
|
110
130
|
|
111
131
|
# git add and commit in tmp
|
112
132
|
repo.add
|
113
|
-
repo.commit("Automated commit at #{Time.now.utc}")
|
114
|
-
|
115
|
-
# push from tmp to self
|
116
|
-
repo.push('origin', 'gh-pages')
|
133
|
+
repo.commit("Automated commit at #{Time.now.utc} by #{PACKAGE} #{VERSION}")
|
117
134
|
|
118
|
-
# push
|
119
|
-
|
120
|
-
repo.add_remote('github', github_url)
|
121
|
-
repo.push('github', 'gh-pages')
|
135
|
+
# push back into ENV["MM_ROOT"]
|
136
|
+
repo.push("origin", branch)
|
122
137
|
end
|
138
|
+
|
139
|
+
orig.push(remote, branch)
|
140
|
+
orig.remote(remote).fetch
|
123
141
|
end
|
124
142
|
|
125
143
|
end
|
@@ -5,7 +5,7 @@ require "middleman-core"
|
|
5
5
|
module Middleman
|
6
6
|
module Deploy
|
7
7
|
|
8
|
-
class Options < Struct.new(:whatisthis, :method, :host, :port, :user, :path, :clean); end
|
8
|
+
class Options < Struct.new(:whatisthis, :method, :host, :port, :user, :path, :clean, :remote, :branch); end
|
9
9
|
|
10
10
|
class << self
|
11
11
|
|
@@ -19,6 +19,8 @@ module Middleman
|
|
19
19
|
|
20
20
|
options.port ||= 22
|
21
21
|
options.clean ||= false
|
22
|
+
options.remote ||= "origin"
|
23
|
+
options.branch ||= "gh-pages"
|
22
24
|
|
23
25
|
@@options = options
|
24
26
|
|
data/middleman-deploy.gemspec
CHANGED
@@ -9,8 +9,8 @@ Gem::Specification.new do |s|
|
|
9
9
|
s.authors = ["Tom Vaughan","Ben Cates"]
|
10
10
|
s.email = ["thomas.david.vaughan@gmail.com"]
|
11
11
|
s.homepage = "http://tvaughan.github.com/middleman-deploy/"
|
12
|
-
s.summary = %q{Deploy a middleman built site over rsync or
|
13
|
-
s.description = %q{Deploy a middleman built site over rsync or
|
12
|
+
s.summary = %q{Deploy a middleman built site over rsync or via git (e.g. gh-pages on github).}
|
13
|
+
s.description = %q{Deploy a middleman built site over rsync or via git (e.g. gh-pages on github).}
|
14
14
|
|
15
15
|
s.files = `git ls-files`.split("\n")
|
16
16
|
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: middleman-deploy
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.6
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -10,11 +10,11 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2012-
|
13
|
+
date: 2012-10-05 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: middleman-core
|
17
|
-
requirement: &
|
17
|
+
requirement: &21821760 !ruby/object:Gem::Requirement
|
18
18
|
none: false
|
19
19
|
requirements:
|
20
20
|
- - ! '>='
|
@@ -22,10 +22,10 @@ dependencies:
|
|
22
22
|
version: 3.0.0
|
23
23
|
type: :runtime
|
24
24
|
prerelease: false
|
25
|
-
version_requirements: *
|
25
|
+
version_requirements: *21821760
|
26
26
|
- !ruby/object:Gem::Dependency
|
27
27
|
name: git
|
28
|
-
requirement: &
|
28
|
+
requirement: &21821260 !ruby/object:Gem::Requirement
|
29
29
|
none: false
|
30
30
|
requirements:
|
31
31
|
- - ~>
|
@@ -33,8 +33,9 @@ dependencies:
|
|
33
33
|
version: 1.2.0
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
|
-
version_requirements: *
|
37
|
-
description: Deploy a middleman built site over rsync or
|
36
|
+
version_requirements: *21821260
|
37
|
+
description: Deploy a middleman built site over rsync or via git (e.g. gh-pages on
|
38
|
+
github).
|
38
39
|
email:
|
39
40
|
- thomas.david.vaughan@gmail.com
|
40
41
|
executables: []
|
@@ -76,6 +77,6 @@ rubyforge_project:
|
|
76
77
|
rubygems_version: 1.8.11
|
77
78
|
signing_key:
|
78
79
|
specification_version: 3
|
79
|
-
summary: Deploy a middleman built site over rsync or
|
80
|
+
summary: Deploy a middleman built site over rsync or via git (e.g. gh-pages on github).
|
80
81
|
test_files: []
|
81
82
|
has_rdoc:
|