diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index a5385ed..5257d0e 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -22,6 +22,9 @@ jobs: - name: Restore dependencies run: dotnet restore + - name: Embed version info + run: echo "${{ github.sha }}" > ConfusedPolarBear.Plugin.IntroSkipper/Configuration/version.txt + - name: Build run: dotnet build --no-restore diff --git a/ConfusedPolarBear.Plugin.IntroSkipper/Configuration/version.txt b/ConfusedPolarBear.Plugin.IntroSkipper/Configuration/version.txt new file mode 100644 index 0000000..3546645 --- /dev/null +++ b/ConfusedPolarBear.Plugin.IntroSkipper/Configuration/version.txt @@ -0,0 +1 @@ +unknown diff --git a/ConfusedPolarBear.Plugin.IntroSkipper/ConfusedPolarBear.Plugin.IntroSkipper.csproj b/ConfusedPolarBear.Plugin.IntroSkipper/ConfusedPolarBear.Plugin.IntroSkipper.csproj index 16990a2..0fe5248 100644 --- a/ConfusedPolarBear.Plugin.IntroSkipper/ConfusedPolarBear.Plugin.IntroSkipper.csproj +++ b/ConfusedPolarBear.Plugin.IntroSkipper/ConfusedPolarBear.Plugin.IntroSkipper.csproj @@ -23,6 +23,7 @@ + diff --git a/ConfusedPolarBear.Plugin.IntroSkipper/Entrypoint.cs b/ConfusedPolarBear.Plugin.IntroSkipper/Entrypoint.cs index 3aac306..5be6297 100644 --- a/ConfusedPolarBear.Plugin.IntroSkipper/Entrypoint.cs +++ b/ConfusedPolarBear.Plugin.IntroSkipper/Entrypoint.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.IO; using System.Threading.Tasks; using Jellyfin.Data.Enums; using MediaBrowser.Controller.Entities; @@ -51,6 +52,10 @@ public class Entrypoint : IServerEntryPoint { Chromaprint.Logger = _logger; + #if DEBUG + LogVersion(); + #endif + // Assert that ffmpeg with chromaprint is installed if (!Chromaprint.CheckFFmpegVersion()) { @@ -195,6 +200,40 @@ public class Entrypoint : IServerEntryPoint throw new FingerprintException("Unable to find an administrator on this server."); } + #if DEBUG + /// + /// Logs the exact commit that created this version of the plugin. Only used in unstable builds. + /// + private void LogVersion() + { + var assembly = GetType().Assembly; + var path = GetType().Namespace + ".Configuration.version.txt"; + + using (var stream = assembly.GetManifestResourceStream(path)) + { + if (stream is null) + { + _logger.LogWarning("Unable to read embedded version information"); + return; + } + + var version = string.Empty; + using (var reader = new StreamReader(stream)) + { + version = reader.ReadToEnd().TrimEnd(); + } + + if (version == "unknown") + { + _logger.LogTrace("Embedded version information was not valid, ignoring"); + return; + } + + _logger.LogInformation("Unstable version built from commit {Version}", version); + } + } + #endif + /// /// Dispose. ///