Skip to content

Commit

Permalink
Merge pull request #15 from argon-chat/feature/heading-endpoint
Browse files Browse the repository at this point in the history
GitVersion + Heading Action Endpoint
  • Loading branch information
0xF6 authored Nov 1, 2024
2 parents 294c458 + 3757a65 commit 5c77477
Show file tree
Hide file tree
Showing 7 changed files with 93 additions and 3 deletions.
1 change: 1 addition & 0 deletions Argon.Server.sln
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
.editorconfig = .editorconfig
.gitignore = .gitignore
.gitmodules = .gitmodules
GitVersion.yml = GitVersion.yml
EndProjectSection
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Argon.Contracts", "src\Argon.Contracts\Argon.Contracts.csproj", "{151002BD-57E5-440B-9CA7-C681A69CA02C}"
Expand Down
25 changes: 25 additions & 0 deletions Directory.Build.props
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<Project>
<PropertyGroup>
<InvariantGlobalization>true</InvariantGlobalization>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<LangVersion>latest</LangVersion>
<Version>0.1</Version>
<EnablePreviewFeatures>true</EnablePreviewFeatures>
</PropertyGroup>
<PropertyGroup>
<CurrentYear>$([System.DateTime]::Now.ToString(yyyy))</CurrentYear>
<PackageProjectUrl>https://github.com/argon-chat/server</PackageProjectUrl>
<RepositoryUrl>https://github.com/argon-chat/server</RepositoryUrl>
<RepositoryType>git</RepositoryType>
<Copyright>(C) 2024-$(CurrentYear) Contributors of the Argon repository</Copyright>
<Authors>Yuuki Wesp, Aram Hayrapetyan, and all contributors of the Argon repository (argon-chat/server)</Authors>
<Company>Argon Chat</Company>
<EmbedUntrackedSources>true</EmbedUntrackedSources>
<IncludeSymbols>true</IncludeSymbols>
<SymbolPackageFormat>snupkg</SymbolPackageFormat>
<NoWarn>CS0162,CS8981,CS8632,CS9113,CS8618,CS9113,CS8321,CS0219,CS1998,IDE0053</NoWarn>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="8.0.0" PrivateAssets="All"/>
</ItemGroup>
</Project>
8 changes: 8 additions & 0 deletions GitVersion.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
mode: ContinuousDelivery
assembly-file-versioning-format: '{Major}.{Minor}.{Patch}.{CommitsSinceVersionSource}'
assembly-informational-format: '{Major}.{Minor}.{Patch}.{CommitsSinceVersionSource}-{BranchName}+{ShortSha}'
merge-message-formats: {}
commit-message-incrementing: Enabled
patch-version-bump-message: "^(add|bump|drop|mv|move|update|expose|remove|refactoring|additional|use|improvement|fix|refactor)(.+)?"
tag-prefix: 'IGNORE'
next-version: "0.1"
4 changes: 3 additions & 1 deletion src/Argon.Api/Argon.Api.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,9 @@
</ItemGroup>

<ItemGroup>
<Folder Include="Features\Jwt\" />
<PackageReference Include="GitVersion.MsBuild" Version="5.12">
<PrivateAssets>All</PrivateAssets>
</PackageReference>
</ItemGroup>

</Project>
36 changes: 36 additions & 0 deletions src/Argon.Api/Controllers/MetadataController.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
namespace Argon.Api.Controllers;

using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;

[ApiController]
public class MetadataController : ControllerBase
{
[Route("/cfg.json")]
[AllowAnonymous]
public ValueTask<HeadRoutingConfig> GetHead() =>
new(new HeadRoutingConfig(
$"{GlobalVersion.FullSemVer}.{GlobalVersion.ShortSha}",
"api.argon.gl",
"argon-f14ic5ia.livekit.cloud",
[
new RegionalNode("cdn-ru1.argon.gl", "ru1"),
new RegionalNode("cdn-ru2.argon.gl", "ru1"),
new RegionalNode("cdn-as1.argon.gl", "as1")
], [
new FeatureFlag("dev.window", true),
new FeatureFlag("user.allowServerCreation", true),
]));
}

public record HeadRoutingConfig(
string version,
string masterEndpoint,
string webRtcEndpoint,
List<RegionalNode> cdnAddresses,
List<FeatureFlag> features
);

public record RegionalNode(string url, string code);

public record FeatureFlag(string code, bool enabled);
18 changes: 18 additions & 0 deletions src/Argon.Api/GlobalVersion.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
namespace Argon.Api;

public static class GlobalVersion
{
public static string BranchName => GitVersionInformation.BranchName;
public static string AssemblySemFileVer => GitVersionInformation.AssemblySemFileVer;
public static string AssemblySemVer => GitVersionInformation.AssemblySemVer;
public static string CommitDate => GitVersionInformation.CommitDate;
public static string BuildMetaData => GitVersionInformation.BuildMetaData;
public static string FullSemVer => GitVersionInformation.FullSemVer;
public static string InformationalVersion => GitVersionInformation.InformationalVersion;
public static string Major => GitVersionInformation.Major;
public static string Minor => GitVersionInformation.Minor;
public static string Patch => GitVersionInformation.Patch;
public static string Sha => GitVersionInformation.Sha;
public static string ShortSha => GitVersionInformation.ShortSha;
public static string PreReleaseTag => GitVersionInformation.PreReleaseTag;
}
4 changes: 2 additions & 2 deletions src/Argon.Api/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using ActualLab.Rpc;
using ActualLab.Rpc.Infrastructure;
using ActualLab.Rpc.Server;
using Argon.Api;
using Argon.Api.Entities;
using Argon.Api.Extensions;
using Argon.Api.Features.Jwt;
Expand Down Expand Up @@ -42,6 +43,5 @@
app.MapDefaultEndpoints();
app.UseWebSockets();
app.MapRpcWebSocketServer();
var buildTime = File.GetLastWriteTimeUtc(typeof(Program).Assembly.Location);
app.MapGet("/", () => new { buildTime });
app.MapGet("/", () => new { version = $"{GlobalVersion.FullSemVer}.{GlobalVersion.ShortSha}", });
await app.WarpUp<ApplicationDbContext>().RunAsync();

0 comments on commit 5c77477

Please sign in to comment.