Skip to content

Commit f817df9

Browse files
committed
version updates, gha update
1 parent 7cbf00a commit f817df9

File tree

10 files changed

+145
-19
lines changed

10 files changed

+145
-19
lines changed
Lines changed: 122 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,122 @@
1+
2+
3+
name: Build, publish to gh pages and nuget
4+
5+
on:
6+
workflow_dispatch:
7+
inputs:
8+
new_version_blazorstatic:
9+
description: "Enter the new BlazorStatic version"
10+
required: true
11+
default: "1.0.0-beta.XX"
12+
13+
env:
14+
TEMPLATE_PROJ_PATH: BlazorStaticTemplates/BlazorStatic.Templates.csproj
15+
NUGET_FOLDER: nugetky
16+
17+
jobs:
18+
build:
19+
runs-on: ubuntu-latest
20+
permissions:
21+
contents: write
22+
23+
24+
25+
steps:
26+
- uses: actions/checkout@v4
27+
- uses: actions/setup-dotnet@v4
28+
with:
29+
dotnet-version: '9.0.x'
30+
31+
- name: Update .csproj files with new version
32+
run: |
33+
# Define the list of .csproj files
34+
csproj_files=(
35+
"templates/BlazorStaticMinimalBlogTemplate/BlazorStaticMinimalBlog.csproj"
36+
)
37+
38+
# Loop through each file and update the version
39+
for csproj_file in "${csproj_files[@]}"; do
40+
if [[ ! -f "$csproj_file" ]]; then
41+
echo "Error: $csproj_file does not exist."
42+
exit 1
43+
fi
44+
45+
# Replace the version in the .csproj file
46+
sed -i "s/<PackageReference Include=\"BlazorStatic\" Version=\"[^\"]*\"/<PackageReference Include=\"BlazorStatic\" Version=\"${{ github.event.inputs.new_version_blazorstatic }}\"/" "$csproj_file"
47+
48+
# Verify the update
49+
if grep -q "<PackageReference Include=\"BlazorStatic\" Version=\"${{ github.event.inputs.new_version_blazorstatic }}\"" "$csproj_file"; then
50+
echo "BlazorStatic version updated to ${{ github.event.inputs.new_version_blazorstatic }} in $csproj_file."
51+
else
52+
echo "Error: Failed to update the BlazorStatic version in $csproj_file."
53+
exit 1
54+
fi
55+
done
56+
57+
# Step 2: Read the current version from the BlazorStatic.Templates.csproj file
58+
- name: Extract current version
59+
id: extract-version
60+
run: |
61+
current_version=$(grep -oP '(?<=<PackageVersion>).*?(?=</PackageVersion>)' ./BlazorStatic.Templates.csproj)
62+
echo "current_version=$current_version" >> $GITHUB_ENV
63+
64+
# Step 3: Increment the version using the action
65+
- name: Increment version
66+
id: increment-version
67+
uses: christian-draeger/increment-semantic-version@v2
68+
with:
69+
current-version: ${{ env.current_version }}
70+
version-fragment: minor
71+
env:
72+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
73+
74+
75+
76+
- name: Update version in csproj
77+
run: |
78+
sed -i "s/<PackageVersion>${{ env.current_version }}<\/PackageVersion>/<PackageVersion>${{ steps.increment-version.outputs.next-version }}<\/PackageVersion>/" ./BlazorStatic.Templates.csproj
79+
80+
81+
82+
83+
- name: Create nuget BlazorStatic.Templates to destination folder
84+
run: |
85+
mkdir -p "${{ env.NUGET_FOLDER }}"
86+
dotnet pack BlazorStatic.Templates.csproj --output ${{ env.NUGET_FOLDER }}
87+
88+
# Step: Install package, create project, and build
89+
- name: Test Template Installation and Build
90+
run: |
91+
# Use the dynamically determined package version
92+
package_version="${{ steps.increment-version.outputs.next-version }}"
93+
94+
echo "Using package version: $package_version"
95+
96+
# Install the template package
97+
dotnet new install --force "bin/Release/BlazorStatic.Templates.${package_version}.nupkg"
98+
99+
# Create a new project from the template
100+
dotnet new BlazorStaticMinimalBlog -o "TestProject" --force
101+
102+
# Build the newly created project
103+
dotnet build "TestProject"
104+
105+
106+
# - uses: stefanzweifel/git-auto-commit-action@v5
107+
#
108+
# - name: Upload NuGet package artifacts
109+
# uses: actions/upload-artifact@v4
110+
# with:
111+
# name: nuget-packages
112+
# path: ${{ env.NUGET_FOLDER }}/*.nupkg
113+
#
114+
# publish-to-nuget:
115+
# needs: build
116+
# runs-on: ubuntu-latest
117+
# steps:
118+
# - name: Download NuGet package artifacts
119+
# uses: actions/download-artifact@v4
120+
# with:
121+
# name: nuget-packages
122+
# - run: dotnet nuget push "*.nupkg" --source "https://api.nuget.org/v3/index.json" --api-key ${{ secrets.NUGET_API_KEY_BLAZORSTATIC_TEMPLATES }}

