Skip to content

Commit 221cd2b

Browse files
committed
chore: New stable and testing version number calculations
1 parent 7d9f14b commit 221cd2b

File tree

5 files changed

+35
-50
lines changed

5 files changed

+35
-50
lines changed

Build.cmd

Lines changed: 3 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -105,19 +105,6 @@ REM Set update channel.
105105
>>Program\Updater.ini ECHO Channel=string:%Mode% || GOTO :error
106106
ECHO Set update channel to "%Mode%".
107107

108-
REM Set version number.
109-
IF "%Mode%" == "Stable" (
110-
>Program\Version.txt ECHO %Version% || GOTO :error
111-
ECHO Set version number to "%Version%".
112-
) ELSE (
113-
>Program\Version.txt ECHO %Mode:~0,1%%Version% || GOTO :error
114-
ECHO Set version number to "%Mode:~0,1%%Version%".
115-
)
116-
117-
REM Set revision number.
118-
>Program\Revision.txt ECHO %Revision% || GOTO :error
119-
ECHO Set revision number to "%Revision%".
120-
121108
REM Build locales.
122109
PUSHD Source\Locales && CALL Update.bat non-interactive && POPD || GOTO :error
123110

@@ -131,16 +118,10 @@ copy "Program\RunActivity.exe.config" "Program\RunActivityLAA.exe.config" || GOT
131118
ECHO Created large address aware version of RunActivity.exe.
132119

133120
REM Copy version number from OpenRails.exe into all other 1st party files
134-
SET VersionInfoVersion=0.0.0.0
135-
FOR /F "usebackq tokens=1 delims=-" %%V IN (`ECHO %Revision%`) DO SET VersionInfoVersion=%Version%.%%V
136-
IF "%VersionInfoVersion%" == "0.0.0.0" (
137-
>&2 ECHO ERROR: No VersionInfoVersion found in "Program\OpenRails.exe".
138-
GOTO :error
139-
)
140121
FOR %%F IN ("Program\*.exe", "Program\Orts.*.dll", "Program\Contrib.*.dll", "Program\Tests.dll") DO (
141-
rcedit-x86.exe "%%~F" --set-product-version %VersionInfoVersion% --set-file-version %VersionInfoVersion% --set-version-string ProductVersion %VersionInfoVersion% --set-version-string FileVersion %VersionInfoVersion% || GOTO :error
122+
rcedit-x86.exe "%%~F" --set-product-version %Revision% --set-version-string ProductVersion %Version% || GOTO :error
142123
)
143-
ECHO Set product and file version information to "%VersionInfoVersion%".
124+
ECHO Set product version information to "%Version%".
144125

