2021-11-26 21:10:56 -05:00
|
|
|
namespace PluralKit.Core;
|
2021-08-01 15:22:23 -04:00
|
|
|
|
2021-11-26 21:10:56 -05:00
|
|
|
public static class BuildInfoService
|
2021-08-01 15:22:23 -04:00
|
|
|
{
|
2021-11-26 21:10:56 -05:00
|
|
|
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; }
|
2021-08-01 15:22:23 -04:00
|
|
|
|
2021-11-26 21:10:56 -05:00
|
|
|
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");
|
2021-08-01 15:22:23 -04:00
|
|
|
|
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];
|
|
|
|
|
|
|
|
|
|
IsDev = data[2] == "";
|
2021-11-07 03:09:45 -05:00
|
|
|
|
2021-11-26 21:10:56 -05:00
|
|
|
// show only short commit hash to users
|
|
|
|
|
Version = FullVersion.Remove(7);
|
2021-08-01 15:22:23 -04:00
|
|
|
}
|
|
|
|
|
}
|