-
Notifications
You must be signed in to change notification settings - Fork 0
/
makeRelease.mnh
72 lines (61 loc) · 2.36 KB
/
makeRelease.mnh
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
LAZ_BUILD:='..\lazarus64\lazbuild.exe';
LPI:='dt2.lpi';
BUILD_MODE:='--bm=opt';
DELP:=allFiles(LAZ_BUILD.extractFileDirectory,'delp.exe')[0];
memoized getVersionFromLPI->
begin
local lpiLines:=fileLines('dt2.lpi');
[lpiLines.filter((l)->l.matches('MajorVersionNr'))[0] orElse '',
lpiLines.filter((l)->l.matches('MinorVersionNr'))[0] orElse '',
lpiLines.filter((l)->l.matches('RevisionNr' ))[0] orElse '']
.split('"').softCast.map((l)->l.filter(::isInt)[0] orElse '?').join('.');
end;
patchAbout->begin
local lines:=fileLines('aboutUi.lfm');
local toPatch:=indexOf(lines.matches('Digitaltrainer Version \d+\.\d+\.\d+'));
assert(toPatch.size=1);
toPatch:=toPatch[0];
lines[toPatch]:=regex.replace(lines[toPatch],'Digitaltrainer Version \d+\.\d+\.\d+','Digitaltrainer Version '&getVersionFromLPI);
writeFileLines('aboutUi.lfm',lines);
end;
patchInstallerScript->begin
local lines:=fileLines('installer\installer.iss');
local toPatch:=indexOf(lines.matches('AppVersion=\d+\.\d+\.\d+'));
assert(toPatch.size=1);
toPatch:=toPatch[0];
lines[toPatch]:=regex.replace(lines[toPatch],'AppVersion=\d+\.\d+\.\d+','AppVersion='&getVersionFromLPI);
writeFileLines('installer\installer.iss',lines);
end;
main->begin
log('Current version: ',getVersionFromLPI);
local existentTags:=exec('git',['tag'])[0];
local matchingTag :=existentTags[existentTags.matches(getVersionFromLPI)][0];
matchingTag.isVoid
? begin
log('Matching tag : <none>');
end
: begin
log('Matching tag : ',matchingTag);
log('Done.');
halt;
end;
log('Patching about');
patchAbout;
log('Patching installer script');
patchInstallerScript;
log('Building');
assert(teeExec(LAZ_BUILD,[LPI,BUILD_MODE])[1]==0,'Build failed');
changeDirectory('installer');
log('Creating installer');
assert(teeExec('c:\Program Files (x86)\Inno Setup 6\ISCC.exe',['installer.iss'])[1]==0,'Build failed');
changeDirectory('..');
log('Staging everything...');
teeExec('git',['stage','*']);
log('Committing...');
teeExec('git',['commit','-m',"Release V"&getVersionFromLPI]);
log('Creating Tag...');
teeExec('git',['tag','V'&getVersionFromLPI]);
DELP.isVoid ? void : exec(DELP,['-r','.']);
log("Done.\n",
'Please review the generated changes before comitting.');
end;