145126
REM *** Special build step: signs binaries ***
146127
IF NOT "%JENKINS_TOOLS%" == "" (
@@ -174,7 +155,7 @@ IF "%Mode%" == "Stable" (
174155
IF %ERRORLEVEL% GEQ 8 GOTO :error
175156
ROBOCOPY /MIR /NJH /NJS "Program\Documentation" "Open Rails\Documentation"
176157
IF %ERRORLEVEL% GEQ 8 GOTO :error
177-
>"Source\Installer\OpenRails shared\Version.iss" ECHO #define MyAppVersion "%Version%.%Revision%" || GOTO :error
158+
>"Source\Installer\OpenRails shared\Version.iss" ECHO #define MyAppVersion "%Version%" || GOTO :error
178159
iscc "Source\Installer\OpenRails from download\OpenRails from download.iss" || GOTO :error
179160
iscc "Source\Installer\OpenRails from DVD\OpenRails from DVD.iss" || GOTO :error
180161
CALL :move "Source\Installer\OpenRails from download\Output\OpenRailsTestingSetup.exe" "OpenRails-%Mode%-Setup.exe" || GOTO :error

GetVersion.cmd

Lines changed: 26 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,34 @@
11
@ECHO OFF
22
SETLOCAL ENABLEEXTENSIONS ENABLEDELAYEDEXPANSION
33

4-
REM Get product version and code revision.
5-
SET Version=
6-
SET Revision=
7-
FOR /F "usebackq tokens=1* delims=-" %%V IN (`git describe --first-parent --always --long`) DO (
8-
SET Version=%%V
9-
SET Revision=%%W
4+
SET Mode=%~1%
5+
FOR /F "usebackq tokens=1-2 delims=-" %%A IN (`git describe --long --exclude=*-*`) DO (
6+
SET Git.Tag=%%A
7+
SET Git.Commits=%%B
108
)
11-
IF "%~1%" == "Unstable" (
12-
SET TZ=UTC
13-
FOR /F "usebackq tokens=1* delims=-" %%V IN (`git log -1 --pretty^=format:^%%ad --date^=format-local:^%%Y^.%%m^.%%d-^%%H^%%M`) DO (
14-
SET Version=%%V
15-
SET Revision=%%W
16-
)
17-
)
18-
IF "%Version%" == "" (
19-
>&2 ECHO WARNING: No Git repository found.
9+
FOR /F "usebackq tokens=1-4 delims=." %%A IN (`ECHO %Git.Tag%.0.0`) DO SET Revision=%%A.%%B.%%C.%Git.Commits%
10+
GOTO %Mode%
11+
12+
13+
:stable
14+
FOR /F "usebackq tokens=* delims=-" %%A IN (`git describe`) DO SET Version=%%A
15+
GOTO :done
16+
17+
18+
:testing
19+
FOR /F "usebackq tokens=* delims=-" %%A IN (`git describe --long --exclude=*-*`) DO SET Version=%Mode:~0,1%%%A
20+
GOTO :done
21+
22+
23+
:unstable
24+
SET TZ=UTC
25+
FOR /F "usebackq tokens=1-4 delims=." %%A IN (`git log -1 --pretty^=format:%%ad --date=format-local:%%Y.%%m.%%d.%%H%%M`) DO (
26+
SET Version=%Mode:~0,1%%%A.%%B.%%C-%%D
27+
SET Revision=0.%%A.%%B%%C.%%D
2028
)
29+
GOTO :done
30+
2131

22-
REM Output version numbers.
32+
:done
2333
ECHO OpenRails_Version=%Version%
2434
ECHO OpenRails_Revision=%Revision%

Source/Launcher/Launcher.csproj

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,7 @@
6262
<PropertyGroup>
6363
<PreBuildEvent>
6464
</PreBuildEvent>
65-
<PostBuildEvent>echo $Revision: 000 $&gt;Revision.txt
66-
date /t&gt;&gt;Revision.txt
67-
time /t&gt;&gt;Revision.txt</PostBuildEvent>
65+
<PostBuildEvent>
66+
</PostBuildEvent>
6867
</PropertyGroup>
6968
</Project>

Source/Menu/Menu.csproj

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -196,8 +196,7 @@
196196
<PropertyGroup>
197197
<PreBuildEvent>
198198
</PreBuildEvent>
199-
<PostBuildEvent>echo $Revision: 000 $&gt;Revision.txt
200-
date /t&gt;&gt;Revision.txt
201-
time /t&gt;&gt;Revision.txt</PostBuildEvent>
199+
<PostBuildEvent>
200+
</PostBuildEvent>
202201
</PropertyGroup>
203202
</Project>

Source/RunActivity/RunActivity.csproj

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -320,9 +320,6 @@
320320
<Content Include="Readme.txt">
321321
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
322322
</Content>
323-
<Content Include="Version.txt">
324-
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
325-
</Content>
326323
</ItemGroup>
327324
<ItemGroup>
328325
<ProjectReference Include="..\Orts.Formats.Msts\Orts.Formats.Msts.csproj">
@@ -387,8 +384,7 @@
387384
<PropertyGroup>
388385
<PreBuildEvent>
389386
</PreBuildEvent>
390-
<PostBuildEvent>echo $Revision: 000 $&gt;Revision.txt
391-
date /t&gt;&gt;Revision.txt
392-
time /t&gt;&gt;Revision.txt</PostBuildEvent>
387+
<PostBuildEvent>
388+
</PostBuildEvent>
393389
</PropertyGroup>
394390
</Project>

0 commit comments

Comments
 (0)