Skip to content

Commit

Permalink
Simplified Akka.Console template (#403)
Browse files Browse the repository at this point in the history
* Simplified Akka.Console template

close #401

* remove the `.App` suffix from `AkkaConsoleTemplate`

* remove all `.sln` material from `AkkaStreamsTemplate`

* streamlined `AkkaStreamsTemplate`

* cleaned up metadata for Akka.Streams template

* rebranding the WebApi template to `akkaclusterwebapi`

* added release notes bumping

* added `build.ps1` for release notes bumping

* added separate script for installing templates

* adding script to test templates

* fixed issues with WebApi template install

* removed `global.json`

* overhaul GitHub Actions

* make package install testing CI/CD friendly

* fixed Microsoft.Extensions.Hosting references

* simplified post-install scripts

* added Akka.Streams to testing matrix

* run tests on projects too

* cleaning up templates

* fixed end-to-end template testing

* just drop windows builds
  • Loading branch information
Aaronontheweb authored Jan 23, 2025
1 parent 4ab3ddb commit f3b6328
Show file tree
Hide file tree
Showing 50 changed files with 397 additions and 1,053 deletions.
70 changes: 22 additions & 48 deletions .github/workflows/pr_validation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,30 +12,12 @@ on:
merge_group:

jobs:
build-templates:
name: BuildTemplate
runs-on: ubuntu-latest
steps:
- name: "Checkout"
uses: actions/checkout@v4
with:
lfs: true
fetch-depth: 0
- name: "Install .NET SDK"
uses: actions/setup-dotnet@v4
with:
dotnet-version: |
8.0.x
global-json-file: "./global.json"
- name: "dotnet pack"
run: dotnet pack -c Release
test:
name: Test-${{matrix.template}}-${{matrix.os}}
name: Test-${{matrix.os}}
runs-on: ${{matrix.os}}
strategy:
matrix:
template: ["WebApiTemplate", "AkkaConsoleTemplate", "AkkaStreamsTemplate"]
os: [ubuntu-latest, windows-latest]
os: [ubuntu-latest,]
steps:
- name: "Checkout"
uses: actions/checkout@v4
Expand All @@ -47,33 +29,25 @@ jobs:
with:
dotnet-version: |
8.0.x
global-json-file: "./global.json"
- name: "dotnet build"
run: dotnet build -c Release
working-directory: src/${{matrix.template}}
- name: "dotnet test"
run: dotnet test -c Release
working-directory: src/${{matrix.template}}
9.0.x
- name: "Update release notes and version"
shell: pwsh
run: |
./build.ps1
- name: "dotnet pack"
run: dotnet pack -c Release -o bin/nuget

docker:
name: Docker-${{matrix.template}}
runs-on: ubuntu-latest
strategy:
matrix:
template: ["WebApiTemplate"]
steps:
- name: "Checkout"
uses: actions/checkout@v4
with:
lfs: true
fetch-depth: 0
- name: "Install .NET SDK"
uses: actions/setup-dotnet@v4
with:
dotnet-version: |
8.0.x
global-json-file: "./global.json"
- name: "dotnet docker"
run: dotnet publish --os linux --arch x64 -c Release -p:PublishProfile=DefaultContainer
working-directory: src/${{matrix.template}}
- name: "Install templates"
run: dotnet new install bin/nuget/*.nupkg

- name: "Test dev templates"
shell: pwsh
run: |
./scripts/test-templates.ps1
- name: Archive production artifacts
uses: actions/upload-artifact@v4
with:
name: package
path: |
bin/**/*.nupkg
2 changes: 1 addition & 1 deletion .github/workflows/publish_nuget.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
dotnet-version: ${{ env.DOTNET_VERSION }}

- name: Create Packages
run: dotnet pack /p:PackageVersion=${{ github.ref_name }} -c Release -o ./output
run: dotnet pack -c Release -o ./output

- name: Push Packages
run: dotnet nuget push "output/*.nupkg" -k ${{ secrets.NUGET_KEY }} -s https://api.nuget.org/v3/index.json
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ mono_crash.*
[Dd]ebugPublic/
[Rr]elease/
[Rr]eleases/
[oO]utput/
x64/
x86/
[Aa][Rr][Mm]/
Expand Down
10 changes: 4 additions & 6 deletions Akka.Templates.csproj
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<PackageType>Template</PackageType>
<PackageVersion>1.0</PackageVersion>
<VersionPrefix>1.0.0</VersionPrefix>
<PackageId>Akka.Templates</PackageId>
<Title>Akka.NET Project Templates</Title>
<Authors>AkkaDotNet</Authors>
<Description>Templates to use when creating new Akka.NET applications.</Description>
<PackageTags>dotnet-new;templates;akkadotnet;akka;</PackageTags>
<PackageReleaseNotes>* Simplified and renamed all Akka.Templates per [https://github.com/akkadotnet/akkadotnet-templates/issues/225](https://github.com/akkadotnet/akkadotnet-templates/issues/225)
* Upgraded to Akka.NET v1.5.36</PackageReleaseNotes>
<TargetFramework>netstandard2.0</TargetFramework>
<IncludeContentInPack>true</IncludeContentInPack>
<IncludeBuildOutput>false</IncludeBuildOutput>
Expand All @@ -20,15 +21,12 @@
<NoWarn>$(NoWarn);CS1591;xUnit1013</NoWarn>
<PackageReadmeFile>README.md</PackageReadmeFile>
</PropertyGroup>

<ItemGroup>
<Content Include="src\**\*" Exclude="src\**\bin\**;src\**\obj\**" />
<Compile Remove="**\*" />
</ItemGroup>

<ItemGroup>
<None Include="$(MSBuildThisFileDirectory)\logo.png" Pack="true" Visible="false" PackagePath="\" />
<None Include="$(MSBuildThisFileDirectory)\README.md" Pack="true" Visible="false" PackagePath="\" />
</ItemGroup>

</Project>
</Project>
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ The following templates are available as part of the `Akka.Templates` package:

| Template | Short Name | Description |
|--------------|-------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [Akka.WebApi](https://github.com/akkadotnet/akkadotnet-templates/blob/dev/docs/WebApiTemplate.md) | akkawebapi | A template for building ASP.NET HTTP APIs on top of an Akka.NET Cluster. Uses Akka.Cluster.Sharding and, optionally: Akka.Management + Akka.Persistence.Azure + Akka.Azure.Discovery. This template is meant as a starter for building distributed systems with Akka.NET |
| [Akka.Cluster.WebApi](https://github.com/akkadotnet/akkadotnet-templates/blob/dev/docs/WebApiTemplate.md) | akka.cluster.webapi | A template for building ASP.NET HTTP APIs on top of an Akka.NET Cluster. Uses Akka.Cluster.Sharding and, optionally: Akka.Management + Akka.Persistence.Azure + Akka.Azure.Discovery. This template is meant as a starter for building distributed systems with Akka.NET |
| [Akka.Console](https://github.com/akkadotnet/akkadotnet-templates/blob/dev/docs/ConsoleTemplate.md) | akkaconsole | This is a simple template designed to incorporate local [Akka.NET](https://getakka.net/) into a console application. |
| [Akka.Streams](https://github.com/akkadotnet/akkadotnet-templates/blob/dev/docs/AkkaStreamsTemplate.md) | akkastreams | This is a simple template designed to incorporate [Akka.NET](https://getakka.net/)'s [Akka.Streams APIs](https://getakka.net/articles/streams/introduction.html) into a local console template. |

Expand Down
5 changes: 3 additions & 2 deletions RELEASE_NOTES.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
## [0.4.1] / September 24 2024
#### 1.0.0 January 22 2025 ####

* Upgraded all Akka.NET dependenices to [Akka v1.5.28](https://github.com/akkadotnet/akka.net/releases/tag/1.5.28)
* Simplified and renamed all Akka.Templates per [https://github.com/akkadotnet/akkadotnet-templates/issues/225](https://github.com/akkadotnet/akkadotnet-templates/issues/225)
* Upgraded to Akka.NET v1.5.36
15 changes: 15 additions & 0 deletions build.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
. "$PSScriptRoot\scripts\getReleaseNotes.ps1"
. "$PSScriptRoot\scripts\bumpVersion.ps1"

Set-StrictMode -Version latest
$ErrorActionPreference = "Stop"

######################################################################
# Step 1: Grab release notes and update solution metadata
######################################################################
$releaseNotes = Get-ReleaseNotes -MarkdownFile (Join-Path -Path $PSScriptRoot -ChildPath "RELEASE_NOTES.md")

# inject release notes into Directory.Buil
UpdateVersionAndReleaseNotes -ReleaseNotesResult $releaseNotes -XmlFilePath (Join-Path -Path $PSScriptRoot -ChildPath "Akka.Templates.csproj")

Write-Output "Added release notes $releaseNotes"
6 changes: 3 additions & 3 deletions docs/WebApiTemplate.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# WebApiTemplate
# Akka.Cluster WebApiTemplate

This template is designed to integrate [Akka.NET](https://getakka.net/) with ASP.NET Web APIs.
This template is designed to integrate [Akka.NET](https://getakka.net/) Clusters with ASP.NET Web APIs.

## Installation

Expand All @@ -13,7 +13,7 @@ dotnet new -i "Akka.Templates::*"
From there, you can use this template via the following command:

```
dotnet new akkawebapi -n "your project name"
dotnet new akkaclusterwebapi -n "your project name"
```

## Usage
Expand Down
6 changes: 0 additions & 6 deletions global.json

This file was deleted.

27 changes: 27 additions & 0 deletions install-dev-templates.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Inspired by https://github.com/AvaloniaUI/avalonia-dotnet-templates/blob/main/install-dev-templates.ps1

######################################################################
# Step 2: Uninstall previous templates and clean output
######################################################################
dotnet new uninstall Akka.Templates
Remove-Item bin/**/*.nupkg

######################################################################
# Step 3: Pack new templates
######################################################################
dotnet pack -c Release
# Search Directory
$directoryPath = ".\bin\Release"

$latestNupkgFile = Get-ChildItem -Path $directoryPath -Recurse -Filter "*.nupkg" |
Where-Object { -not $_.PSIsContainer } |
Sort-Object LastWriteTime -Descending |
Select-Object -First 1

######################################################################
# Step 4: install the templates
######################################################################
if ($latestNupkgFile) {
$latestNupkgPath = $latestNupkgFile.FullName
dotnet new install $latestNupkgPath
}
28 changes: 28 additions & 0 deletions scripts/bumpVersion.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
function UpdateVersionAndReleaseNotes {
param (
[Parameter(Mandatory=$true)]
[PSCustomObject]$ReleaseNotesResult,

[Parameter(Mandatory=$true)]
[string]$XmlFilePath
)

# Load XML
$xmlContent = New-Object XML
$xmlContent.Load($XmlFilePath)

# Update VersionPrefix and PackageReleaseNotes
$versionPrefixElement = $xmlContent.SelectSingleNode("//VersionPrefix")
$versionPrefixElement.InnerText = $ReleaseNotesResult.Version

$packageReleaseNotesElement = $xmlContent.SelectSingleNode("//PackageReleaseNotes")
$packageReleaseNotesElement.InnerText = $ReleaseNotesResult.ReleaseNotes

# Save the updated XML
$xmlContent.Save($XmlFilePath)
}

# Usage example:
# $notes = Get-ReleaseNotes -MarkdownFile "$PSScriptRoot\RELEASE_NOTES.md"
# $propsPath = Join-Path -Path (Get-Item $PSScriptRoot).Parent.FullName -ChildPath "Directory.Build.props"
# UpdateVersionAndReleaseNotes -ReleaseNotesResult $notes -XmlFilePath $propsPath
44 changes: 44 additions & 0 deletions scripts/getReleaseNotes.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
function Get-ReleaseNotes {
param (
[Parameter(Mandatory=$true)]
[string]$MarkdownFile
)

# Read markdown file content
$content = Get-Content -Path $MarkdownFile -Raw

# Split content based on headers
$sections = $content -split "####"

# Output object to store result
$outputObject = [PSCustomObject]@{
Version = $null
Date = $null
ReleaseNotes = $null
}

# Check if we have at least 3 sections (1. Before the header, 2. Header, 3. Release notes)
if ($sections.Count -ge 3) {
$header = $sections[1].Trim()
$releaseNotes = $sections[2].Trim()

# Extract version and date from the header
$headerParts = $header -split " ", 2
if ($headerParts.Count -eq 2) {
$outputObject.Version = $headerParts[0]
$outputObject.Date = $headerParts[1]
}

$outputObject.ReleaseNotes = $releaseNotes
}

# Return the output object
return $outputObject
}

# Call function example:
#$result = Get-ReleaseNotes -MarkdownFile "$PSScriptRoot\RELEASE_NOTES.md"
#Write-Output "Version: $($result.Version)"
#Write-Output "Date: $($result.Date)"
#Write-Output "Release Notes:"
#Write-Output $result.ReleaseNotes
Loading

0 comments on commit f3b6328

Please sign in to comment.