Skip to content

Commit d728a62

Browse files
authored
Merge pull request #737 from TechnologyEnhancedLearning/Develop/TD-4948
TD-4948-Update Semantic version Number for LH repo
2 parents 693d1d0 + e0acca5 commit d728a62

File tree

15 files changed

+1059
-873
lines changed

15 files changed

+1059
-873
lines changed

.github/azure-pipeline-webui-ci.yml

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,57 @@ jobs:
5151
inputs:
5252
command: restore
5353
projects: $(BuildParameters.RestoreBuildProjects)
54+
# Step 1: Get the version tag from the repository
55+
- script: |
56+
echo "Extracting version from Git tag: $(versionTag)"
57+
VERSION=$(echo $(versionTag) | sed 's/^v//')
58+
echo "VERSION=$VERSION" >> $(Build.ArtifactStagingDirectory)/version.txt
59+
displayName: 'Extract version tag'
60+
61+
# Step 2: Update AssemblyVersion in Web UI .csproj
62+
- powershell: |
63+
$versionFile = "$(Build.ArtifactStagingDirectory)/version.txt"
64+
$version = Get-Content $versionFile
65+
$version = $version.Trim()
66+
67+
# Path to your .csproj file (adjust if necessary)
68+
$csprojFile = "$(Build.SourcesDirectory)\LearningHub.Nhs.WebUI\LearningHub.Nhs.WebUI.csproj"
69+
70+
Write-Host "Updating AssemblyVersion and FileVersion and Version in $csprojFile to $version"
71+
72+
# Load the .csproj XML file
73+
[xml]$csprojXml = Get-Content -Path $csprojFile
74+
75+
# Update the AssemblyVersion and FileVersion
76+
$csprojXml.Project.PropertyGroup.AssemblyVersion = $version
77+
$csprojXml.Project.PropertyGroup.FileVersion = $version
78+
$csprojXml.Project.PropertyGroup.Version = $version
79+
80+
# Save the updated .csproj file
81+
$csprojXml.Save($csprojFile)
82+
displayName: 'Update AssemblyVersion in WebUI .csproj'
83+
# Step 2: Update AssemblyVersion in Admin UI .csproj
84+
- powershell: |
85+
$versionFile = "$(Build.ArtifactStagingDirectory)/version.txt"
86+
$version = Get-Content $versionFile
87+
$version = $version.Trim()
88+
89+
# Path to your .csproj file (adjust if necessary)
90+
$csprojFile = "$(Build.SourcesDirectory)\AdminUI\LearningHub.Nhs.AdminUI\LearningHub.Nhs.AdminUI.csproj"
91+
92+
Write-Host "Updating AssemblyVersion and FileVersion and Version in $csprojFile to $version"
93+
94+
# Load the .csproj XML file
95+
[xml]$csprojXml = Get-Content -Path $csprojFile
96+
97+
# Update the AssemblyVersion and FileVersion
98+
$csprojXml.Project.PropertyGroup.AssemblyVersion = $version
99+
$csprojXml.Project.PropertyGroup.FileVersion = $version
100+
$csprojXml.Project.PropertyGroup.Version = $version
101+
102+
# Save the updated .csproj file
103+
$csprojXml.Save($csprojFile)
104+
displayName: 'Update AssemblyVersion in AdminUI .csproj'
54105
- task: DotNetCoreCLI@2
55106
displayName: Build
56107
inputs:

AdminUI/LearningHub.Nhs.AdminUI/LearningHub.Nhs.AdminUI.csproj

Lines changed: 630 additions & 623 deletions
Large diffs are not rendered by default.

