forked from latex3/fontspec
-
Notifications
You must be signed in to change notification settings - Fork 0
/
autorelease.lua
executable file
·175 lines (137 loc) · 4.46 KB
/
autorelease.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
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
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
#!/usr/bin/env texlua
--[==========================================[--
AUTOMATON for performing CTAN releases
======================================
* Save the `main` branch for releases only; this allows hotfixes to releases to be
organised easily with a minimal number of branches to keep things simple.
* Changes over time go into the `develop` branch.
* Records of changes which deserve to be included in the release notes should be added
CHANGES.md. Follow the formatting of the file.
* The topmost entry of CHANGES.md is used to populate the new version number
(but the date will be updated automatically by the build script).
* The topmost entry of the CHANGES.md file is extracted and used in the git tagging
and in the CTAN release notes.
* To commence a release, be in the `develop` branch, fully committed.
* This file will query a couple of times to make sure all is well.
* If so, it sends the package off to CTAN and the `main` branch is rebased and tagged.
* TODO: add Github release zip file as well.
--]==========================================]--
--[=============[--
FUNCTIONS
--]=============]--
function os.capture(cmd, raw)
local f = assert(io.popen(cmd, 'r'))
local s = assert(f:read('*a'))
f:close()
if raw then return s end
s = string.gsub(s, '^%s+', '')
s = string.gsub(s, '%s+$', '')
s = string.gsub(s, '[\n\r]+', ' ')
return s
end
function exe(s)
print('=====================')
print('> '..s..'\n')
local e = os.execute(s)
if not(e) then
error("EXECUTION FAILED: ABORT")
end
end
function usercheck()
print("\nHappy? [y/n]")
ans = io.read()
if not(string.lower(ans,1,1)=="y") then
error("USER ABORTED")
end
end
--[==================[--
INITIAL CHECKS
--]==================]--
reqbranch = "develop"
gitbranch = os.capture('git symbolic-ref --short HEAD')
if gitbranch ~= reqbranch then
print("Current git branch: "..gitbranch)
error("You must be on the '"..reqbranch.."' branch")
else
print("Current git branch: "..gitbranch.." ... correct!")
end
gitstatus = os.capture('git status --porcelain')
if gitstatus ~= "" then
error("Files have been edited; please commit all changes.")
end
--[=========================[--
MOVE TO MAIN BRANCH
--]=========================]--
exe("git fetch")
aheadmaybe = os.capture('git branch -vv | grep `git symbolic-ref --short HEAD` | grep ahead')
if aheadmaybe ~= "" then
exe("git push")
end
exe("git checkout main")
exe("git pull")
exe("git rebase develop")
--[=====================[--
CLEAN UP
--]=====================]--
gitclean = os.capture('git clean -nx')
if gitclean ~= "" then
print("Before we start, the following files are about to be deleted. Please check.")
exe('git clean -nx')
usercheck()
end
exe("git clean -fx")
--[===============[--
UPDATE DATE
--]===============]--
exe("l3build tag")
gitstatus = os.capture('git status --porcelain')
if gitstatus ~= "" then
exe([===[
git commit -a -m 'update package info for release';
]===])
end
--[=====================[--
START THE RELEASE
--]=====================]--
changeslisting = nil
do
local f = assert(io.open("doc/CHANGES.md", "r"))
changeslisting = f:read("*all")
f:close()
end
currentchanges = string.match(changeslisting,"(## %S+ %(.-%).-)%s*## %S+ %(.-%)")
if string.len(currentchanges) > 8192 then
local trunctext = "[...and more; see package for full details.]"
currentchanges = string.sub(currentchanges,1,8192-string.len(trunctext)-1) .. trunctext
end
print("***************************")
print(" CURRENT CHANGES ")
print("***************************")
print(currentchanges)
print("***************************")
pkgversion = string.match(currentchanges,"## (%S+) %(.-%)")
print(' New version: '..pkgversion)
oldversion = os.capture('git describe $(git rev-list --tags --max-count=1)')
print('Most recent tag: '..oldversion)
usercheck()
--[=================[--
BUILD and TAG
--]=================]--
exe("l3build ctan")
do
local f = assert(io.open("CHANGES-NEW.md", "w"))
f:write(currentchanges)
f:close()
end
exe("git tag -a '"..pkgversion.."' -F CHANGES-NEW.md")
--[=======================[--
UPLOAD and CLEAN UP
--]=======================]--
exe("l3build upload --file CHANGES-NEW.md")
exe("rm CHANGES-NEW.md")
exe("git push")
exe("git checkout develop")
exe("git rebase main")
exe("git push")
exe("rm fontspec-ctan.curlopt")
print("Great success! Now time to fix some more bugs.")