mirror of
https://github.com/RedWizardsLab/EchoHub.git
synced 2026-09-04 00:26:07 +02:00
feat: Enhance CI workflows to check for source and documentation changes, and cache NuGet packages
feat: Embed appsettings.json as a resource and update configuration loading logic
This commit is contained in:
@@ -30,25 +30,28 @@ jobs:
|
|||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
outputs:
|
outputs:
|
||||||
src_changed: ${{ steps.check.outputs.src_changed }}
|
src_changed: ${{ steps.check.outputs.src_changed }}
|
||||||
|
docs_changed: ${{ steps.check.outputs.docs_changed }}
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
with:
|
with:
|
||||||
fetch-depth: 0
|
fetch-depth: 0
|
||||||
|
|
||||||
- name: Check for src/ changes
|
- name: Check for changes
|
||||||
id: check
|
id: check
|
||||||
|
env:
|
||||||
|
BEFORE: ${{ github.event.before }}
|
||||||
run: |
|
run: |
|
||||||
BEFORE=${{ github.event.before }}
|
|
||||||
if [ "$BEFORE" = "0000000000000000000000000000000000000000" ]; then
|
if [ "$BEFORE" = "0000000000000000000000000000000000000000" ]; then
|
||||||
# Initial push — treat everything as changed
|
# Initial push — treat everything as changed
|
||||||
echo "src_changed=true" >> "$GITHUB_OUTPUT"
|
echo "src_changed=true" >> "$GITHUB_OUTPUT"
|
||||||
|
echo "docs_changed=true" >> "$GITHUB_OUTPUT"
|
||||||
else
|
else
|
||||||
CHANGED=$(git diff --name-only "$BEFORE" HEAD -- 'src/' | wc -l)
|
SRC_CHANGED=$(git diff --name-only "$BEFORE" HEAD -- 'src/' | wc -l)
|
||||||
if [ "$CHANGED" -gt 0 ]; then
|
DOCS_CHANGED=$(git diff --name-only "$BEFORE" HEAD -- 'docs/' | wc -l)
|
||||||
echo "src_changed=true" >> "$GITHUB_OUTPUT"
|
|
||||||
else
|
[ "$SRC_CHANGED" -gt 0 ] && echo "src_changed=true" >> "$GITHUB_OUTPUT" || echo "src_changed=false" >> "$GITHUB_OUTPUT"
|
||||||
echo "src_changed=false" >> "$GITHUB_OUTPUT"
|
# Docs rebuild on docs/ OR src/ changes (docfx reads XML comments from assemblies)
|
||||||
fi
|
[ "$DOCS_CHANGED" -gt 0 ] || [ "$SRC_CHANGED" -gt 0 ] && echo "docs_changed=true" >> "$GITHUB_OUTPUT" || echo "docs_changed=false" >> "$GITHUB_OUTPUT"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
test:
|
test:
|
||||||
@@ -64,6 +67,13 @@ jobs:
|
|||||||
with:
|
with:
|
||||||
dotnet-version: '10.0.x'
|
dotnet-version: '10.0.x'
|
||||||
|
|
||||||
|
- name: Cache NuGet packages
|
||||||
|
uses: actions/cache@v4
|
||||||
|
with:
|
||||||
|
path: ~/.nuget/packages
|
||||||
|
key: nuget-${{ runner.os }}-${{ hashFiles('src/**/*.csproj') }}
|
||||||
|
restore-keys: nuget-${{ runner.os }}-
|
||||||
|
|
||||||
- name: Restore dependencies
|
- name: Restore dependencies
|
||||||
run: dotnet restore src/EchoHub.slnx
|
run: dotnet restore src/EchoHub.slnx
|
||||||
|
|
||||||
@@ -118,6 +128,10 @@ jobs:
|
|||||||
# if: steps.check_release.outputs.exists == 'false'
|
# if: steps.check_release.outputs.exists == 'false'
|
||||||
# run: dotnet publish src/EchoHub.Server/EchoHub.Server.csproj -c Release -r osx-x64 --self-contained true -o publish/server-osx-x64
|
# run: dotnet publish src/EchoHub.Server/EchoHub.Server.csproj -c Release -r osx-x64 --self-contained true -o publish/server-osx-x64
|
||||||
#
|
#
|
||||||
|
# - name: Publish Server osx-arm64
|
||||||
|
# if: steps.check_release.outputs.exists == 'false'
|
||||||
|
# run: dotnet publish src/EchoHub.Server/EchoHub.Server.csproj -c Release -r osx-arm64 --self-contained true -o publish/server-osx-arm64
|
||||||
|
#
|
||||||
# - name: Publish Client win-x64
|
# - name: Publish Client win-x64
|
||||||
# if: steps.check_release.outputs.exists == 'false'
|
# if: steps.check_release.outputs.exists == 'false'
|
||||||
# run: dotnet publish src/EchoHub.Client/EchoHub.Client.csproj -c Release -r win-x64 --self-contained true -o publish/client-win-x64
|
# run: dotnet publish src/EchoHub.Client/EchoHub.Client.csproj -c Release -r win-x64 --self-contained true -o publish/client-win-x64
|
||||||
@@ -130,6 +144,10 @@ jobs:
|
|||||||
# if: steps.check_release.outputs.exists == 'false'
|
# if: steps.check_release.outputs.exists == 'false'
|
||||||
# run: dotnet publish src/EchoHub.Client/EchoHub.Client.csproj -c Release -r osx-x64 --self-contained true -o publish/client-osx-x64
|
# run: dotnet publish src/EchoHub.Client/EchoHub.Client.csproj -c Release -r osx-x64 --self-contained true -o publish/client-osx-x64
|
||||||
#
|
#
|
||||||
|
# - name: Publish Client osx-arm64
|
||||||
|
# if: steps.check_release.outputs.exists == 'false'
|
||||||
|
# run: dotnet publish src/EchoHub.Client/EchoHub.Client.csproj -c Release -r osx-arm64 --self-contained true -o publish/client-osx-arm64
|
||||||
|
#
|
||||||
# - name: Zip artifacts
|
# - name: Zip artifacts
|
||||||
# if: steps.check_release.outputs.exists == 'false'
|
# if: steps.check_release.outputs.exists == 'false'
|
||||||
# run: |
|
# run: |
|
||||||
@@ -137,9 +155,11 @@ jobs:
|
|||||||
# zip -r ../EchoHub-Server-win-x64.zip server-win-x64/
|
# zip -r ../EchoHub-Server-win-x64.zip server-win-x64/
|
||||||
# zip -r ../EchoHub-Server-linux-x64.zip server-linux-x64/
|
# zip -r ../EchoHub-Server-linux-x64.zip server-linux-x64/
|
||||||
# zip -r ../EchoHub-Server-osx-x64.zip server-osx-x64/
|
# zip -r ../EchoHub-Server-osx-x64.zip server-osx-x64/
|
||||||
|
# zip -r ../EchoHub-Server-osx-arm64.zip server-osx-arm64/
|
||||||
# zip -r ../EchoHub-Client-win-x64.zip client-win-x64/
|
# zip -r ../EchoHub-Client-win-x64.zip client-win-x64/
|
||||||
# zip -r ../EchoHub-Client-linux-x64.zip client-linux-x64/
|
# zip -r ../EchoHub-Client-linux-x64.zip client-linux-x64/
|
||||||
# zip -r ../EchoHub-Client-osx-x64.zip client-osx-x64/
|
# zip -r ../EchoHub-Client-osx-x64.zip client-osx-x64/
|
||||||
|
# zip -r ../EchoHub-Client-osx-arm64.zip client-osx-arm64/
|
||||||
#
|
#
|
||||||
# - name: Create GitHub Release
|
# - name: Create GitHub Release
|
||||||
# if: steps.check_release.outputs.exists == 'false'
|
# if: steps.check_release.outputs.exists == 'false'
|
||||||
@@ -150,15 +170,18 @@ jobs:
|
|||||||
# EchoHub-Server-win-x64.zip \
|
# EchoHub-Server-win-x64.zip \
|
||||||
# EchoHub-Server-linux-x64.zip \
|
# EchoHub-Server-linux-x64.zip \
|
||||||
# EchoHub-Server-osx-x64.zip \
|
# EchoHub-Server-osx-x64.zip \
|
||||||
|
# EchoHub-Server-osx-arm64.zip \
|
||||||
# EchoHub-Client-win-x64.zip \
|
# EchoHub-Client-win-x64.zip \
|
||||||
# EchoHub-Client-linux-x64.zip \
|
# EchoHub-Client-linux-x64.zip \
|
||||||
# EchoHub-Client-osx-x64.zip
|
# EchoHub-Client-osx-x64.zip \
|
||||||
|
# EchoHub-Client-osx-arm64.zip
|
||||||
# env:
|
# env:
|
||||||
# GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
# GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
|
||||||
docs:
|
docs:
|
||||||
name: Build & Deploy Docs
|
name: Build & Deploy Docs
|
||||||
needs: lint-markdown
|
needs: [lint-markdown, detect-changes]
|
||||||
|
if: needs.detect-changes.outputs.docs_changed == 'true'
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
@@ -168,6 +191,13 @@ jobs:
|
|||||||
with:
|
with:
|
||||||
dotnet-version: '10.0.x'
|
dotnet-version: '10.0.x'
|
||||||
|
|
||||||
|
- name: Cache NuGet packages
|
||||||
|
uses: actions/cache@v4
|
||||||
|
with:
|
||||||
|
path: ~/.nuget/packages
|
||||||
|
key: nuget-${{ runner.os }}-${{ hashFiles('src/**/*.csproj') }}
|
||||||
|
restore-keys: nuget-${{ runner.os }}-
|
||||||
|
|
||||||
- name: Restore .NET tools
|
- name: Restore .NET tools
|
||||||
run: dotnet tool restore
|
run: dotnet tool restore
|
||||||
|
|
||||||
|
|||||||
@@ -28,14 +28,14 @@ jobs:
|
|||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
with:
|
|
||||||
fetch-depth: 0
|
|
||||||
|
|
||||||
- name: Check for src/ changes
|
- name: Check for src/ changes
|
||||||
id: changes
|
id: changes
|
||||||
|
env:
|
||||||
|
BASE_REF: ${{ github.base_ref }}
|
||||||
run: |
|
run: |
|
||||||
git fetch origin ${{ github.base_ref }} --depth=1
|
git fetch origin "$BASE_REF" --depth=1
|
||||||
CHANGED=$(git diff --name-only origin/${{ github.base_ref }}...HEAD -- 'src/' | wc -l)
|
CHANGED=$(git diff --name-only "origin/$BASE_REF"...HEAD -- 'src/' | wc -l)
|
||||||
if [ "$CHANGED" -gt 0 ]; then
|
if [ "$CHANGED" -gt 0 ]; then
|
||||||
echo "src_changed=true" >> "$GITHUB_OUTPUT"
|
echo "src_changed=true" >> "$GITHUB_OUTPUT"
|
||||||
else
|
else
|
||||||
@@ -48,6 +48,14 @@ jobs:
|
|||||||
with:
|
with:
|
||||||
dotnet-version: '10.0.x'
|
dotnet-version: '10.0.x'
|
||||||
|
|
||||||
|
- name: Cache NuGet packages
|
||||||
|
if: steps.changes.outputs.src_changed == 'true'
|
||||||
|
uses: actions/cache@v4
|
||||||
|
with:
|
||||||
|
path: ~/.nuget/packages
|
||||||
|
key: nuget-${{ runner.os }}-${{ hashFiles('src/**/*.csproj') }}
|
||||||
|
restore-keys: nuget-${{ runner.os }}-
|
||||||
|
|
||||||
- name: Restore dependencies
|
- name: Restore dependencies
|
||||||
if: steps.changes.outputs.src_changed == 'true'
|
if: steps.changes.outputs.src_changed == 'true'
|
||||||
run: dotnet restore src/EchoHub.slnx
|
run: dotnet restore src/EchoHub.slnx
|
||||||
|
|||||||
@@ -17,6 +17,9 @@
|
|||||||
<Content Include="appsettings.json">
|
<Content Include="appsettings.json">
|
||||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||||
</Content>
|
</Content>
|
||||||
|
<EmbeddedResource Include="appsettings.json">
|
||||||
|
<LogicalName>EchoHub.Client.appsettings.json</LogicalName>
|
||||||
|
</EmbeddedResource>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
|
|||||||
@@ -5,9 +5,22 @@ using Microsoft.Extensions.Configuration;
|
|||||||
using Serilog;
|
using Serilog;
|
||||||
using Terminal.Gui.App;
|
using Terminal.Gui.App;
|
||||||
|
|
||||||
|
var appSettingsPath = Path.Combine(AppContext.BaseDirectory, "appsettings.json");
|
||||||
|
if (!File.Exists(appSettingsPath))
|
||||||
|
{
|
||||||
|
using var stream = typeof(AppOrchestrator).Assembly
|
||||||
|
.GetManifestResourceStream("EchoHub.Client.appsettings.json");
|
||||||
|
|
||||||
|
if (stream is not null)
|
||||||
|
{
|
||||||
|
using var file = File.Create(appSettingsPath);
|
||||||
|
stream.CopyTo(file);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
var configuration = new ConfigurationBuilder()
|
var configuration = new ConfigurationBuilder()
|
||||||
.SetBasePath(AppContext.BaseDirectory)
|
.SetBasePath(AppContext.BaseDirectory)
|
||||||
.AddJsonFile("appsettings.json", optional: false, reloadOnChange: false)
|
.AddJsonFile("appsettings.json", optional: true, reloadOnChange: false)
|
||||||
.Build();
|
.Build();
|
||||||
|
|
||||||
Log.Logger = new LoggerConfiguration()
|
Log.Logger = new LoggerConfiguration()
|
||||||
|
|||||||
Reference in New Issue
Block a user