middleman-deploy 0.0.3 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -6,7 +6,7 @@ Middleman Delpoy -- Deploy a [middleman](http://middlemanapp.com/) built site ov
6
6
 
7
7
  ## QUICK START
8
8
 
9
- Be sure that `rsync` is installed.
9
+ If deploying through `rsync`, be sure it is installed.
10
10
 
11
11
  ### Step 1
12
12
 
@@ -27,22 +27,21 @@ Then run:
27
27
 
28
28
  bundle install
29
29
 
30
- ### Step 4
30
+ ### Step 4a - Rsync setup
31
31
 
32
32
  #### These settings are required.
33
33
 
34
34
  Edit `config.rb`, and add:
35
35
 
36
36
  activate :deploy do |deploy|
37
- deploy.user = "tvaughan"
38
- deploy.host = "www.example.com"
39
- deploy.path = "/srv/www/site"
37
+ deploy.method = :rsync
38
+ deploy.user = "tvaughan"
39
+ deploy.host = "www.example.com"
40
+ deploy.path = "/srv/www/site"
40
41
  end
41
42
 
42
43
  Adjust these values accordingly.
43
44
 
44
- ### Step 4.1
45
-
46
45
  #### These settings are optional.
47
46
 
48
47
  To use a particular SSH port, add:
@@ -57,6 +56,17 @@ To remove orphaned files or directories on the remote host, add:
57
56
 
58
57
  Default is `false`.
59
58
 
59
+ ### Step 4b - Github Pages setup
60
+
61
+ Edit `config.rb`, and add:
62
+
63
+ activate :deploy do |deploy|
64
+ deploy.method = :git
65
+ end
66
+
67
+ The git deploy method assumes your project is in a repository with
68
+ github set up as `origin` and a working `gh-pages` branch already in place.
69
+
60
70
  ### Step 5
61
71
 
62
72
  middleman build
@@ -2,6 +2,8 @@ require "middleman-core/cli"
2
2
 
3
3
  require "middleman-deploy/extension"
4
4
 
5
+ require 'git'
6
+
5
7
  module Middleman
6
8
  module Cli
7
9
 
@@ -18,18 +20,26 @@ module Middleman
18
20
  true
19
21
  end
20
22
 
21
- desc "deploy", "Copy build directory to a remote host over rsync"
23
+ desc "deploy", "Copy build directory to a remote host"
22
24
  method_option "clean",
23
25
  :type => :boolean,
24
26
  :aliases => "-c",
25
27
  :desc => "Remove orphaned files or directories on the remote host"
26
28
  def deploy
27
- shared_inst = ::Middleman::Application.server.inst
29
+ send("deploy_#{self.middleman_options.method}")
30
+ end
31
+
32
+ protected
28
33
 
29
- host = shared_inst.options.host
30
- port = shared_inst.options.port
31
- user = shared_inst.options.user
32
- path = shared_inst.options.path
34
+ def middleman_options
35
+ ::Middleman::Application.server.inst.options
36
+ end
37
+
38
+ def deploy_rsync
39
+ host = self.middleman_options.host
40
+ port = self.middleman_options.port
41
+ user = self.middleman_options.user
42
+ path = self.middleman_options.path
33
43
 
34
44
  # These only exists when the config.rb sets them!
35
45
  if (!host || !user || !path)
@@ -51,6 +61,30 @@ module Middleman
51
61
  run command
52
62
  end
53
63
 
64
+ def deploy_git
65
+ puts "## Deploying to Github Pages"
66
+ Dir.mktmpdir do |tmp|
67
+ # clone ./ with branch gh-pages to tmp
68
+ repo = Git.clone(ENV['MM_ROOT'], tmp)
69
+ repo.checkout('origin/gh-pages', :new_branch => 'gh-pages')
70
+
71
+ # copy ./build/* to tmp
72
+ FileUtils.cp_r(Dir.glob(File.join(ENV['MM_ROOT'], 'build', '*')), tmp)
73
+
74
+ # git add and commit in tmp
75
+ repo.add
76
+ repo.commit("Automated commit at #{Time.now.utc}")
77
+
78
+ # push from tmp to self
79
+ repo.push('origin', 'gh-pages')
80
+
81
+ # push to github
82
+ github_url = Git.open(ENV['MM_ROOT']).remote.url
83
+ repo.add_remote('github', github_url)
84
+ repo.push('github', 'gh-pages')
85
+ end
86
+ end
87
+
54
88
  end
55
89
 
56
90
  # Alias "d" to "deploy"
@@ -5,7 +5,7 @@ require "middleman-core"
5
5
  module Middleman
6
6
  module Deploy
7
7
 
8
- class Options < Struct.new(:host, :port, :user, :path, :clean); end
8
+ class Options < Struct.new(:method, :host, :port, :user, :path, :clean); end
9
9
 
10
10
  class << self
11
11
 
@@ -17,6 +17,7 @@ module Middleman
17
17
  options = Options.new(options_hash)
18
18
  yield options if block_given?
19
19
 
20
+ options.method ||= :rsync
20
21
  options.port ||= 22
21
22
  options.clean ||= false
22
23
 
@@ -25,8 +26,9 @@ module Middleman
25
26
  app.send :include, Helpers
26
27
 
27
28
  app.after_configuration do
28
- if (!options.host || !options.user || !options.path)
29
- raise <<EOF
29
+ if (options.method == :rsync)
30
+ if (!options.host || !options.user || !options.path)
31
+ raise <<EOF
30
32
 
31
33
 
32
34
  ERROR: middleman-deploy is not setup correctly. host, user, and path
@@ -39,6 +41,7 @@ activate :deploy do |deploy|
39
41
  end
40
42
 
41
43
  EOF
44
+ end
42
45
  end
43
46
  end
44
47
  end
@@ -1,6 +1,6 @@
1
1
  module Middleman
2
2
  module Deploy
3
3
  PACKAGE = "middleman-deploy"
4
- VERSION = "0.0.3"
4
+ VERSION = "0.0.4"
5
5
  end
6
6
  end
@@ -6,11 +6,11 @@ Gem::Specification.new do |s|
6
6
  s.name = Middleman::Deploy::PACKAGE
7
7
  s.version = Middleman::Deploy::VERSION
8
8
  s.platform = Gem::Platform::RUBY
9
- s.authors = ["Tom Vaughan"]
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.}
13
- s.description = %q{Deploy a middleman built site over rsync.}
12
+ s.summary = %q{Deploy a middleman built site over rsync or to github pages.}
13
+ s.description = %q{Deploy a middleman built site over rsync or to github pages.}
14
14
 