BlazorStatic.Templates.csproj

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
<Authors>tesar.tech</Authors>
99
<Description>Templates for creating project for static websites using BlazorStatic.</Description>
1010
<PackageTags>dotnet-new;templates;blazor;static;website;generator;BlazorStatic</PackageTags>
11-
<TargetFramework>net8.0</TargetFramework>
11+
<TargetFramework>net9.0</TargetFramework>
1212

1313
<!-- Include content in the NuGet package -->
1414
<IncludeContentInPack>true</IncludeContentInPack>
@@ -18,21 +18,21 @@
1818
<NoDefaultExcludes>true</NoDefaultExcludes>
1919

2020
<PackageReadmeFile>README.md</PackageReadmeFile>
21-
<PackageLicenseExpression>AGPL-3.0-or-later</PackageLicenseExpression>
22-
<RepositoryUrl>https://github.com/tesar-tech/BlazorStatic/</RepositoryUrl>
21+
<PackageLicenseExpression>MIT</PackageLicenseExpression>
22+
<RepositoryUrl>https://github.com/BlazorStatic/BlazorStatic/</RepositoryUrl>
2323

2424

2525
</PropertyGroup>
2626

2727
<ItemGroup>
2828
<!-- Include all template files, excluding build folders -->
2929
<Content Include="templates\**\*" Exclude="templates\**\bin\**;templates\**\obj\**" />
30-
30+
3131
<!-- Remove any files from compilation, as these are templates -->
3232
<Compile Remove="**\*" />
3333
<None Include="README.md" Pack="true" PackagePath="\" />
3434

35-
35+
3636

3737
</ItemGroup>
3838
</Project>

pack_and_test.ps1

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
# Quick packing to see the result. Change the version if needed.
22

33
Write-Host "Packing the project..." -ForegroundColor Cyan
4-
dotnet pack
4+
dotnet pack /p:PackageVersion=1.0.0-test
55

66
Write-Host "Uninstalling the old template 'BlazorStatic.Templates'..." -ForegroundColor Cyan
77
dotnet new uninstall BlazorStatic.Templates
88

99
Write-Host "Installing the new template" -ForegroundColor Cyan
10-
dotnet new install --force "bin/Release/BlazorStatic.Templates.1.0.2.nupkg"
10+
dotnet new install --force "bin/Release/BlazorStatic.Templates.1.0.0-test.nupkg"
1111

1212
Write-Host "Removing the old 'TestProject' directory..." -ForegroundColor Cyan
13-
Remove-Item -Recurse -Force -Path ".\TestProject"
13+
Remove-Item -Recurse -Force -Path "./TestProject"
1414

1515
Write-Host "Creating a new project from the 'BlazorStaticMinimalBlog' template..." -ForegroundColor Cyan
16-
dotnet new BlazorStaticMinimalBlog -o "TestProject" --force -e
16+
dotnet new BlazorStaticMinimalBlog -o "TestProject" --force

templates/BlazorStaticMinimalBlogTemplate/.template-config/dotnetcli.host.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"symbolInfo": {
44
"ExcludeDefaultPosts": {
55
"longName": "exclude-default-posts",
6-
"shortName": "e"
6+
"shortName": "e",
77
}
88
}
99
}

