-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMakefile
59 lines (48 loc) · 1.37 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
SITE_FOLDER=_site
GIT_REV:=$(shell git rev-parse --verify HEAD)
GH_PAGES_BRANCH=gh-pages
GH_PAGES_DIR=gh-pages
all: clean test
.PHONY: build_nix
build_nix:
nix build .#website
.PHONY: build
build:
nix run . -- build
.PHONY: test
test: build
nix run . -- check
.PHONY: clean
clean:
nix run . -- clean
rm -f result
@# this is hacky, just to get things working. I need to think about all the
@# edge cases
git worktree prune
git worktree list --porcelain | rg $(GH_PAGES_BRANCH) | rg "^worktree " | cut -d' ' -f2 | xargs --no-run-if-empty -tI@ -- git worktree remove --force @
rm -rf $(GH_PAGES_DIR)
.PHONY: server
server: build
nix run . -- server
.PHONY: watch
watch: build
nix run . -- watch
.PHONY: develop
develop:
make develop
.PHONY: watch-external
watch-external: build
$(SITE_EXE) watch --host '0.0.0.0' --port '8822'
# hacks be below
.PHONY: gh-pages
gh-pages: clean build
git fetch
git branch --delete --force $(GH_PAGES_BRANCH) || true # if branch doesn't exist locally
git worktree add ./$(GH_PAGES_DIR) $(GH_PAGES_BRANCH)
cd $(GH_PAGES_DIR) && git ls-files | xargs -tI@ -- rm -r @
cd $(GH_PAGES_DIR) && fd --type=directory | xargs --no-run-if-empty -I@ -- rm -rf @
cp -ar $(SITE_FOLDER)/. $(GH_PAGES_DIR)
cd $(GH_PAGES_DIR) && git add --all && git commit -m "Built from $(GIT_REV)" && git show
.PHONY: deploy
deploy: gh-pages
cd $(GH_PAGES_DIR) && git push