-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
124 lines (101 loc) · 3.22 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
SHELL = /bin/bash
JEKYLL_ARGS ?=
JEKYLL_DEST ?= public
JEKYLL_ENV ?= production
COMPASS_ARGS = -e $(JEKYLL_ENV) --sass-dir site/css --css-dir $(JEKYLL_DEST)/css --images-dir img --javascripts-dir js --relative-assets
WATCH_EVENTS = create delete modify move
WATCH_DIRS = site
GHP_REMOTE = [email protected]:scampersand/scampersand.github.io
NEXT_DEPLOY_DEST = [email protected]:next.scampersand.com/
DREAM_DEPLOY_DEST = [email protected]:scampersand.com/
VAGRANT_MAKE = vagrant ssh -- -t make -C /vagrant
export JEKYLL_ENV
default: help
######################################################################
ifeq ($(shell whoami), vagrant)
build:
[[ $(JEKYLL_ENV) != production ]] || $(MAKE) clean
$(MAKE) jekyll
$(MAKE) sass
[[ $(JEKYLL_ENV) != production ]] || ./post-process.bash
jekyll:
jekyll build -d $(JEKYLL_DEST) $(JEKYLL_ARGS)
sass:
compass compile $(COMPASS_ARGS)
watch:
trap exit 2; \
while true; do \
$(MAKE) build; \
date > .sync; \
inotifywait $(WATCH_EVENTS:%=-e %) --exclude '/\.' -r $(WATCH_DIRS); \
done
serve:
# jekyll serve -d $(JEKYLL_DEST) --no-watch --skip-initial-build --host 0 --port 8000
cd $(JEKYLL_DEST) && \
browser-sync start -s --port 8000 --files ../.sync --no-notify --no-open --no-ui
sync_serve:
while [[ ! -e .sync ]]; do sleep 0.1; done
$(MAKE) serve
draft: export JEKYLL_ARGS += --drafts
draft dev: export JEKYLL_ENV = development
draft dev: export JEKYLL_DEST = dev
draft dev:
rm -f .sync
$(MAKE) -j2 watch sync_serve
clean:
if [[ -e $(JEKYLL_DEST)/.git ]]; then \
tmp=$$(mktemp -d clean.XXXXXX) && \
mv -T $(JEKYLL_DEST) $$tmp && \
mkdir $(JEKYLL_DEST) && \
mv $$tmp/.git $(JEKYLL_DEST) && \
rm -rf $$tmp; \
else \
rm -rf $(JEKYLL_DEST); \
fi
next deploy:
@echo >&2
@echo "#########################################" >&2
@echo "# Please make $@ outside of vagrant" >&2
@echo "#########################################" >&2
@echo >&2
@exit 1
######################################################################
else
build draft dev: up
$(VAGRANT_MAKE) $@
up:
vagrant status | grep -q '^default *running' || vagrant up
next: build
$(MAKE) _deploy_next
deploy: build
$(MAKE) _deploy_dream
$(MAKE) _deploy_ghp
_deploy_next:
echo 'Disallow: /' >> $(JEKYLL_DEST)/robots.txt
rsync -az --exclude=.git --delete-before $(JEKYLL_DEST)/. $(NEXT_DEPLOY_DEST)
_deploy_dream:
rsync -az --exclude=.git --delete-before $(JEKYLL_DEST)/. $(DREAM_DEPLOY_DEST)
_deploy_ghp:
cd $(JEKYLL_DEST) && \
if [[ ! -d .git ]]; then \
git init && \
git remote add origin $(GHP_REMOTE); \
fi && \
git fetch --depth=1 origin master && \
git reset origin/master && \
git add -A && \
if git status --porcelain | grep -q .; then \
git commit -m deploy; \
fi && \
git branch -u origin/master && \
git push
endif
######################################################################
help:
@echo >&2
@echo "#########################################" >&2
@echo "# Target required (hint: dev or deploy)" >&2
@echo "#########################################" >&2
@echo >&2
.PHONY: _deploy_dream _deploy_ghp _deploy_next build clean default deploy \
dev draft help jekyll next sass serve sync_serve up watch