Skip to content

Commit 84c153c

Browse files
committed
Updated with product versions
1 parent d4eb30e commit 84c153c

File tree

3 files changed

+62
-4
lines changed

3 files changed

+62
-4
lines changed

WrapThat.Version/InfoController.cs

+31-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
using System.Reflection;
1+
using System.Diagnostics;
2+
using System.Reflection;
23
using Microsoft.AspNetCore.Authorization;
34
using Microsoft.AspNetCore.Mvc;
45

@@ -18,6 +19,17 @@ public ActionResult<string> Version()
1819
return Ok(version?.ToSemver());
1920
}
2021

22+
[HttpGet]
23+
[Route("productversion")]
24+
public ActionResult<string> ProductVersion()
25+
{
26+
var assembly = Assembly.GetEntryAssembly();
27+
var fileversioninfo = FileVersionInfo.GetVersionInfo(assembly.Location);
28+
return Ok(fileversioninfo.ProductVersion);
29+
}
30+
31+
32+
2133
[HttpGet]
2234
[AllowAnonymous]
2335
public ActionResult<string> Info()
@@ -27,6 +39,24 @@ public ActionResult<string> Info()
2739
return Ok(shields);
2840
}
2941

42+
[HttpGet]
43+
[AllowAnonymous]
44+
[Route("shields/version")]
45+
public ActionResult<string> InfoShields() => Info();
46+
47+
48+
[HttpGet]
49+
[Route("shields/productversion")]
50+
public ActionResult<string> ProductVersionShields()
51+
{
52+
var assembly= Assembly.GetEntryAssembly();
53+
var fileversioninfo = FileVersionInfo.GetVersionInfo(assembly.Location);
54+
var shields = new ShieldsIo("Version", fileversioninfo.ProductVersion);
55+
return Ok(shields);
56+
}
57+
58+
59+
3060
[HttpGet]
3161
[Route("status")]
3262
public ActionResult<string> Status()

WrapThat.Version/WrapThat.Version.csproj

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
<ImplicitUsings>enable</ImplicitUsings>
1414
<Nullable>enable</Nullable>
1515
<PackageId>WrapThat.Version</PackageId>
16-
<Version>0.9.3</Version>
16+
<Version>0.9.4</Version>
1717
</PropertyGroup>
1818

1919
<ItemGroup>

readme.md

+30-2
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ Install from nuget
66

77
## Usage
88

9-
Add this package to your main ASP.Net project, and it will add an Info endpoint with three methods, giving you the version of the main assembly in semver format.
9+
Add this package to your main ASP.Net project, and it will add an Info endpoint with five methods, giving you the version of the main assembly in semver format.
1010

1111
### Get version as a string
1212

@@ -17,10 +17,20 @@ returns
1717
1.2.3
1818
```
1919

20+
### Get product version as a string
21+
22+
```cs
23+
Route: /api/info/productversion
24+
25+
returns
26+
1.2.3-rc.1
27+
```
28+
29+
2030
### Get version as a [shields.io](https://shields.io/) structure
2131

2232
```cs
23-
Route: /api/info
33+
Route: /api/info/shields/version
2434

2535
returns shields io structure for use in a [shields endpoint](https://shields.io/endpoint) call.
2636
@@ -34,6 +44,24 @@ https://img.shields.io/endpoint?url=https://yourwebapi/api/info
3444

3545
And you get a lightgrey shields badge back, with label Version and your version number.
3646

47+
48+
### Get ProductVersion as a [shields.io](https://shields.io/) structure
49+
50+
```cs
51+
Route: /api/info/shields/productversion
52+
53+
returns shields io structure for use in a [shields endpoint](https://shields.io/endpoint) call.
54+
55+
```
56+
57+
You call this using shields like:
58+
59+
```
60+
https://img.shields.io/endpoint?url=https://yourwebapi/api/info/productversion
61+
```
62+
63+
And you get a lightgrey shields badge back, with label Version and your version number.
64+
3765
### Get version as a string authenticated
3866

3967
This is the same as the first method, except that it require authentication, if your API/app is set up for that. The intention is that you can use this to check if the authentication is actually working.

0 commit comments

Comments
 (0)