Skip to content

Commit

Permalink
Set version following SemVer scheme
Browse files Browse the repository at this point in the history
  • Loading branch information
mariomenjr committed Jun 20, 2021
1 parent 30c157b commit 53dd98a
Show file tree
Hide file tree
Showing 5 changed files with 52 additions and 20 deletions.
2 changes: 1 addition & 1 deletion Docker/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ version: "3.1"
services:
identity:
container_name: identity
image: identity:0.0.0.2
image: identity:0.1.1-alpha.1
build:
context: ./../
dockerfile: Docker/${DOCKERFILE}
Expand Down
6 changes: 3 additions & 3 deletions Identity/Identity.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@

<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
<AssemblyVersion>0.0.0.2</AssemblyVersion>
<AssemblyVersion>0.1.1.1</AssemblyVersion>
<NeutralLanguage>en-US</NeutralLanguage>
<Authors>Mario Menjivar</Authors>
<Description>dentity Server 4 using MongoDB for Stores.</Description>
<Description>Identity Server 4 using MongoDB for Stores.</Description>
<PackageProjectUrl>https://identity.mariomenjr.com/</PackageProjectUrl>
<RepositoryUrl>https://github.com/mariomenjr/identity</RepositoryUrl>
<IsPackable>true</IsPackable>
<PackageVersion>0.0.0.2</PackageVersion>
<Version>0.1.1-alpha.1</Version>
</PropertyGroup>

<ItemGroup>
Expand Down
15 changes: 2 additions & 13 deletions Identity/Startup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,10 @@ namespace Identity
{
public class Startup
{
private FileVersionInfo About { get; }
private IConfiguration Configuration { get; }

public Startup(IConfiguration configuration)
{
this.About = FileVersionInfo.GetVersionInfo(Assembly.GetExecutingAssembly().Location);
this.Configuration = configuration;
}

Expand Down Expand Up @@ -50,18 +48,9 @@ public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
{
endpoints.MapGet("/", async context =>
{
string repoUrl = "https://github.com/mariomenjr/identity"; // Environment.GetEnvironmentVariable("REPO_URL");
await context.Response.WriteAsync(
"<html><body>" +
string.Join(
"<br />",
new string[]
{
$"{this.About.ProductName}/{this.About.FileVersion} @ {DateTimeOffset.Now.ToString()}",
$"Repo: <a href=\"{repoUrl}\">{repoUrl}</a>",
}
) +
"</body></html>"

Utils.About.GetHtmlWelcomePage()
);
});
});
Expand Down
45 changes: 45 additions & 0 deletions Identity/Utils/About.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
using System;
using System.Diagnostics;
using System.Linq;
using System.Reflection;

namespace Identity.Utils
{
public static class About
{
public static string GetHtmlWelcomePage()
{
var body = string.Join(
"<br />",
new string[]
{
$"{DateTimeOffset.Now.ToString()}/{IdentityInfo.Configuration}",
"<br />",
$"{IdentityInfo.Product}@v{IdentityInfo.InformationalVersion}",
$" {IdentityInfo.Description}",
$"<a href=\"{IdentityInfo.RepositoryUrl}\">{IdentityInfo.RepositoryUrl}</a>",
}
);

return $"<html><body>{body}</body></html>";
}

private static class IdentityInfo
{
public static string Product { get { return GetExecutingAssemblyAttribute<AssemblyProductAttribute>(a => a.Product); } }
public static string Description { get { return GetExecutingAssemblyAttribute<AssemblyDescriptionAttribute>(a => a.Description); } }
public static string Configuration { get { return GetExecutingAssemblyAttribute<AssemblyConfigurationAttribute>(a => a.Configuration); } }
public static string RepositoryUrl { get { return GetExecutingAssemblyAttribute<AssemblyMetadataAttribute>(a => a.Value); } }
public static string InformationalVersion { get { return GetExecutingAssemblyAttribute<AssemblyInformationalVersionAttribute>(a => a.InformationalVersion); } }
// public static Version Version { get { return Assembly.GetExecutingAssembly().GetName().Version; } }

private static string GetExecutingAssemblyAttribute<T>(Func<T, string> value) where T : Attribute
{
T attribute = (T)Attribute.GetCustomAttribute(Assembly.GetExecutingAssembly(), typeof(T));
return value.Invoke(attribute);
}
}
}


}
4 changes: 1 addition & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,4 @@ Currently, the appsettings.json is being tracked by Git. Be careful when making

- Externalize IdentityResources
- Implement secrets.json with Docker for MongoSettings (Ref: https://blog.matjanowski.pl/2017/11/18/managing-options-and-secrets-in-net-core-and-docker/)
- Create permanent signing credential for Identity Server. Stop using `builder.AddDeveloperSigningCredential()`.

> Version 0.0.0.2
- Create permanent signing credential for Identity Server. Stop using `builder.AddDeveloperSigningCredential()`.

0 comments on commit 53dd98a

Please sign in to comment.