generated from noahgift/rust-new-project-template
-
Notifications
You must be signed in to change notification settings - Fork 12
/
Makefile
50 lines (39 loc) · 1.18 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
install:
cargo install mdbook
build:
mdbook build small-rust-tutorial
serve:
mdbook serve -p 8000 -n 127.0.0.1 small-rust-tutorial
format:
cargo fmt --quiet
lint:
cargo clippy --quiet
test:
cargo test --quiet
linkcheck:
mdbook test -L small-rust-tutorial
run:
cargo run
release:
cargo build --release
deploy:
#if git is not configured, configure it
if [ -z "$(git config --global user.email)" ]; then git config --global user.email "noah.gift@gmail.com" &&\
git config --global user.name "Noah Gift"; fi
#install mdbook if not installed
if [ ! -x "$(command -v mdbook)" ]; then cargo install mdbook; fi
@echo "====> deploying to github"
# if worktree exists, remove it: git worktree remove --force /tmp/book
# otherwise add it: git worktree add /tmp/book gh-pages
if [ -d /tmp/book ]; then git worktree remove --force /tmp/book; fi
git worktree add -f /tmp/book gh-pages
mdbook build small-rust-tutorial
rm -rf /tmp/book/*
cp -rp small-rust-tutorial/book/* /tmp/book/
cd /tmp/book && \
git add -A && \
git commit -m "deployed on $(shell date) by ${USER}" && \
git push origin gh-pages
git update-ref -d refs/heads/gh-pages
git push --force
all: format lint test run