Skip to content

Commit

Permalink
Merge pull request #106 from prplecake/use-gitversion-semver
Browse files Browse the repository at this point in the history
  • Loading branch information
prplecake committed Aug 15, 2023
2 parents b5e7fa6 + d785492 commit 4bb771f
Show file tree
Hide file tree
Showing 7 changed files with 27 additions and 4 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/dotnet-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,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:
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/dotnet.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,3 +45,4 @@ jobs:
name: .NET Test Results
path: TestResults/*.trx
reporter: dotnet-trx
- run: dotnet run --project src/BookmarkSync.CLI/BookmarkSync.CLI.csproj -- version
4 changes: 4 additions & 0 deletions src/BookmarkSync.CLI/BookmarkSync.CLI.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@

<ItemGroup>
<PackageReference Include="CiT.Common" Version="0.0.1" />
<PackageReference Include="GitVersion.MsBuild" Version="6.0.0-beta.3">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.Extensions.Hosting" Version="7.0.1" />
<PackageReference Include="Serilog.Extensions.Hosting" Version="7.0.0" />
<PackageReference Include="Serilog.Settings.Configuration" Version="7.0.0" />
Expand Down
9 changes: 8 additions & 1 deletion src/BookmarkSync.CLI/Program.cs
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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);

Expand All @@ -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;
}
Expand Down
4 changes: 4 additions & 0 deletions src/BookmarkSync.Core/BookmarkSync.Core.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@

<ItemGroup>
<PackageReference Include="CiT.Common" Version="0.0.1" />
<PackageReference Include="GitVersion.MsBuild" Version="6.0.0-beta.3">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="HtmlAgilityPack" Version="1.11.51" />
<PackageReference Include="Microsoft.Extensions.Configuration" Version="7.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.Binder" Version="7.0.4" />
Expand Down
9 changes: 6 additions & 3 deletions src/BookmarkSync.Core/Meta.cs
Original file line number Diff line number Diff line change
@@ -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);
}

0 comments on commit 4bb771f

Please sign in to comment.