From af83af777b2e1d1ab851cd8bc52e0cf8d1138e1e Mon Sep 17 00:00:00 2001 From: Matty Jorgensen Date: Tue, 15 Aug 2023 18:07:10 -0500 Subject: [PATCH 1/5] Add GitVersion 6.0.0-beta.3 --- src/BookmarkSync.CLI/BookmarkSync.CLI.csproj | 4 ++++ src/BookmarkSync.Core/BookmarkSync.Core.csproj | 4 ++++ 2 files changed, 8 insertions(+) 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.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 + From 9c0d1f755d2e14a54a6b270b0bb92dbfd39b0cae Mon Sep 17 00:00:00 2001 From: Matty Jorgensen Date: Tue, 15 Aug 2023 18:07:45 -0500 Subject: [PATCH 2/5] Use SemVer from GitVersion as Meta.Version, falling back to "2.0" if that fails --- src/BookmarkSync.CLI/Program.cs | 4 +++- src/BookmarkSync.Core/Meta.cs | 9 ++++++--- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/src/BookmarkSync.CLI/Program.cs b/src/BookmarkSync.CLI/Program.cs index 3fc724f..33e0fa7 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; @@ -23,6 +24,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/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); } From 0998acecef8dc3e1a5b3ec8f3892b8592ddf7ef4 Mon Sep 17 00:00:00 2001 From: Matty Jorgensen Date: Tue, 15 Aug 2023 18:12:14 -0500 Subject: [PATCH 3/5] Print version when "version" is supplied as an argument --- src/BookmarkSync.CLI/Program.cs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/BookmarkSync.CLI/Program.cs b/src/BookmarkSync.CLI/Program.cs index 33e0fa7..e80b8db 100644 --- a/src/BookmarkSync.CLI/Program.cs +++ b/src/BookmarkSync.CLI/Program.cs @@ -13,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); From 1b1e2aeed2afe3c589547dd4989b69a08369f59d Mon Sep 17 00:00:00 2001 From: Matty Jorgensen Date: Tue, 15 Aug 2023 18:17:25 -0500 Subject: [PATCH 4/5] Print version in CI --- .github/workflows/dotnet-release.yml | 2 ++ .github/workflows/dotnet.yml | 1 + 2 files changed, 3 insertions(+) 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 From d7854927f01eadb10f0e5dd16530a29071e63de7 Mon Sep 17 00:00:00 2001 From: Matty Jorgensen Date: Tue, 15 Aug 2023 18:20:09 -0500 Subject: [PATCH 5/5] Fetch all history in codeql workflow --- .github/workflows/codeql.yml | 2 ++ 1 file changed, 2 insertions(+) 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