-
Notifications
You must be signed in to change notification settings - Fork 0
/
IncrementVersion.ps1
75 lines (67 loc) · 2.03 KB
/
IncrementVersion.ps1
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
$file = './Source/Almonaster/GameEngine/GameEngine.cpp'
$content = Get-Content -Path $file
Remove-Item -Path $file
ForEach ($row in $content)
{
if ($row.Contains('#define ALMONASTER_VERSION'))
{
$index = $row.IndexOf('VERSION ')
if ($index -ne -1)
{
$index += 'VERSION '.Length
$version = [version]$row.Substring($index).Trim()
Add-Content -Path $file ('#define ALMONASTER_VERSION ' + '{0}.{1}.{2}' -f $version.Major, $version.Minor, ($version.Build + 1))
}
}
else
{
Add-Content -Path $file $row
}
}
$file = './Source/AlajarDll/HttpServer.h'
$content = Get-Content -Path $file
Remove-Item -Path $file
ForEach ($row in $content)
{
if ($row.Contains('#define ALAJAR_VERSION'))
{
$index = $row.IndexOf('VERSION ')
if ($index -ne -1)
{
$index += 'VERSION '.Length
$version = [version]$row.Substring($index).Trim()
$newVersion = '{0}.{1}.{2}' -f $version.Major, $version.Minor, ($version.Build + 1);
Add-Content -Path $file ('#define ALAJAR_VERSION ' + $newVersion)
}
}
else
{
Add-Content -Path $file $row
}
}
$file = './.github/workflows/release.yml'
$content = Get-Content -Path $file
Remove-Item -Path $file
ForEach ($row in $content)
{
if ($row.Contains('/almonaster-'))
{
$startIndex = $row.IndexOf('/almonaster-')
if ($startIndex -ne -1)
{
$startIndex += '/almonaster-'.Length
$endIndex = $row.IndexOf('-', $startIndex)
if ($endIndex -ne -1)
{
$version = [version]$row.Substring($startIndex, $endIndex - $startIndex).Trim()
$newVersion = '{0}.{1}.{2}' -f $version.Major, $version.Minor, ($version.Build + 1);
$newRow = $row.Substring(0, $startIndex) + $newVersion + $row.SubString($endIndex)
Add-Content -Path $file $newRow
}
}
}
else
{
Add-Content -Path $file $row
}
}