forked from tuna/thuthesis
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.lua
88 lines (72 loc) · 2.47 KB
/
build.lua
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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
#!/usr/bin/env texlua
module = "thuthesis"
supportdir = "./testfiles/support-main"
checksuppfiles = {"fontset.tex"}
demofiles = {"latexmkrc", "Makefile"}
docfiles = {
"CHANGELOG.md",
"thusetup.tex", "math_commands.tex",
"data", "figures", "ref",
}
installfiles = {"*.cls", "*.bst", "tsinghua-name-bachelor.pdf"}
sourcefiles = {"*.dtx", "*.ins", "*.bst", "tsinghua-name-bachelor.pdf"}
tagfiles = {"*.dtx", "CHANGELOG.md", "package.json"}
textfiles = {"*.md","LICENSE"}
typesetdemofiles = {"thuthesis-example.tex", "spine.tex"}
checkengines = {"xetex"}
stdengine = "xetex"
checkconfigs = {
"build",
"testfiles/config-cover",
"testfiles/config-nomencl",
"testfiles/config-bib",
}
-- include .tds.zip in build output
packtdszip = true
-- specify some files of their correct TDS locations
tdslocations = {
"bibtex/bst/thuthesis/*.bst",
"tex/latex/thuthesis/tsinghua-name-bachelor.pdf",
}
typesetexe = "xelatex"
unpackexe = "xetex"
checkopts = "-file-line-error -halt-on-error -interaction=nonstopmode"
typesetopts = "-shell-escape -file-line-error -halt-on-error -interaction=nonstopmode"
lvtext = ".tex"
function docinit_hook()
for _, file in pairs({"dtx-style.sty"}) do
cp(file, unpackdir, typesetdir)
end
return 0
end
function update_tag(file, content, tagname, tagdate)
local url = "https://github.com/tuna/thuthesis"
local date = string.gsub(tagdate, "%-", "/")
if string.match(file, "%.dtx$") then
if string.match(content, "%d%d%d%d/%d%d/%d%d [0-9.]+") then
content = string.gsub(content, "%d%d%d%d/%d%d/%d%d [0-9.]+",
date .. " " .. tagname)
end
if string.match(content, "\\def\\version{[0-9.]+}") then
content = string.gsub(content, "\\def\\version{[0-9.]+}",
"\\def\\version{" .. tagname .. "}")
end
elseif string.match(file, "CHANGELOG.md") then
local previous = string.match(content, "/compare/(.*)%.%.%.HEAD")
local gittag = 'v' .. tagname
if gittag == previous then return content end
content = string.gsub(content,
"## %[Unreleased%]",
"## [Unreleased]\n\n## [" .. gittag .."] - " .. tagdate)
content = string.gsub(content,
previous .. "%.%.%.HEAD",
gittag .. "...HEAD\n" ..
string.format("%-14s", "[" .. gittag .. "]:") .. url .. "/compare/"
.. previous .. "..." .. gittag)
elseif string.match(file, "package.json") then
content = string.gsub(content,
"\"version\": \"[0-9.]+\"",
"\"version\": \"" .. tagname .. "\"")
end
return content
end