AdminUI/LearningHub.Nhs.AdminUI/ServiceCollectionExtension.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,7 @@ public static void ConfigureServices(this IServiceCollection services, IConfigur
141141

142142
services.AddTransient<CookieEventHandler>();
143143
services.AddSingleton<LogoutUserManager>();
144+
services.AddSingleton<VersionService>();
144145

145146
services.AddAuthentication(options =>
146147
{
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
namespace LearningHub.Nhs.AdminUI.Services
2+
{
3+
/// <summary>
4+
/// Defines the <see cref="VersionService" />.
5+
/// </summary>
6+
public class VersionService
7+
{
8+
/// <summary>
9+
/// The GetVersion.
10+
/// </summary>
11+
/// <returns>The <see cref="string"/>.</returns>
12+
public string GetVersion()
13+
{
14+
var version = typeof(Program).Assembly.GetName().Version;
15+
return $"{version?.Major}.{version?.Minor}.{version?.Build}";
16+
}
17+
}
18+
}
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
namespace LearningHub.Nhs.AdminUI.ViewComponents
2+
{
3+
using LearningHub.Nhs.AdminUI.Services;
4+
using Microsoft.AspNetCore.Html;
5+
using Microsoft.AspNetCore.Mvc;
6+
using Microsoft.AspNetCore.Mvc.ViewComponents;
7+
8+
/// <summary>
9+
/// Initializes a new instance of the <see cref="VersionViewComponent"/> class.
10+
/// </summary>
11+
public class VersionViewComponent : ViewComponent
12+
{
13+
private readonly VersionService versionService;
14+
15+
/// <summary>
16+
/// Initializes a new instance of the <see cref="VersionViewComponent"/> class.
17+
/// </summary>
18+
/// <param name="versionService">.</param>
19+
public VersionViewComponent(VersionService versionService)
20+
{
21+
this.versionService = versionService;
22+
}
23+
24+
/// <summary>
25+
/// The Invoke.
26+
/// </summary>
27+
/// <returns>A representing the result of the synchronous operation.</returns>
28+
public IViewComponentResult Invoke()
29+
{
30+
var version = this.versionService.GetVersion();
31+
return new HtmlContentViewComponentResult(new HtmlString($"<!-- Version: {version} -->"));
32+
}
33+
}
34+
}

AdminUI/LearningHub.Nhs.AdminUI/Views/Shared/_Layout.cshtml

Lines changed: 73 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -2,83 +2,83 @@
22
<!DOCTYPE html>
33
<html>
44
<head>
5-
<meta charset="utf-8" />
6-
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
7-
<title>@ViewData["Title"] - Learning Hub Administration</title>
8-
<link rel="apple-touch-icon" sizes="180x180" href="~/apple-touch-icon.png">
9-
<link rel="icon" type="image/png" sizes="32x32" href="~/favicon-32x32.png">
10-
<link rel="icon" type="image/png" sizes="16x16" href="~/favicon-16x16.png">
5+
<meta charset="utf-8" />
6+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
7+
<title>@ViewData["Title"] - Learning Hub Administration</title>
8+
<link rel="apple-touch-icon" sizes="180x180" href="~/apple-touch-icon.png">
9+
<link rel="icon" type="image/png" sizes="32x32" href="~/favicon-32x32.png">
10+
<link rel="icon" type="image/png" sizes="16x16" href="~/favicon-16x16.png">
1111

12-
<environment include="Development">
12+
<environment include="Development">
1313

14-
<link rel="stylesheet" href="~/lib/bootstrap/dist/css/bootstrap.css" />
15-
<link rel="stylesheet" type="text/css" href="~/lib/fontawesome-free-6.4.2-web/css/all.css"/>
16-
</environment>
17-
<environment exclude="Development">
18-
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.1.3/css/bootstrap.min.css"
19-
asp-fallback-href="~/lib/bootstrap/dist/css/bootstrap.min.css"
20-
asp-fallback-test-class="sr-only" asp-fallback-test-property="position" asp-fallback-test-value="absolute"
21-
crossorigin="anonymous"
22-
integrity="sha256-eSi1q2PG6J7g7ib17yAaWMcrr5GrtohYChqibrV7PBE=" />
23-
<link rel="stylesheet" type="text/css" href="~/lib/fontawesome-free-6.4.2-web/css/all.min.css" />
24-
</environment>
25-
<link rel="stylesheet" type="text/css" href="~/css/site.css" asp-append-version="true"/>
26-
<link rel="stylesheet" type="text/css" href="~/css/nhsuk/common.css"/>
27-
@RenderSection("Styles", required: false)
28-
@await Html.PartialAsync("_GoogleAnalytics")
29-
<partial name="~/Views/Shared/_TimezoneInfoScriptPartial.cshtml" />
14+
<link rel="stylesheet" href="~/lib/bootstrap/dist/css/bootstrap.css" />
15+
<link rel="stylesheet" type="text/css" href="~/lib/fontawesome-free-6.4.2-web/css/all.css" />
16+
</environment>
17+
<environment exclude="Development">
18+
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.1.3/css/bootstrap.min.css"
19+
asp-fallback-href="~/lib/bootstrap/dist/css/bootstrap.min.css"
20+
asp-fallback-test-class="sr-only" asp-fallback-test-property="position" asp-fallback-test-value="absolute"
21+
crossorigin="anonymous"
22+
integrity="sha256-eSi1q2PG6J7g7ib17yAaWMcrr5GrtohYChqibrV7PBE=" />
23+
<link rel="stylesheet" type="text/css" href="~/lib/fontawesome-free-6.4.2-web/css/all.min.css" />
24+
</environment>
25+
<link rel="stylesheet" type="text/css" href="~/css/site.css" asp-append-version="true" />
26+
<link rel="stylesheet" type="text/css" href="~/css/nhsuk/common.css" />
27+
@RenderSection("Styles", required: false)
28+
@await Html.PartialAsync("_GoogleAnalytics")
29+
<partial name="~/Views/Shared/_TimezoneInfoScriptPartial.cshtml" />
3030
</head>
3131
<body>
32-
<header role="banner" id="header">
33-
<partial name="~/Views/Shared/_NavPartial.cshtml" />
34-
</header>
35-
<div class="container-fluid">
36-
<!--<partial name="_CookieConsentPartial" />-->
37-
<main role="main" id="maincontent" tabindex="-1">
38-
@{
39-
var mainWidth = IsSectionDefined("SideMenu") ? "col-sm-9 col-lg-9 col-xl-10 pageWithMenu" : "col-sm-12";
40-
}
41-
<div class="row">
42-
@if (IsSectionDefined("SideMenu"))
43-
{
44-
<div class="col-sm-3 col-lg-3 col-xl-2 side-menu">
45-
@RenderSection("SideMenu", required: false)
46-
</div>
47-
}
48-
<div class="@mainWidth">
49-
@RenderBody()
50-
</div>
51-
</div>
52-
</main>
53-
</div>
54-
<footer class="border-top footer text-muted">
55-
<partial name="~/Views/Shared/_FooterPartial.cshtml" />
56-
</footer>
32+
<header role="banner" id="header">
33+
<partial name="~/Views/Shared/_NavPartial.cshtml" />
34+
</header>
35+
<div class="container-fluid">
36+
<!--<partial name="_CookieConsentPartial" />-->
37+
<main role="main" id="maincontent" tabindex="-1">
38+
@{
39+
var mainWidth = IsSectionDefined("SideMenu") ? "col-sm-9 col-lg-9 col-xl-10 pageWithMenu" : "col-sm-12";
40+
}
41+
<div class="row">
42+
@if (IsSectionDefined("SideMenu"))
43+
{
44+
<div class="col-sm-3 col-lg-3 col-xl-2 side-menu">
45+
@RenderSection("SideMenu", required: false)
46+
</div>
47+
}
48+
<div class="@mainWidth">
49+
@RenderBody()
50+
</div>
51+
</div>
52+
</main>
53+
</div>
54+
<footer class="border-top footer text-muted">
55+
<partial name="~/Views/Shared/_FooterPartial.cshtml" />
56+
</footer>
5757

58-
<environment include="Development">
59-
<script src="~/lib/jquery/dist/jquery.js"></script>
60-
<script src="~/lib/bootstrap/dist/js/bootstrap.bundle.js"></script>
61-
<script src="~/lib/ckeditor/ckeditor.js"></script>
62-
</environment>
63-
<environment exclude="Development">
64-
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"
65-
asp-fallback-src="~/lib/jquery/dist/jquery.min.js"
66-
asp-fallback-test="window.jQuery"
67-
crossorigin="anonymous"
68-
integrity="sha256-FgpCb/KJQlLNfOu91ta32o/NMZxltwRo8QtmkMRdAu8=">
69-
</script>
70-
<script src="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.1.3/js/bootstrap.bundle.min.js"
71-
asp-fallback-src="~/lib/bootstrap/dist/js/bootstrap.bundle.min.js"
72-
asp-fallback-test="window.jQuery && window.jQuery.fn && window.jQuery.fn.modal"
73-
crossorigin="anonymous"
74-
integrity="sha256-E/V4cWE4qvAeO5MOhjtGtqDzPndRO1LBk8lJ/PR7CA4=">
75-
</script>
76-
<script src="~/lib/ckeditor/ckeditor.js"></script>
77-
@*<script type="text/javascript" src="~/js/site.min.js"></script>*@
78-
</environment>
79-
@*<script type="text/javascript" src="~/js/bundle/header.js"></script>*@
80-
<partial name="~/Views/Shared/_ValidationScriptsPartial.cshtml" />
81-
@RenderSection("Scripts", required: false)
58+
<environment include="Development">
59+
<script src="~/lib/jquery/dist/jquery.js"></script>
60+
<script src="~/lib/bootstrap/dist/js/bootstrap.bundle.js"></script>
61+
<script src="~/lib/ckeditor/ckeditor.js"></script>
62+
</environment>
63+
<environment exclude="Development">
64+
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"
65+
asp-fallback-src="~/lib/jquery/dist/jquery.min.js"
66+
asp-fallback-test="window.jQuery"
67+
crossorigin="anonymous"
68+
integrity="sha256-FgpCb/KJQlLNfOu91ta32o/NMZxltwRo8QtmkMRdAu8=">
69+
</script>
70+
<script src="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.1.3/js/bootstrap.bundle.min.js"
71+
asp-fallback-src="~/lib/bootstrap/dist/js/bootstrap.bundle.min.js"
72+
asp-fallback-test="window.jQuery && window.jQuery.fn && window.jQuery.fn.modal"
73+
crossorigin="anonymous"
74+
integrity="sha256-E/V4cWE4qvAeO5MOhjtGtqDzPndRO1LBk8lJ/PR7CA4=">
75+
</script>
76+
<script src="~/lib/ckeditor/ckeditor.js"></script>
77+
@*<script type="text/javascript" src="~/js/site.min.js"></script>*@
78+
</environment>
79+
@*<script type="text/javascript" src="~/js/bundle/header.js"></script>*@
80+
<partial name="~/Views/Shared/_ValidationScriptsPartial.cshtml" />
81+
@RenderSection("Scripts", required: false)
8282
</body>
8383
</html>
84-
<!-- Build number: @settings.Value.BuildNumber -->
84+
@await Component.InvokeAsync("Version")

0 commit comments

Comments
 (0)