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

Automatically generated version info using GitVersion #70

Merged
merged 4 commits into from
Jun 6, 2024
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
13 changes: 11 additions & 2 deletions .config/dotnet-tools.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,22 @@
"version": "0.6.2",
"commands": [
"husky"
]
],
"rollForward": false
},
"csharpier": {
"version": "0.25.0",
"commands": [
"dotnet-csharpier"
]
],
"rollForward": false
},
"gitversion.tool": {
"version": "5.12.0",
"commands": [
"dotnet-gitversion"
],
"rollForward": false
}
}
}
5 changes: 4 additions & 1 deletion .github/workflows/pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,10 @@ jobs:
runs-on: ubuntu-latest
name: Checks
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Setup .NET
uses: actions/setup-dotnet@v3
with:
Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -408,3 +408,6 @@ FodyWeavers.xsd
# Migrations and SQLite files
/Server/Migrations
/Server/fracture.d*

# AssemblyInfo.cs (it's autogenerated)
/Server/AssemblyInfo.cs
11 changes: 7 additions & 4 deletions Server/Components/Layout/GameLayout.razor
Original file line number Diff line number Diff line change
@@ -1,16 +1,19 @@
@inherits LayoutComponentBase
@using Fracture.Server.Modules.Shared
@inherits LayoutComponentBase
@inject VersionInfoProvider VersionInfoProvider

<HeadContent>
<link rel="stylesheet" href="css/game.css">
<link rel="stylesheet" href="css/items.css">
<meta name="generator" content="Fracture @VersionInfoProvider.ShortVersion">
</HeadContent>

@Body

@* <div id="blazor-error-ui">
An unhandled error has occurred.
<a href="" class="reload">Reload</a>
<a class="dismiss">🗙</a>
An unhandled error has occurred.
<a href="" class="reload">Reload</a>
<a class="dismiss">🗙</a>
</div> *@


Expand Down
7 changes: 5 additions & 2 deletions Server/Components/Layout/HomeLayout.razor
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
@inherits LayoutComponentBase
@using Fracture.Server.Modules.Shared
@inherits LayoutComponentBase
@inject VersionInfoProvider VersionInfoProvider

<HeadContent>
<link rel="stylesheet" href="css/game.css">
<meta name="generator" content="Fracture @VersionInfoProvider.ShortVersion">
</HeadContent>

@Body

@code {

}
5 changes: 3 additions & 2 deletions Server/Components/Pages/GamePage.razor
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,12 @@
@using Fracture.Server.Modules.Database
@using Fracture.Server.Modules.Users
@using Fracture.Server.Components.Pages
@using Fracture.Server.Modules.Shared
@layout GameLayout
@inject IUsersRepository UsersRepository
@inject NavigationManager NavigationManager
@inject IItemsRepository ItemsRepository

@inject VersionInfoProvider VersionInfoProvider

<div id="container">
<div class="leftPanel borderPanel">
Expand Down Expand Up @@ -53,7 +54,7 @@
</div>
<div class="dialogueWindowBg">
<div class="dialogueWindow">
tutaj log mojej gry<br />
Fracture @VersionInfoProvider.ShortVersion<br />
tutaj log mojej gry<br />
<PopupContainer @ref="_popup"></PopupContainer>
</div>
Expand Down
6 changes: 6 additions & 0 deletions Server/Fracture.Server.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<UserSecretsId>16f71bc9-60c6-466f-af95-a2818674e57c</UserSecretsId>
<GenerateAssemblyFileVersionAttribute>false</GenerateAssemblyFileVersionAttribute>
<GenerateAssemblyVersionAttribute>false</GenerateAssemblyVersionAttribute>
<GenerateAssemblyInformationalVersionAttribute>false</GenerateAssemblyInformationalVersionAttribute>
</PropertyGroup>
<ItemGroup>
<_ContentIncludedByDefault Remove="wwwroot\css\items.css" />
Expand All @@ -27,4 +30,7 @@
<Exec Command="dotnet tool restore" StandardOutputImportance="Low" StandardErrorImportance="High" />
<Exec Command="dotnet husky install" StandardOutputImportance="Low" StandardErrorImportance="High" WorkingDirectory=".." />
</Target>
<Target Name="GitVersion" BeforeTargets="Build">
<Exec Command="dotnet dotnet-gitversion /updateassemblyinfo AssemblyInfo.cs /ensureassemblyinfo" StandardOutputImportance="High" StandardErrorImportance="High" />
</Target>
</Project>
21 changes: 21 additions & 0 deletions Server/Modules/Shared/VersionInfoProvider.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
using System.Reflection;

namespace Fracture.Server.Modules.Shared;

class VersionInfoProvider
{
public VersionInfoProvider()
{
InformationalVersion =
Assembly
.GetEntryAssembly()
?.GetCustomAttribute<AssemblyInformationalVersionAttribute>()
?.InformationalVersion ?? string.Empty;

ShortVersion = InformationalVersion.Substring(0, InformationalVersion.IndexOf(".Branch"));
}

public string InformationalVersion { get; init; }

public string ShortVersion { get; init; }
}
1 change: 1 addition & 0 deletions Server/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
builder.Services.AddSingleton<INameGenerator, MarkovNameGenerator>();
builder.Services.AddSingleton<IItemGenerator, ItemGenerator>();
builder.Services.AddSingleton<PrefixesGenerator>();
builder.Services.AddSingleton<VersionInfoProvider>();
builder.Services.AddScoped<IUsersRepository, UsersRepository>();
builder.Services.AddScoped<IItemsRepository, ItemsRepository>();

Expand Down
Loading