PluralKit/PluralKit.Core/Services/BuildInfoService.cs

26 lines
844 B
C#
Raw Permalink Normal View History

namespace PluralKit.Core;
public static class BuildInfoService
{
public static string Version { get; private set; }
public static string FullVersion { get; private set; }
2025-01-05 00:52:45 +00:00
public static string Timestamp { get; private set; }
public static bool IsDev { get; private set; }
public static async Task LoadVersion()
{
2025-01-05 00:52:45 +00:00
using var stream = typeof(BuildInfoService).Assembly.GetManifestResourceStream("version");
if (stream == null) throw new Exception("missing version information");
2025-01-05 00:52:45 +00:00
using var reader = new StreamReader(stream);
var data = (await reader.ReadToEndAsync()).Split("\n");
FullVersion = data[0];
Timestamp = data[1];
2025-01-05 04:54:40 +00:00
IsDev = data.Length < 3 || data[2] == "";
// show only short commit hash to users
Version = FullVersion.Remove(7);
}
}