summaryrefslogtreecommitdiff
path: root/Makefile
blob: e7428d181d83ef7d5bc8d6e5567132b08385dbd2 (plain) (blame)
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
.PHONY: clean
clean:
	hugo --cleanDestinationDir

.PHONY: server
server: clean
	hugo serve --buildDrafts --buildFuture

.PHONY: deps
deps:
	brew install hugo

.PHONY: build
build: clean
	hugo

DEPLOY_BRANCH := master
DEPLOY_DIR := public

.PHONY: publish
publish: build
	git symbolic-ref HEAD refs/heads/$(DEPLOY_BRANCH)
	git --work-tree $(DEPLOY_DIR) reset --mixed --quiet
	git --work-tree $(DEPLOY_DIR) add --all
	if git --work-tree $(DEPLOY_DIR) diff-index --quiet HEAD -- ; then \
	  echo "no changes" ; \
	else \
	  git --work-tree $(DEPLOY_DIR) commit -m "deploy " ; \
	  git push origin $(DEPLOY_BRANCH) ; \
	fi

	git symbolic-ref HEAD refs/heads/posts
	git reset --mixed
	[ -d $(DEPLOY_DIR) ] && rm -rf $(DEPLOY_DIR)