diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml index 362679b..a6238e0 100644 --- a/.github/workflows/codeql.yml +++ b/.github/workflows/codeql.yml @@ -42,6 +42,8 @@ jobs: steps: - name: Checkout repository uses: actions/checkout@v3 + with: + fetch-depth: 0 # Initializes the CodeQL tools for scanning. - name: Initialize CodeQL diff --git a/.github/workflows/dotnet-release.yml b/.github/workflows/dotnet-release.yml index a3b689a..c01ed95 100644 --- a/.github/workflows/dotnet-release.yml +++ b/.github/workflows/dotnet-release.yml @@ -38,6 +38,8 @@ jobs: name: .NET Test Results path: TestResults/*.trx reporter: dotnet-trx + - run: dotnet run --project src/BookmarkSync.CLI/BookmarkSync.CLI.csproj -- version + publish: env: diff --git a/.github/workflows/dotnet.yml b/.github/workflows/dotnet.yml index 998ad63..24d2688 100644 --- a/.github/workflows/dotnet.yml +++ b/.github/workflows/dotnet.yml @@ -47,3 +47,4 @@ jobs: name: .NET Test Results path: TestResults/*.trx reporter: dotnet-trx + - run: dotnet run --project src/BookmarkSync.CLI/BookmarkSync.CLI.csproj -- version diff --git a/src/BookmarkSync.CLI/BookmarkSync.CLI.csproj b/src/BookmarkSync.CLI/BookmarkSync.CLI.csproj index a49f678..10876cb 100644 --- a/src/BookmarkSync.CLI/BookmarkSync.CLI.csproj +++ b/src/BookmarkSync.CLI/BookmarkSync.CLI.csproj @@ -15,6 +15,10 @@ + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + diff --git a/src/BookmarkSync.CLI/Program.cs b/src/BookmarkSync.CLI/Program.cs index 3fc724f..e80b8db 100644 --- a/src/BookmarkSync.CLI/Program.cs +++ b/src/BookmarkSync.CLI/Program.cs @@ -1,4 +1,5 @@ -using BookmarkSync.Core.Configuration; +using BookmarkSync.Core; +using BookmarkSync.Core.Configuration; using BookmarkSync.Infrastructure.Services.Bookmarking; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; @@ -12,6 +13,11 @@ public static class Program private static IConfiguration? _configuration; public static int Main(string[] args) { + if (args.Contains("version")) + { + Console.WriteLine("{0} {1}", Meta.Name, Meta.Version); + return 0; + } _configuration = SetupConfiguration(args); IConfigManager configManager = new ConfigManager(_configuration); @@ -23,6 +29,7 @@ public static int Main(string[] args) try { Log.Information("Starting host"); + Log.Information("{Name} {Version}", Meta.Name, Meta.Version); BuildHost(configManager).Run(); return 0; } diff --git a/src/BookmarkSync.Core/BookmarkSync.Core.csproj b/src/BookmarkSync.Core/BookmarkSync.Core.csproj index 5fba10e..d0e2e0f 100644 --- a/src/BookmarkSync.Core/BookmarkSync.Core.csproj +++ b/src/BookmarkSync.Core/BookmarkSync.Core.csproj @@ -12,6 +12,10 @@ + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + diff --git a/src/BookmarkSync.Core/Meta.cs b/src/BookmarkSync.Core/Meta.cs index a3b3d78..55d6418 100644 --- a/src/BookmarkSync.Core/Meta.cs +++ b/src/BookmarkSync.Core/Meta.cs @@ -1,11 +1,14 @@ using System.Net.Http.Headers; +using System.Reflection; namespace BookmarkSync.Core; public static class Meta { - private const string - Name = "mastodon-bookmark-sync", - Version = "2.0"; + private static readonly Assembly? Assembly = Assembly.GetEntryAssembly(); + private static readonly Type? GitVersionInformationType = Assembly?.GetType("GitVersionInformation"); + public const string Name = "mastodon-bookmark-sync"; + public static readonly string + Version = GitVersionInformationType?.GetField("SemVer")?.GetValue(null)?.ToString() ?? "2.0"; public static readonly ProductInfoHeaderValue UserAgent = new(Name, Version); }