-
Notifications
You must be signed in to change notification settings - Fork 29
/
autorelease.lua
executable file
·139 lines (109 loc) · 2.99 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
#!/usr/bin/env texlua
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 e > 0 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
gitbranch = os.capture('git symbolic-ref --short HEAD')
if gitbranch ~= "working" then
print("Current git branch: "..gitbranch)
error("You must be on the 'working' 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
--[=========[
START
--]=========]
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 master")
exe("git pull")
exe("git rebase working")
print("***************************")
print(" REVIEW THE FOLLOWING ")
print("***************************")
changeslisting = nil
do
local f = assert(io.open("CHANGES.md", "r"))
changeslisting = f:read("*all")
f:close()
end
currentchanges = string.match(changeslisting,"(## %S+ %(.-%).-)%s*## %S+ %(.-%)")
if currentchanges:len() > 8192 then
local trunctext = " [...and more; see CHANGES.md for full details.]"
currentchanges = currentchanges:sub(1,8192-trunctext:len()-1) .. trunctext
end
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()
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
--[============[
CONTINUE
--]============]
exe("git clean -fx")
exe("l3build tag")
gitstatus = os.capture('git status --porcelain')
if gitstatus ~= "" then
exe([===[
git commit -a -m 'update package version/date for release
[ci skip]';
]===])
end
exe("l3build ctan")
--[===========[
TAGGING
--]===========]
do
local f = assert(io.open("CHANGES-NEW.md", "w"))
f:write(currentchanges)
f:close()
end
exe("git tag -a '"..pkgversion.."' --file CHANGES-NEW.md")
exe("rm CHANGES-NEW.md")
--[=======================[
UPLOAD and CLEAN UP
--]=======================]
exe("l3build upload")
exe("git push")
exe("git checkout working")
exe("git rebase master")
exe("git push")
print('=====================')
print("Great success! Now time to fix some more bugs.")