Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add GitVersion #106

Merged
merged 5 commits into from
Aug 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -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:
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/dotnet.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
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);
}
Loading