Skip to content

Commit 6471e90

Browse files
Automated Release
1 parent 4c13bcc commit 6471e90

File tree

7 files changed

+88
-7
lines changed

7 files changed

+88
-7
lines changed

.github/workflows/gh-pages.yml

Lines changed: 33 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,27 @@ on: [push]
44

55
jobs:
66
build:
7-
87
runs-on: ubuntu-latest
9-
108
steps:
11-
- uses: actions/checkout@v2
9+
- uses: actions/checkout@v4
10+
with:
11+
fetch-depth: 0
1212
- name: Setup .NET
1313
uses: actions/setup-dotnet@v1
1414
with:
1515
dotnet-version: 8.0.x
16+
- name: Version Increment
17+
id: version
18+
uses: reecetech/[email protected]
19+
with:
20+
scheme: calver
21+
increment: patch
22+
- name: DotNet Bump Versions
23+
uses: SiqiLu/[email protected]
24+
with:
25+
version_files: "**/*.csproj"
26+
version_mask: "1.1.1.1"
27+
version_overwrite: "${{ steps.version.outputs.major-version }}.${{ steps.version.outputs.minor-version }}.${{ steps.version.outputs.patch-version }}.0"
1628
- name: Publish with dotnet
1729
run: dotnet publish ./src --configuration Release --output build
1830
- name: Deploy to Github Pages
@@ -21,5 +33,22 @@ jobs:
2133
ACCESS_TOKEN: ${{ secrets.ACCESS_TOKEN }}
2234
BASE_BRANCH: main # The branch the action should deploy from.
2335
BRANCH: gh-pages-from-actions # The branch the action should deploy to.
24-
FOLDER: build/wwwroot # The folder the action should deploy.
36+
FOLDER: build/wwwroot # The folder the action should deploy.
2537
SINGLE_COMMIT: true
38+
39+
release:
40+
runs-on: ubuntu-latest
41+
needs: [build]
42+
if: always() && !failure() && !cancelled()
43+
steps:
44+
- name: Version Increment
45+
id: version
46+
uses: reecetech/[email protected]
47+
with:
48+
scheme: calver
49+
use_api: true
50+
- uses: "marvinpinto/[email protected]"
51+
with:
52+
repo_token: "${{ secrets.GITHUB_TOKEN }}"
53+
prerelease: false
54+
automatic_release_tag: "v${{ steps.version.outputs.major-version }}.${{ steps.version.outputs.minor-version }}.${{ steps.version.outputs.patch-version }}"

src/MudBlazorPages/AppSettings.cs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
using System.Text.Json.Serialization;
2+
3+
namespace MudBlazorPages;
4+
5+
public class AppSettings
6+
{
7+
[JsonPropertyName("stringValue")]
8+
public string? StringValue { get; set; }
9+
10+
[JsonPropertyName("intValue")]
11+
public int IntValue { get; set; }
12+
}

src/MudBlazorPages/Layout/MainLayout.razor

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
@inherits LayoutComponentBase
2+
@inject NavigationManager NavigationManager
23

34
<MudThemeProvider />
45
<MudPopoverProvider />
@@ -24,7 +25,7 @@
2425
<main>
2526
<div class="top-row px-4">
2627
<MudIconButton Icon="@Icons.Custom.Brands.MudBlazor" Style="color: white;" Href="https://mudblazor.com/" Target="_blank" />
27-
<MudIconButton Icon="@Icons.Custom.Brands.GitHub" Style="color: white;" Href="https://github.com/MudBlazor/MudBlazor/" Target="_blank" />
28+
<MudIconButton Icon="@Icons.Custom.Brands.GitHub" Style="color: white;" Href="@GetGitHubUrl()" Target="_blank" />
2829
</div>
2930

3031
<MudContainer MaxWidth="MaxWidth.ExtraExtraLarge" Class="my-2 pt-2">
@@ -38,4 +39,26 @@
3839
<a href="" class="reload">Reload</a>
3940
<a class="dismiss">🗙</a>
4041
</div>
42+
@code {
43+
private string GetGitHubUrl()
44+
{
45+
const string DefaultGitHubUrl = "https://github.com/MudBlazorGitHubPages/mudblazorgithubpages.github.io";
4146

47+
var baseUrl = new Uri(NavigationManager.BaseUri);
48+
49+
if (baseUrl.Scheme == "https")
50+
{
51+
if (baseUrl.Host.EndsWith(".github.io"))
52+
{
53+
54+
var organizationName = baseUrl.Host.Replace(".github.io", string.Empty);
55+
var path = baseUrl.AbsolutePath.Replace("/", string.Empty);
56+
var repositoryName = path != string.Empty ? path : $"{organizationName}.github.io";
57+
58+
return $"https://github.com/{organizationName}/{repositoryName}";
59+
}
60+
}
61+
62+
return DefaultGitHubUrl;
63+
}
64+
}

src/MudBlazorPages/Layout/NavMenu.razor

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,9 @@
22
<MudNavLink Href="" Match="NavLinkMatch.All" Icon="@Icons.Material.Filled.Home">Home</MudNavLink>
33
<MudNavLink Href="counter" Match="NavLinkMatch.Prefix" Icon="@Icons.Material.Filled.Add">Counter</MudNavLink>
44
<MudNavLink Href="weather" Match="NavLinkMatch.Prefix" Icon="@Icons.Material.Filled.List">Weather</MudNavLink>
5-
5+
<MudDivider Class="my-2" />
6+
<MudStack Row="true">
7+
<MudSpacer/>
8+
<MudText>Version @this.GetType().Assembly.GetName().Version?.ToString(3)</MudText>
9+
</MudStack>
610
</MudNavMenu>

src/MudBlazorPages/MudBlazorPages.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
<Nullable>enable</Nullable>
66
<ImplicitUsings>enable</ImplicitUsings>
77
<ServiceWorkerAssetsManifest>service-worker-assets.js</ServiceWorkerAssetsManifest>
8+
<AssemblyVersion>1.0.0</AssemblyVersion>
89
</PropertyGroup>
910

1011

src/MudBlazorPages/Program.cs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,21 @@
1+
using System.Net.Http.Json;
12
using Blazored.LocalStorage;
23
using Microsoft.AspNetCore.Components.Web;
34
using Microsoft.AspNetCore.Components.WebAssembly.Hosting;
45
using MudBlazor.Services;
6+
using static System.Net.WebRequestMethods;
7+
using System.Text.Json.Serialization;
8+
using MudBlazorPages;
59

610
var builder = WebAssemblyHostBuilder.CreateDefault(args);
711
builder.RootComponents.Add<MudBlazorPages.App>("#app");
812
builder.RootComponents.Add<HeadOutlet>("head::after");
913

10-
builder.Services.AddScoped(sp => new HttpClient { BaseAddress = new Uri(builder.HostEnvironment.BaseAddress) });
14+
var http = new HttpClient { BaseAddress = new Uri(builder.HostEnvironment.BaseAddress) };
15+
builder.Services.AddScoped(sp => http);
16+
17+
var appSettings = await http.GetFromJsonAsync<AppSettings>("appsettings.json", new System.Text.Json.JsonSerializerOptions() { Converters = { new JsonStringEnumConverter() } });
18+
builder.Services.AddSingleton(appSettings ?? new());
1119

1220
builder.Services.AddMudServices();
1321

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"stringValue": "Example String Value",
3+
"intValue": 4
4+
}

0 commit comments

Comments
 (0)