-
Notifications
You must be signed in to change notification settings - Fork 16
Expand file tree
/
Copy pathbuild.lua
More file actions
147 lines (129 loc) · 5.19 KB
/
build.lua
File metadata and controls
147 lines (129 loc) · 5.19 KB
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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
#!/usr/bin/env texlua
--[[
Build script for the LaTeX-ZUGFeRD project
Copyright (C) 2024 Marei Peischl <marei@peitex.de>
This file is part of the build system of the zugferd package.
It may be distributed and/or modified under the conditions of the
LaTeX Project Public License (LPPL), either version 1.3c of this
license or (at your option) any later version. The latest version
of this license is in the file
https://www.latex-project.org/lppl.txt
]]
module="zugferd"
-- allow to tag the build.lua file
if options["target"] == "tag" then
excludefiles={"*~"}
end
packageversion = "0.10"
packagedate = "2025-09-22"
sourcefiles={"*.dtx","*.ins", "*.sty"}
demofiles={"*.tex"}
-- demofiles should be typeset for testing but not for the ctan upload
if options["target"] == "ctan" then
typesetcmds="\\def\\DoNotTypesetImplementation{don't typeset implementation for CTAN}"
else
typesetdemofiles={"*.tex"}
end
typesetexe="lualatex"
typesetopts=""
supportdir="support"
checksuppfiles={"validate_zugferd.sh","Mustang-CLI*.jar","zugferd-test.ltx"}
checkconfigs = {"build"}
-- checkconfigs = {"build", "config-pdf"} -- pdf config is only checked on release
recordstatus=true
ctanreadme="README_CTAN.md"
function get_dev_tag (oldtag)
if string.match(oldtag, "%-dev$") then
return (oldtag), true
end
newtag=string.gsub(oldtag,"v?(%d+).%d+%-?%w*%s?","%1.")..string.format("%02d",math.floor(string.gsub(oldtag,"v?%d+.(%d+)%-?%w*%s?","%1") + 1))
return newtag.."-dev",false
end
--[[
# Tagging configuration
]]
tagfiles = {"*.dtx","*.sty", "*.md", "*.tex","*.lua"}
function update_tag(file, content, tagname, tagdate)
local versionpattern = "%d+.%d+%-?%w*"
local datepattern = "%d%d%d%d%-%d%d%-%d%d"
local tag_only_changes = false
local old_tagpattern = ""
local tagname = tagname or packageversion
if tagname == "dev" or string.match(tagname, "%-dev$") then
tagname, tag_only_changes = get_dev_tag(packageversion)
else
-- when a new tag is set all \changes{<old-dev-tag>} should be replaced as well
old_tagpattern = string.gsub(packageversion, "%.", "%%.")
old_tagpattern = string.gsub(old_tagpattern, "%-", "%%-")
end
-- Copyright (C) 2018–2025 by uploadconfig["author"]>
-- maybe change to -- instead of –
content = string.gsub(content, "(Copyright %(C%) 20%d%d)%-*%d%d%d%d by " ..
uploadconfig["author"], "%1--" .. os.date("%Y") ..
" by " .. uploadconfig["author"])
-- tagging \changes
if file ~= "build.lua" then
content = string.gsub(content, "\\changes{v?0*%.0*}{" .. datepattern,
"\\changes{v" .. tagname .. "}{" .. tagdate)
content = string.gsub(content, "\\changes{version}{date",
"\\changes{v" .. tagname .. "}{" .. tagdate)
end
-- don't tag fileversion to not change all dates
if tag_only_changes then return content end
if string.match(file, "%.md$") or string.match(file, "%.tex$") then
content = string.gsub(content,
"([Vv]ersion%s)"..versionpattern.."%s%("..datepattern.."%)",
"%1"..tagname.." ("..tagdate..")")
elseif file == "build.lua" then
content = string.gsub(content,"(packageversion%s*=%s*\")"..versionpattern, "%1"..tagname)
content = string.gsub(content,"(packagedate%s*=%s*\")"..datepattern, "%1"..tagdate)
else
content = string.gsub(content,
"(\\Provides%a-{[^\n]-}%[)"..datepattern.."%s-v"..versionpattern,
"%1"..tagdate.." v"..tagname)
content = string.gsub(content,
"(\\ProvidesExpl%a-{[^\n]-}){[^\n]-}{[^\n]-}",
"%1{".. tagdate.."}{"..tagname .. "}")
content = string.gsub(content,
"(\\usepackage{"..module.."}%[)"..datepattern.."%]",
"%1"..tagdate.."]")
content = string.gsub(content,
"\\changes{v" .. tagname .. "(%-dev)?}{" ..
datepattern,
"\\changes{v" .. tagname .. "}{" .. tagdate)
content = string.gsub(content,"(%%<%*[^\n]+\n%s+%[)"..
datepattern .. "%s-v" .. versionpattern,
"%1" .. tagdate .. " " .. tagname)
end
content = string.gsub (content,
"(Copyright %(C%) 202%d%–)%d%d%d%d",
"%1"..os.date("%Y"))
return content
end
github_base_url="https://github.com/TeXhackse/LaTeX-ZUGFeRD"
gitlab_base_url="https://gitlab.com/islandoftex/texmf/"..module
ctanpkg=module
uploadconfig = {
author = "Marei Peischl",
uploader = "Marei Peischl",
description="This package provides interfaces to allow creating ZUGFeRD or Faktur-X invoices with LaTeX including the XML file. It can be used to modify personal invoicing templates to fulfil the requirements for digital invoicing without further modification of the invoicing processes.",
pkg = ctanpkg,
version = packageversion .. " " .. packagedate,
license = "lppl1.3c",
summary = "ZUGFeRD and Faktur-X invoicing using LaTeX",
ctanPath = "/macros/latex/contrib/" .. ctanpkg,
repository = {gitlab_base_url..".git",github_base_url..".git"},
bugtracker = {gitlab_base_url.."/issues",github_base_url.."/issues"},
support = {gitlab_base_url.."/issues",github_base_url.."/issues"},
announcement_file = "ctan.ann",
update = true,
topic = "invoice",
note_file = "ctan.note"
}
function runtest_tasks ( name , run )
if run == checkruns and options["target"] == "save" and name ~= "lostchars" then
return "./validate_zugferd.sh " .. name
else
return ""
end
end