Added versioning

This commit is contained in:
Marcel Baumgartner
2024-06-28 11:36:45 +02:00
parent d9d17c8342
commit 1525215757
3 changed files with 81 additions and 5 deletions

View File

@@ -7,10 +7,50 @@ namespace Moonlight.Core.Services;
[Singleton]
public class MoonlightService
{
public readonly string BuildChannel;
public readonly string BuildCommitHash;
public readonly string BuildName;
public readonly string BuildVersion;
public readonly bool IsDockerRun;
public WebApplication Application { get; set; } // Do NOT modify using a plugin
private readonly DateTime StartTimestamp = DateTime.UtcNow;
public MoonlightService()
{
//TODO: Maybe extract to a method
if (!File.Exists("version"))
{
BuildChannel = "N/A";
BuildCommitHash = "N/A";
BuildName = "N/A";
BuildVersion = "N/A";
IsDockerRun = false;
}
var line = File.ReadAllText("version");
var parts = line.Split(";");
if (parts.Length < 5)
{
BuildChannel = "N/A";
BuildCommitHash = "N/A";
BuildName = "N/A";
BuildVersion = "N/A";
IsDockerRun = false;
}
BuildChannel = parts[0];
BuildCommitHash = parts[1];
BuildName = parts[2];
BuildVersion = parts[3];
IsDockerRun = parts[4] == "docker";
//TODO: Add log call
}
public async Task Restart()
{
Logger.Info("Restarting moonlight");