middleman-gh-pages 0.0.3 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/README.md +12 -6
- data/lib/middleman-gh-pages/tasks/gh-pages.rake +43 -24
- data/lib/middleman-gh-pages/version.rb +1 -1
- metadata +10 -15
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 4d105923da0ffb05b86b9d8dcf340a589b064a58
|
4
|
+
data.tar.gz: 9027c3db09483baef0fb7e51fed0b32f8369372a
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 189c7373aabe82d014f04d34893a5d6c06ab1592e9fb1d4660eea0a0aefe8f7bf12112864550f9df274dbc06fa570bbb51e5967f68c28ad828bafebe311b394b
|
7
|
+
data.tar.gz: 4850ef79050cf7ebacd98d40e413cf0a8748e615a55676d61c7ed0a77d5041b83af92420f4e72105017f69c465e4c37ba1cb22a9292ea33ae45a033108d6ed86
|
data/README.md
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
# Middleman Github Pages
|
2
2
|
|
3
|
-
[Middleman](http://middlemanapp.com) makes creating static sites a joy, [Github
|
4
|
-
Pages](http://pages.github.com) hosts static sites for free, Middleman Github
|
5
|
-
Pages brings the two together. Middleman Github Pages is just a few rake tasks
|
3
|
+
[Middleman](http://middlemanapp.com) makes creating static sites a joy, [Github
|
4
|
+
Pages](http://pages.github.com) hosts static sites for free, Middleman Github
|
5
|
+
Pages brings the two together. Middleman Github Pages is just a few rake tasks
|
6
6
|
that automate the process of deploying a Middleman site to Github Pages.
|
7
7
|
|
8
8
|
## Installation
|
@@ -28,8 +28,8 @@ rake build # Compile all files into the build directory
|
|
28
28
|
rake publish # Build and publish to Github Pages
|
29
29
|
```
|
30
30
|
|
31
|
-
The only assumption is that you are deploying to a gh-pages branch in the same
|
32
|
-
remote as the source. `rake publish` will create this branch for you if it
|
31
|
+
The only assumption is that you are deploying to a gh-pages branch in the same
|
32
|
+
remote as the source. `rake publish` will create this branch for you if it
|
33
33
|
doesn't exist.
|
34
34
|
|
35
35
|
## Options
|
@@ -44,7 +44,7 @@ bundle exec rake publish ALLOW_DIRTY=true
|
|
44
44
|
You can append a custom suffix to commit messages on the build branch:
|
45
45
|
|
46
46
|
```shell
|
47
|
-
bundle exec rake publish COMMIT_MESSAGE_SUFFIX="
|
47
|
+
bundle exec rake publish COMMIT_MESSAGE_SUFFIX="[skip-ci]"
|
48
48
|
```
|
49
49
|
|
50
50
|
You can change the remote that you deploy to:
|
@@ -53,6 +53,12 @@ You can change the remote that you deploy to:
|
|
53
53
|
bundle exec rake publish REMOTE_NAME=upstream
|
54
54
|
```
|
55
55
|
|
56
|
+
If you're publishing a personal or organization page, you may want to use the branch `master` instead of `gh-pages`:
|
57
|
+
|
58
|
+
```shell
|
59
|
+
bundle exec rake publish BRANCH_NAME=master
|
60
|
+
```
|
61
|
+
|
56
62
|
## Custom Domain
|
57
63
|
|
58
64
|
To set up a custom domain, you can follow the [GitHub help page](https://help.github.com/articles/setting-up-a-custom-domain-with-pages).
|
@@ -1,12 +1,30 @@
|
|
1
|
-
require
|
1
|
+
require "fileutils"
|
2
|
+
require "tmpdir"
|
2
3
|
|
3
4
|
def remote_name
|
4
5
|
ENV.fetch("REMOTE_NAME", "origin")
|
5
6
|
end
|
6
7
|
|
7
|
-
|
8
|
-
|
9
|
-
|
8
|
+
def branch_name
|
9
|
+
ENV.fetch("BRANCH_NAME", "gh-pages")
|
10
|
+
end
|
11
|
+
|
12
|
+
def uncommitted_changes?
|
13
|
+
`git status --porcelain`.chomp.length > 0
|
14
|
+
end
|
15
|
+
|
16
|
+
def backup_and_restore(dir, file, &block)
|
17
|
+
yield unless File.exist?(File.join(dir, file))
|
18
|
+
Dir.mktmpdir do |tmpdir|
|
19
|
+
mv File.join(dir, file), tmpdir
|
20
|
+
yield
|
21
|
+
mv File.join(tmpdir, file), dir
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
PROJECT_ROOT = ENV.fetch("PROJECT_ROOT", `git rev-parse --show-toplevel`.chomp)
|
26
|
+
BUILD_DIR = ENV.fetch("BUILD_DIR", File.join(PROJECT_ROOT, "build"))
|
27
|
+
GH_PAGES_REF = File.join(BUILD_DIR, ".git/refs/remotes/#{remote_name}/#{branch_name}")
|
10
28
|
|
11
29
|
directory BUILD_DIR
|
12
30
|
|
@@ -14,23 +32,22 @@ file GH_PAGES_REF => BUILD_DIR do
|
|
14
32
|
repo_url = nil
|
15
33
|
|
16
34
|
cd PROJECT_ROOT do
|
17
|
-
repo_url = `git config --get remote.#{remote_name}.url`.
|
35
|
+
repo_url = `git config --get remote.#{remote_name}.url`.chomp
|
18
36
|
end
|
19
37
|
|
20
38
|
cd BUILD_DIR do
|
21
39
|
sh "git init"
|
22
40
|
sh "git remote add #{remote_name} #{repo_url}"
|
23
41
|
sh "git fetch #{remote_name}"
|
24
|
-
sh "git checkout master"
|
25
42
|
|
26
|
-
if `git branch -r` =~ /
|
27
|
-
sh "git checkout
|
43
|
+
if `git branch -r` =~ /#{branch_name}/
|
44
|
+
sh "git checkout #{branch_name}"
|
28
45
|
else
|
29
|
-
sh "git checkout --orphan
|
30
|
-
|
46
|
+
sh "git checkout --orphan #{branch_name}"
|
47
|
+
FileUtils.touch("index.html")
|
31
48
|
sh "git add ."
|
32
|
-
sh "git commit -m
|
33
|
-
sh "git push #{remote_name}
|
49
|
+
sh "git commit -m \"initial gh-pages commit\""
|
50
|
+
sh "git push #{remote_name} #{branch_name}"
|
34
51
|
end
|
35
52
|
end
|
36
53
|
end
|
@@ -42,22 +59,24 @@ task :prepare_git_remote_in_build_dir => GH_PAGES_REF
|
|
42
59
|
task :sync do
|
43
60
|
cd BUILD_DIR do
|
44
61
|
sh "git fetch #{remote_name}"
|
45
|
-
sh "git reset --hard #{remote_name}
|
62
|
+
sh "git reset --hard #{remote_name}/#{branch_name}"
|
46
63
|
end
|
47
64
|
end
|
48
65
|
|
49
66
|
# Prevent accidental publishing before committing changes
|
50
67
|
task :not_dirty do
|
51
|
-
|
52
|
-
|
53
|
-
fail "
|
68
|
+
if uncommitted_changes?
|
69
|
+
puts "*** WARNING: You currently have uncommitted changes. ***"
|
70
|
+
fail "Build aborted, because project directory is not clean." unless ENV["ALLOW_DIRTY"]
|
54
71
|
end
|
55
72
|
end
|
56
73
|
|
57
74
|
desc "Compile all files into the build directory"
|
58
75
|
task :build do
|
59
|
-
|
60
|
-
|
76
|
+
backup_and_restore(BUILD_DIR, ".git") do
|
77
|
+
cd PROJECT_ROOT do
|
78
|
+
sh "bundle exec middleman build --clean"
|
79
|
+
end
|
61
80
|
end
|
62
81
|
end
|
63
82
|
|
@@ -67,17 +86,17 @@ task :publish => [:not_dirty, :prepare_git_remote_in_build_dir, :sync, :build] d
|
|
67
86
|
suffix = ENV["COMMIT_MESSAGE_SUFFIX"]
|
68
87
|
|
69
88
|
cd PROJECT_ROOT do
|
70
|
-
head = `git log --pretty="%h" -n1`.
|
89
|
+
head = `git log --pretty="%h" -n1`.chomp
|
71
90
|
message = ["Site updated to #{head}", suffix].compact.join("\n\n")
|
72
91
|
end
|
73
92
|
|
74
93
|
cd BUILD_DIR do
|
75
|
-
sh
|
76
|
-
if
|
77
|
-
puts "No changes to commit."
|
78
|
-
else
|
94
|
+
sh "git add --all"
|
95
|
+
if uncommitted_changes?
|
79
96
|
sh "git commit -m \"#{message}\""
|
97
|
+
else
|
98
|
+
puts "No changes to commit."
|
80
99
|
end
|
81
|
-
sh "git push #{remote_name}
|
100
|
+
sh "git push #{remote_name} #{branch_name}"
|
82
101
|
end
|
83
102
|
end
|
metadata
CHANGED
@@ -1,30 +1,27 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: middleman-gh-pages
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
5
|
-
prerelease:
|
4
|
+
version: 0.1.1
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- Adam McCrea
|
9
8
|
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
date:
|
11
|
+
date: 2016-02-16 00:00:00.000000000 Z
|
13
12
|
dependencies:
|
14
13
|
- !ruby/object:Gem::Dependency
|
15
14
|
name: rake
|
16
15
|
requirement: !ruby/object:Gem::Requirement
|
17
|
-
none: false
|
18
16
|
requirements:
|
19
|
-
- -
|
17
|
+
- - ">"
|
20
18
|
- !ruby/object:Gem::Version
|
21
19
|
version: 0.9.3
|
22
20
|
type: :runtime
|
23
21
|
prerelease: false
|
24
22
|
version_requirements: !ruby/object:Gem::Requirement
|
25
|
-
none: false
|
26
23
|
requirements:
|
27
|
-
- -
|
24
|
+
- - ">"
|
28
25
|
- !ruby/object:Gem::Version
|
29
26
|
version: 0.9.3
|
30
27
|
description: Easy deployment of Middleman sites to Github Pages
|
@@ -34,7 +31,7 @@ executables: []
|
|
34
31
|
extensions: []
|
35
32
|
extra_rdoc_files: []
|
36
33
|
files:
|
37
|
-
- .gitignore
|
34
|
+
- ".gitignore"
|
38
35
|
- Gemfile
|
39
36
|
- LICENSE.txt
|
40
37
|
- README.md
|
@@ -45,27 +42,25 @@ files:
|
|
45
42
|
- middleman-gh-pages.gemspec
|
46
43
|
homepage: http://github.com/newcontext/middleman-gh-pages
|
47
44
|
licenses: []
|
45
|
+
metadata: {}
|
48
46
|
post_install_message:
|
49
47
|
rdoc_options: []
|
50
48
|
require_paths:
|
51
49
|
- lib
|
52
50
|
required_ruby_version: !ruby/object:Gem::Requirement
|
53
|
-
none: false
|
54
51
|
requirements:
|
55
|
-
- -
|
52
|
+
- - ">="
|
56
53
|
- !ruby/object:Gem::Version
|
57
54
|
version: '0'
|
58
55
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
59
|
-
none: false
|
60
56
|
requirements:
|
61
|
-
- -
|
57
|
+
- - ">="
|
62
58
|
- !ruby/object:Gem::Version
|
63
59
|
version: '0'
|
64
60
|
requirements: []
|
65
61
|
rubyforge_project:
|
66
|
-
rubygems_version:
|
62
|
+
rubygems_version: 2.5.2
|
67
63
|
signing_key:
|
68
|
-
specification_version:
|
64
|
+
specification_version: 4
|
69
65
|
summary: Easy deployment of Middleman sites to Github Pages
|
70
66
|
test_files: []
|
71
|
-
has_rdoc:
|