-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
50 lines (41 loc) · 1.7 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
PDFS := $(wildcard mespubli/pdf/*.pdf)
LINKS := $(patsubst mespubli/%,%,$(PDFS))
.PHONY: build rebuild watch
build: stack_build update_pdf_links
stack exec site -- $@
rebuild: stack_build update_pdf_links
stack exec site -- $@
watch: stack_build
stack exec site -- $@
.PHONY: stack_build
stack_build:
stack build
.PHONY: update_pdf_links
update_pdf_links: $(LINKS)
%.pdf:
cd pdf && ln -s ../mespubli/pdf/$(shell basename $@) .
deploy: check-upstream git-clean-status rebuild
rsync -avr --delete --exclude='.git' _site/ site/
cd site \
&& git checkout master \
&& git add . \
&& GIT_AUTHOR_EMAIL='[email protected]' git commit -m 'site update' \
&& git push --recurse-submodules=check origin master
git add site
git commit -m 'site update'
git push origin master
git push github master
check-upstream:
# dependency to the build rule 'git-clean-status': abort if we are in a dirty state. Do this a first time before updating submodules: the update way take a few seconds and we want to abort quickly if need be.
# Check that we are either up to date, or ahead of the default
# upstream branch, and merge if need be.
git submodule update --recursive --remote --merge
.PHONY: check-upstream
git-clean-status:
# MAYBE This is fragile! Any better options for making sure
# that we are up to date or ahead of upstream?
LANG=C git status --porcelain --untracked-files=no --ignore-submodules=untracked | wc -l | grep -q -e '0' || (git status --untracked-files=no --ignore-submodules=untracked; echo "\n\nERROR. The repository is in a dirty state.\nPlease commit changes and delete all untracked changes."; return 1)
.PHONY: git-clean-status
debug:
@echo $(LINKS)
@echo $(PDFS)