-
Notifications
You must be signed in to change notification settings - Fork 28
/
Makefile
53 lines (44 loc) · 2.08 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
SERVER ?= api.annhe.net
USER ?= root
PORT ?= 22
DIR ?= /PanBook
HIGHLIGHT ?= --highlight-style=tango
DEBUG ?=
OWNER ?= annProg
REPO ?= PanBook
TAG ?= $(shell git rev-parse --short HEAD)
DIVISION = --top-level-division=chapter
CJK ?= -V CJKmainfont:思源宋体 -V CJKoptions:BoldFont=Source\ Han\ Serif\ SC\ Heavy,ItalicFont=FandolKai,SmallCapsFont=思源黑体
MAINFONT ?= -V mainfont:Source\ Serif\ Pro
SANSFONT ?= -V sansfont:Source\ Sans\ Pro
CODEFONT ?= -V monofont:Source\ Code\ Pro
all: ctex ctex6in elegantbook epub online
book: ctex ctex6in elegantbook
ctex:
panbook book -V cover:R $(DIVISION) $(CJK) $(DEBUG) $(HIGHLIGHT) $(MAINFONT) $(SANSFONT) $(CODEFONT)
ctex6in:
panbook book -V cover:R -V device:mobile $(DIVISION) $(CJK) $(DEBUG) $(HIGHLIGHT) $(MAINFONT) $(SANSFONT) $(CODEFONT)
elegantbook:
panbook book --style=elegantbook $(DIVISION) $(CJK) $(DEBUG) $(HIGHLIGHT) $(MAINFONT) $(SANSFONT) $(CODEFONT)
epub:
rm -f build/*.epub
panbook book --style=epub $(DEBUG) $(HIGHLIGHT)
ls -l build/
mv build/$(REPO)-*.epub build/$(REPO).epub
up: release upload
release:
git tag -a $(TAG) -m "$(TAG)"
git push origin $(TAG)
curl -H "Content-Type:application/json" -H "Authorization: token $$GITHUB_TOKEN" -XPOST "https://api.github.com/repos/$(OWNER)/$(REPO)/releases" -d '{"tag_name":"$(TAG)"}'
upload:
ID=`curl -s -H "Authorization: token $$GITHUB_TOKEN" "https://api.github.com/repos/$(OWNER)/$(REPO)/releases/tags/$(TAG)" |grep '"id"' |head -n 1 |awk '{print $$2}' |tr -d ','`; echo "ID: $$ID";\
cd build/; \
for FILE in `ls $(REPO)-*.pdf` $(REPO).epub;do \
echo $$FILE;\
curl -H "Authorization: token $$GITHUB_TOKEN" -H "Content-Type: $$(file -b --mime-type $$FILE)" "https://uploads.github.com/repos/$(OWNER)/$(REPO)/releases/$$ID/assets?name=$$(basename $$FILE)" --data-binary @$$FILE; echo; \
done
online:
scp -P $(PORT) build/$(REPO)-book-*.pdf $(USER)@$(SERVER):$(DIR)
scp -P $(PORT) build/$(REPO).epub $(USER)@$(SERVER):$(DIR)
aliyun:
cat Dockerfile |sed '/^FROM alpine/a\RUN sed -i "s/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g" /etc/apk/repositories' > Dockerfile.aliyun