templates/BlazorStaticMinimalBlogTemplate/.template-config/template.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,12 +37,12 @@
3737
{
3838
"condition": "true",
3939
"exclude": [
40-
"./BlazorStaticMinimalBlog/.git",
40+
"./.git",
4141
".git"
4242
]
4343
}
4444
],
45-
"source": "./BlazorStaticMinimalBlog"
45+
"source": "./"
4646
}
4747
],
4848
"symbols": {

templates/BlazorStaticMinimalBlogTemplate/BlazorStaticMinimalBlog.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
<Project Sdk="Microsoft.NET.Sdk.Web">
22

33
<PropertyGroup>
4-
<TargetFramework>net8.0</TargetFramework>
4+
<TargetFramework>net9.0</TargetFramework>
55
<Nullable>enable</Nullable>
66
<ImplicitUsings>enable</ImplicitUsings>
77
</PropertyGroup>
88

99
<ItemGroup>
10-
<PackageReference Include="BlazorStatic" Version="1.0.0-beta.13"/>
10+
<PackageReference Include="BlazorStatic" Version="1.0.0-beta.14"/>
1111
</ItemGroup>
1212

1313
<ItemGroup>

templates/BlazorStaticMinimalBlogTemplate/Components/Pages/Blog.razor

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@
9696
<div class="flex flex-wrap">
9797
@foreach(var tag in post.FrontMatter.Tags)
9898
{
99-
<a class="text-primary-500 hover:text-primary-400 mr-3 text-sm font-medium uppercase" href="@blazorStaticContentService.Options.TagsPageUrl/@tag">@tag</a>
99+
<a class="text-primary-500 hover:text-primary-400 mr-3 text-sm font-medium uppercase" href="@blazorStaticContentService.Options.Tags.TagsPageUrl/@tag">@tag</a>
100100
}
101101
</div>
102102
</div>

templates/BlazorStaticMinimalBlogTemplate/Components/Pages/Tags.razor

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,14 @@
1010
<div class="flex flex-wrap justify-evenly gap-1">
1111
@{
1212
var tagsWithCount = blazorStaticContentService.Posts
13-
.SelectMany(x => x.FrontMatter.Tags)
13+
.SelectMany(x => x.Tags)
1414
.GroupBy(x => x)
1515
.Select(group => new { Tag = group.Key, Count = group.Count() })
1616
.OrderByDescending(x => x.Count);
1717

18-
foreach(var tag in tagsWithCount)
18+
foreach(var tagGroup in tagsWithCount)
1919
{
20-
<a class="text-primary-500 hover:text-primary-400 mr-3 text-sm font-medium uppercase" href="@blazorStaticContentService.Options.TagsPageUrl/@WebUtility.HtmlEncode(tag.Tag)">@tag.Tag (@tag.Count)</a>
20+
<a class="text-primary-500 hover:text-primary-400 mr-3 text-sm font-medium uppercase" href="@($"{blazorStaticContentService.Options.Tags.TagsPageUrl}/{tagGroup.Tag.EncodedName}")">@tagGroup.Tag.Name</a>
2121
}
2222
}
2323
</div>

templates/BlazorStaticMinimalBlogTemplate/Components/PostsList.razor

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
<div class="flex flex-wrap">
3030
@foreach(var tag in post.FrontMatter.Tags)
3131
{
32-
<a class="text-primary-500 hover:text-primary-400 mr-3 text-sm font-medium uppercase" href="@blazorStaticContentService.Options.TagsPageUrl/@tag">@tag</a>
32+
<a class="text-primary-500 hover:text-primary-400 mr-3 text-sm font-medium uppercase" href="@blazorStaticContentService.Options.Tags.TagsPageUrl/@tag">@tag</a>
3333
}
3434
</div>
3535
</div>

templates/BlazorStaticMinimalBlogTemplate/Program.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
11
using BlazorStatic;
2+
using Microsoft.AspNetCore.Builder;
3+
using Microsoft.AspNetCore.Hosting;
4+
using Microsoft.Extensions.DependencyInjection;
5+
using Microsoft.Extensions.Hosting;
26
using BlazorStaticMinimalBlog.Components;
37

48
var builder = WebApplication.CreateBuilder(args);

0 commit comments

Comments
 (0)