Expose git version in 'pk;stats' and '/v1/meta'

This commit is contained in:
spiral
2021-08-01 15:22:23 -04:00
parent dcc15dc847
commit 1cb4bc9287
9 changed files with 54 additions and 5 deletions

View File

@@ -0,0 +1,24 @@
using System.IO;
using System.Reflection;
using System.Threading.Tasks;
namespace PluralKit.Core
{
public static class BuildInfoService
{
public static string Version { get; private set; }
public static async Task LoadVersion()
{
using (var stream = typeof(BuildInfoService).Assembly.GetManifestResourceStream("version"))
{
// if this happens, something broke
if (stream == null) Version = "(unknown version) ";
else using (var reader = new StreamReader(stream)) Version = await reader.ReadToEndAsync();
}
// cheap hack to remove newline
Version = Version.Remove(Version.Length - 1);
}
}
}