-
Notifications
You must be signed in to change notification settings - Fork 4
/
build.lua
96 lines (83 loc) · 3.13 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
89
90
91
92
93
94
95
96
#!/usr/bin/env texlua
-- Execute with ======================================================
-- l3build tag
-- l3build ctan
-- l3build upload
-- l3build clean
-- Settings ==========================================================
bundle = ""
module = "fancyqr"
ctanpkg = module
builddir = os.getenv("TMPDIR")
-- Package date ======================================================
packagedate = os.date("!%Y-%m-%d")
-- interacting with git ==============================================
function git(...)
local args = {...}
table.insert(args, 1, 'git')
local cmd = table.concat(args, ' ')
print('Executing:', cmd)
os.execute(cmd)
end
-- replace version tags in .sty and -doc.tex files ===================
tagfiles = {"*.sty", "*-doc.tex"}
function update_tag(file, content, tagname, tagdate)
tagdate = string.gsub(packagedate, "-", "/")
if string.match(file, "%.sty$") then
content = string.gsub(content, "\\ProvidesPackage{(.-)}%[%d%d%d%d%/%d%d%/%d%d version v%d%.%d+",
"\\ProvidesPackage{%1}[" .. tagdate .. " version " .. tagname)
return content
elseif string.match(file, "*-doc.tex$") then
content = string.gsub(content, "\\date{Version v%d%.%d+ \\textendash\\ %d%d%d%d%/%d%d%/%d%d",
"\\date{Version " .. tagname .. " \\textendash{} " .. tagdate)
return content
end
return content
end
-- committing retagged file and tag the commit =======================
require('build-private.lua')
function tag_hook(tagname)
-- fail if tagname is missing
if not tagname then
print("No tagname provided, please use 'l3build tag <tagname>'")
return
end
-- fail if tag already exists locally
if os.execute("git rev-parse " .. tagname) == 0 then
print("Tag '" .. tagname .. "' already exists locally")
return
end
-- update the tag first
for _, file in ipairs(tagfiles) do
for _, file in ipairs(filelist(file)) do
local content = update_tag(file, readfile(file), tagname)
writefile(file, content)
end
end
git("add", "*.sty")
git("add", "*-doc.tex")
os.execute("github_changelog_generator --user EagleoutIce --future-release \"" .. tagname .. "\" --project \"" .. module .. "\" --token \"" .. token .. "\"")
git("add", "CHANGELOG.md")
git("status")
-- ask for verification if the tag is correct and all is updated correctly
print("Please verify the changes and commit the changes with the tag '" .. tagname .. "'")
print("Press any key to continue...")
io.read()
git("commit -S -m 'step version " .. tagname .. "'")
git("tag", tagname)
git("push", "--tags")
git("push")
end
-- collecting files for ctan =========================================
typesetfiles = { module .. "-doc.tex" }
textfiles = {"README.md"}
ctanreadme = "README.md"
installfiles = {"*.sty", "*.tex", "*.code"}
sourcefiles = installfiles
unpackfiles = {}
-- Release a TDS-style zip
packtdszip = false
-- Preserve structure for CTAN
flatten = true
-- cleanup ===========================================================
cleanfiles = { module .. "-ctan.curlopt", module .. "-ctan.zip"}