-
Notifications
You must be signed in to change notification settings - Fork 102
/
version_help.ps1
38 lines (32 loc) · 1.7 KB
/
version_help.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
$tag = git describe --tags --always
if (-Not ($tag -match ".+\..+\..+\..+")) {
$tag = "0.0.0." + $tag
}
$commatag = $tag -replace "\.",","
$commatag = $commatag -replace "-","0"
$commatag = $commatag -replace "[A-z]","0"
((Get-Content -path ./Resource.rc -Raw) -replace "FILEVERSION .*,.*,.*,.*", ("FILEVERSION " + $commatag)) | Set-Content -Path ./Resource.rc
((Get-Content -path ./Resource.rc -Raw) -replace "PRODUCTVERSION .*,.*,.*,.*", ("PRODUCTVERSION " + $commatag)) | Set-Content -Path ./Resource.rc
((Get-Content -path ./Resource.rc -Raw) -replace '"FileVersion", ".*"', ('"FileVersion", "' + $tag + '"')) | Set-Content -Path ./Resource.rc
((Get-Content -path ./Resource.rc -Raw) -replace '"ProductVersion", ".*"', ('"ProductVersion", "' + $tag + '"')) | Set-Content -Path ./Resource.rc
$cleanTag = git describe --tags --abbrev=0
$versionFileText = "
/* Autogenerated version info file */
#pragma once
namespace version {
inline const auto VERSION_STR = ""$tag"";
inline const auto IS_SNAPSHOT = $( If ($tag.Length -gt 10) {'true'} Else {'false'});
inline const auto VERSION_MAJOR = $($cleanTag.Split('.')[0]);
inline const auto VERSION_MINOR = $($cleanTag.Split('.')[1]);
inline const auto VERSION_PATCH = $($cleanTag.Split('.')[2]);
inline const auto VERSION_REVISION = $($cleanTag.Split('.')[3]);
}
"
if (!(Test-Path '../version.hpp')) {
New-Item -Path ".." -Name "version.hpp" -ItemType "file" -Value $versionFileText
} else {
Set-Content -Path "../version.hpp" -Value $versionFileText
}
if ((Test-Path '../Installer/Installer.nsi')) {
((Get-Content -path '../Installer/Installer.nsi' -Raw) -replace '!define VERSION ".*"', ('!define VERSION "' + $tag + '"')) | Set-Content -Path '../Installer/Installer.nsi'
}