|
| 1 | +#!/usr/bin/env texlua |
| 2 | +-- Execute with ====================================================== |
| 3 | +-- l3build tag |
| 4 | +-- l3build ctan |
| 5 | +-- l3build upload |
| 6 | +-- l3build clean |
| 7 | + |
| 8 | +-- Settings ========================================================== |
| 9 | +module = "beamertheme-tcolorbox" |
| 10 | +ctanpkg = "beamertheme-tcolorbox" |
| 11 | +builddir = os.getenv("TMPDIR") |
| 12 | + |
| 13 | +-- Private settings ================================================== |
| 14 | +local ok, build_private = pcall(require, "build-private.lua") |
| 15 | + |
| 16 | +-- Package version =================================================== |
| 17 | +if ok then |
| 18 | + local handle = io.popen("git describe --tags $(git rev-list --tags --max-count=1)") |
| 19 | + local oldtag = handle:read("*a") |
| 20 | + handle:close() |
| 21 | + newsubtag = string.sub(oldtag, 4) |
| 22 | + newmajortag = string.sub(oldtag, 0, 3) |
| 23 | + previousversion = newmajortag .. math.floor(newsubtag) |
| 24 | + if ( options["target"] == "tag") then |
| 25 | + newsubtag = newsubtag + 1 |
| 26 | + end |
| 27 | + packageversion = newmajortag .. math.floor(newsubtag) |
| 28 | +else |
| 29 | + packageversion="v1.42" |
| 30 | +end |
| 31 | + |
| 32 | +-- Package date ====================================================== |
| 33 | +packagedate = os.date("!%Y-%m-%d") |
| 34 | +--packagedate = "2020-01-02" |
| 35 | + |
| 36 | +-- interacting with git ============================================== |
| 37 | +function git(...) |
| 38 | + local args = {...} |
| 39 | + table.insert(args, 1, 'git') |
| 40 | + local cmd = table.concat(args, ' ') |
| 41 | + print('Executing:', cmd) |
| 42 | + os.execute(cmd) |
| 43 | +end |
| 44 | + |
| 45 | +-- replace version tags in .sty and -doc.tex files =================== |
| 46 | +tagfiles = {"*.sty", "*-doc.tex", "README.md", "CHANGELOG.md"} |
| 47 | +function update_tag (file,content,tagname,tagdate) |
| 48 | + tagdate = string.gsub (packagedate,"-", "/") |
| 49 | + if string.match (file, "%.sty$" ) then |
| 50 | + content = string.gsub ( |
| 51 | + content, |
| 52 | + "\\ProvidesPackage{(.-)}%[%d%d%d%d%/%d%d%/%d%d version v%d%.%d+", |
| 53 | + "\\ProvidesPackage{%1}[" .. tagdate.." version "..packageversion |
| 54 | + ) |
| 55 | + return content |
| 56 | + elseif string.match (file, "*-doc.tex$" ) then |
| 57 | + content = string.gsub ( |
| 58 | + content, |
| 59 | + "\\date{Version v%d%.%d+ \\textendash{} %d%d%d%d%/%d%d%/%d%d", |
| 60 | + "\\date{Version " .. packageversion .. " \\textendash{} " .. tagdate |
| 61 | + ) |
| 62 | + return content |
| 63 | + elseif string.match (file, "README.md$" ) then |
| 64 | + content = string.gsub ( |
| 65 | + content, |
| 66 | + "Current version: %d%d%d%d%/%d%d%/%d%d version v%d%.%d+", |
| 67 | + "Current version: " .. tagdate.." version "..packageversion |
| 68 | + ) |
| 69 | + return content |
| 70 | + elseif string.match (file, "CHANGELOG.md$" ) then |
| 71 | + local url = "https://github.com/samcarter/" .. module .. "/compare/" |
| 72 | + local previous = string.match(content,"compare/(v%d%.%d)%.%.%.HEAD") |
| 73 | + |
| 74 | + -- copying current changelong to announcement.txt |
| 75 | + -- finding start and end in changelog |
| 76 | + i, startstring = string.find(content, "## %[Unreleased%]") |
| 77 | + stopstring, i = string.find(content, "## %[" .. previousversion .. "%]") |
| 78 | + -- opening file and writing substring |
| 79 | + file = io.open("announcement.txt", "w") |
| 80 | + file:write(string.sub(content, startstring+3, stopstring-1), "\n") |
| 81 | + file:close() |
| 82 | + |
| 83 | + -- adding new unreleased heading at the top |
| 84 | + content = string.gsub ( |
| 85 | + content, |
| 86 | + "## %[Unreleased%]", |
| 87 | + "## [Unreleased]\n\n### New\n\n### Changed\n\n### Fixed\n\n\n## [" .. packageversion .."]" |
| 88 | + ) |
| 89 | + |
| 90 | + -- adding new link at bottom |
| 91 | + content = string.gsub ( |
| 92 | + content, |
| 93 | + "v%d.%d%.%.%.HEAD", |
| 94 | + packageversion .. "...HEAD\n[" .. packageversion .. "]: " .. url .. previousversion .. "..." .. packageversion |
| 95 | + ) |
| 96 | + return content |
| 97 | + end |
| 98 | + return content |
| 99 | +end |
| 100 | + |
| 101 | +-- committing retagged file and tag the commit ======================= |
| 102 | +function tag_hook(tagname) |
| 103 | + git("add", "*.sty") |
| 104 | + git("add", "*-doc.tex") |
| 105 | + git("add", "README.md") |
| 106 | + git("add", "CHANGELOG.md") |
| 107 | + os.execute("latexmk " .. module .. "-doc") |
| 108 | + os.execute("cp " .. module .. "-doc.pdf documentation.pdf") |
| 109 | + git("add", "documentation.pdf") |
| 110 | + git("commit -m 'step version ", packageversion, "'" ) |
| 111 | + git("tag", packageversion) |
| 112 | +end |
| 113 | + |
| 114 | +-- collecting files for ctan ========================================= |
| 115 | +docfiles = {"*-doc.tex"} |
| 116 | +textfiles= {"README.md"} |
| 117 | +ctanreadme= "README.md" |
| 118 | +packtdszip = false |
| 119 | +installfiles = {"*.sty"} |
| 120 | +sourcefiles = {"*.sty"} |
| 121 | +excludefiles = {"documentation.pdf","test.pdf"} |
| 122 | + |
| 123 | +-- configuring ctan upload =========================================== |
| 124 | +if not ok then |
| 125 | + uploadconfig = uploadconfig or {} |
| 126 | + uploadconfig.author = "xxx" |
| 127 | + uploadconfig.uploader = "xxx" |
| 128 | + uploadconfig.email = "xxx" |
| 129 | +end |
| 130 | + |
| 131 | +uploadconfig = { |
| 132 | + author = uploadconfig.author, |
| 133 | + uploader = uploadconfig.uploader, |
| 134 | + email = uploadconfig.email, |
| 135 | + pkg = ctanpkg, |
| 136 | + version = packageversion .. " " .. packagedate, |
| 137 | + license = "lppl1.3c", |
| 138 | + summary = "A beamer inner theme which reproduces standard beamer blocks using tcolorboxes", |
| 139 | + ctanPath = "/graphics/pgf/contrib/" .. ctanpkg, |
| 140 | + repository = "https://github.com/samcarter/" .. module, |
| 141 | + note = [[Uploaded automatically by l3build...]], |
| 142 | + bugtracker = "https://github.com/samcarter/" .. module .. "/issues", |
| 143 | + support = "https://github.com/samcarter/" .. module .. "/issues", |
| 144 | + announcement_file = "announcement.txt" |
| 145 | +} |
| 146 | + |
| 147 | +-- cleanup =========================================================== |
| 148 | +cleanfiles = {"beamertheme-tcolorbox-ctan.curlopt", "beamertheme-tcolorbox-ctan.zip"} |
0 commit comments