15
15
  s.files = `git ls-files`.split("\n")
16
16
  s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
@@ -21,5 +21,5 @@ Gem::Specification.new do |s|
21
21
  s.add_runtime_dependency("middleman-core", [">= 3.0.0"])
22
22
 
23
23
  # Additional dependencies
24
- # s.add_runtime_dependency("gem-name", "gem-version")
24
+ s.add_runtime_dependency("git", "~> 1.2.0")
25
25
  end
metadata CHANGED
@@ -1,19 +1,20 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: middleman-deploy
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
8
8
  - Tom Vaughan
9
+ - Ben Cates
9
10
  autorequire:
10
11
  bindir: bin
11
12
  cert_chain: []
12
- date: 2012-08-23 00:00:00.000000000 Z
13
+ date: 2012-08-30 00:00:00.000000000 Z
13
14
  dependencies:
14
15
  - !ruby/object:Gem::Dependency
15
16
  name: middleman-core
16
- requirement: &9399040 !ruby/object:Gem::Requirement
17
+ requirement: &19921080 !ruby/object:Gem::Requirement
17
18
  none: false
18
19
  requirements:
19
20
  - - ! '>='
@@ -21,8 +22,19 @@ dependencies:
21
22
  version: 3.0.0
22
23
  type: :runtime
23
24
  prerelease: false
24
- version_requirements: *9399040
25
- description: Deploy a middleman built site over rsync.
25
+ version_requirements: *19921080
26
+ - !ruby/object:Gem::Dependency
27
+ name: git
28
+ requirement: &19919900 !ruby/object:Gem::Requirement
29
+ none: false
30
+ requirements:
31
+ - - ~>
32
+ - !ruby/object:Gem::Version
33
+ version: 1.2.0
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: *19919900
37
+ description: Deploy a middleman built site over rsync or to github pages.
26
38
  email:
27
39
  - thomas.david.vaughan@gmail.com
28
40
  executables: []
@@ -64,6 +76,6 @@ rubyforge_project:
64
76
  rubygems_version: 1.8.11
65
77
  signing_key:
66
78
  specification_version: 3
67
- summary: Deploy a middleman built site over rsync.
79
+ summary: Deploy a middleman built site over rsync or to github pages.
68
80
  test_files: []
69
81
  has_rdoc: