If you are already using Git for your game and want to automatically tag your main branch after completing a feature and having the version number displaying in your game, you can use the following bash script (I am using Git bash for Windows) that updates the GameSettings.ini file where the version is stored:
#!/bin/bash
version=$1
if [ -z "$version" ]; then
echo "Argument is version in [major].[minor].[revision].[build] format"
exit 1
fi
ini_file="Config/DefaultGame.ini"
#Game Display
perl -pi -e "s/\d+\.\d+\.\d+\.\d+/${version}/" $ini_file
git add $ini_file
git commit -m "Releasing version ${version}"
git tag -a "${version}" -m "version ${version}"
git push origin
git push origin "${version}"
Then in your GameMode, GameInstance, or static utility function you can add this to retrieve the version, which you can display in the bottom right corner of your main menu for example:
#include "Misc/ConfigCacheIni.h"
// ....
FString ASimpleShooterGameModeBase::GetProjectVersion() const
{
FString GameVersion;
GConfig->GetString(
TEXT("/Script/EngineSettings.GeneralProjectSettings"),
TEXT("ProjectVersion"),
GameVersion,
GGameIni
);
return FString::Printf(TEXT("v %s"), *GameVersion);
}
Then after merging to main on your main branch and ready for a new release, you can run
./release_version 1.0.0.1
for example to set the version number to 1.0.0.1 both in your game settings and as a tag on your git repository.