feat: Add CI and Release workflows for automated markdown linting, formatting checks, and deployment

This commit is contained in:
HueByte
2026-02-19 11:18:30 +01:00
parent defc5873fe
commit da7c16d5d0
2 changed files with 44 additions and 99 deletions
@@ -1,8 +1,11 @@
name: PR Check name: CI
on: on:
push:
branches: [master, dev]
pull_request: pull_request:
branches: [master, dev] branches: [master, dev]
workflow_dispatch:
jobs: jobs:
lint-markdown: lint-markdown:
@@ -23,36 +26,41 @@ jobs:
- name: Setup .NET 10 - name: Setup .NET 10
uses: actions/setup-dotnet@v4 uses: actions/setup-dotnet@v4
with: with:
dotnet-version: "10.0.x" dotnet-version: '10.0.x'
- name: Check formatting - name: Check formatting
run: dotnet format src/EchoHub.slnx --verify-no-changes --verbosity diagnostic run: dotnet format src/EchoHub.slnx --verify-no-changes --verbosity diagnostic
test: build-and-test:
name: Build & Test name: Build & Test
needs: [lint-markdown, format-check]
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: env:
EVENT: ${{ github.event_name }}
BEFORE: ${{ github.event.before }}
BASE_REF: ${{ github.base_ref }} BASE_REF: ${{ github.base_ref }}
run: | run: |
git fetch origin "$BASE_REF" --depth=1 if [ "$EVENT" = "pull_request" ]; then
CHANGED=$(git diff --name-only "origin/$BASE_REF"...HEAD -- 'src/' | wc -l) git fetch origin "$BASE_REF" --depth=1
if [ "$CHANGED" -gt 0 ]; then CHANGED=$(git diff --name-only "origin/$BASE_REF"...HEAD -- 'src/' | wc -l)
echo "src_changed=true" >> "$GITHUB_OUTPUT" elif [ -z "$BEFORE" ] || [ "$BEFORE" = "0000000000000000000000000000000000000000" ]; then
CHANGED=1
else else
echo "src_changed=false" >> "$GITHUB_OUTPUT" CHANGED=$(git diff --name-only "$BEFORE" HEAD -- 'src/' | wc -l)
fi fi
[ "$CHANGED" -gt 0 ] && echo "src_changed=true" >> "$GITHUB_OUTPUT" || echo "src_changed=false" >> "$GITHUB_OUTPUT"
- name: Setup .NET 10 - name: Setup .NET 10
if: steps.changes.outputs.src_changed == 'true' if: steps.changes.outputs.src_changed == 'true'
uses: actions/setup-dotnet@v4 uses: actions/setup-dotnet@v4
with: with:
dotnet-version: "10.0.x" dotnet-version: '10.0.x'
- name: Cache NuGet packages - name: Cache NuGet packages
if: steps.changes.outputs.src_changed == 'true' if: steps.changes.outputs.src_changed == 'true'
@@ -1,4 +1,4 @@
name: CI / Release name: Release
on: on:
push: push:
@@ -9,98 +9,28 @@ permissions:
contents: write contents: write
jobs: jobs:
lint-markdown: release:
name: Markdown Lint name: Create Release
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Run markdownlint
run: bash scripts/lint-markdown.sh
format-check:
name: Format Check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup .NET 10
uses: actions/setup-dotnet@v4
with:
dotnet-version: '10.0.x'
- name: Check formatting
run: dotnet format src/EchoHub.slnx --verify-no-changes --verbosity diagnostic
detect-changes:
name: Detect Changes
runs-on: ubuntu-latest
outputs:
src_changed: ${{ steps.check.outputs.src_changed }}
steps: steps:
- uses: actions/checkout@v4 - uses: actions/checkout@v4
with: with:
fetch-depth: 0 fetch-depth: 0
- name: Check for changes - name: Check for src/ changes
id: check id: changes
env: env:
BEFORE: ${{ github.event.before }} BEFORE: ${{ github.event.before }}
run: | run: |
if [ -z "$BEFORE" ] || [ "$BEFORE" = "0000000000000000000000000000000000000000" ]; then if [ -z "$BEFORE" ] || [ "$BEFORE" = "0000000000000000000000000000000000000000" ]; then
# workflow_dispatch or initial push — treat everything as changed
echo "src_changed=true" >> "$GITHUB_OUTPUT" echo "src_changed=true" >> "$GITHUB_OUTPUT"
else else
SRC_CHANGED=$(git diff --name-only "$BEFORE" HEAD -- 'src/' | wc -l) CHANGED=$(git diff --name-only "$BEFORE" HEAD -- 'src/' | wc -l)
[ "$CHANGED" -gt 0 ] && echo "src_changed=true" >> "$GITHUB_OUTPUT" || echo "src_changed=false" >> "$GITHUB_OUTPUT"
[ "$SRC_CHANGED" -gt 0 ] && echo "src_changed=true" >> "$GITHUB_OUTPUT" || echo "src_changed=false" >> "$GITHUB_OUTPUT"
fi fi
test:
name: Build & Test
needs: [lint-markdown, format-check, detect-changes]
if: needs.detect-changes.outputs.src_changed == 'true'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup .NET 10
uses: actions/setup-dotnet@v4
with:
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
run: dotnet restore src/EchoHub.slnx
- name: Build
run: dotnet build src/EchoHub.slnx --no-restore --configuration Release
- name: Test
run: dotnet test src/EchoHub.slnx --no-build --configuration Release --verbosity normal
release:
name: Create Release
needs: [lint-markdown, format-check, detect-changes, test]
if: needs.detect-changes.outputs.src_changed == 'true'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup .NET 10
uses: actions/setup-dotnet@v4
with:
dotnet-version: '10.0.x'
- name: Read version - name: Read version
if: steps.changes.outputs.src_changed == 'true'
id: version id: version
run: | run: |
VERSION=$(grep -oP '(?<=<Version>)[^<]+' src/Directory.Build.props) VERSION=$(grep -oP '(?<=<Version>)[^<]+' src/Directory.Build.props)
@@ -108,6 +38,7 @@ jobs:
echo "tag=v$VERSION" >> "$GITHUB_OUTPUT" echo "tag=v$VERSION" >> "$GITHUB_OUTPUT"
- name: Check if release exists - name: Check if release exists
if: steps.changes.outputs.src_changed == 'true'
id: check_release id: check_release
run: | run: |
if gh release view "${{ steps.version.outputs.tag }}" &>/dev/null; then if gh release view "${{ steps.version.outputs.tag }}" &>/dev/null; then
@@ -118,40 +49,46 @@ jobs:
env: env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Setup .NET 10
if: steps.changes.outputs.src_changed == 'true' && steps.check_release.outputs.exists == 'false'
uses: actions/setup-dotnet@v4
with:
dotnet-version: '10.0.x'
- name: Publish Server win-x64 - name: Publish Server win-x64
if: steps.check_release.outputs.exists == 'false' if: steps.changes.outputs.src_changed == 'true' && steps.check_release.outputs.exists == 'false'
run: dotnet publish src/EchoHub.Server/EchoHub.Server.csproj -c Release -r win-x64 --self-contained true -o publish/server-win-x64 run: dotnet publish src/EchoHub.Server/EchoHub.Server.csproj -c Release -r win-x64 --self-contained true -o publish/server-win-x64
- name: Publish Server linux-x64 - name: Publish Server linux-x64
if: steps.check_release.outputs.exists == 'false' if: steps.changes.outputs.src_changed == 'true' && steps.check_release.outputs.exists == 'false'
run: dotnet publish src/EchoHub.Server/EchoHub.Server.csproj -c Release -r linux-x64 --self-contained true -o publish/server-linux-x64 run: dotnet publish src/EchoHub.Server/EchoHub.Server.csproj -c Release -r linux-x64 --self-contained true -o publish/server-linux-x64
- name: Publish Server osx-x64 - name: Publish Server osx-x64
if: steps.check_release.outputs.exists == 'false' if: steps.changes.outputs.src_changed == 'true' && 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 - name: Publish Server osx-arm64
if: steps.check_release.outputs.exists == 'false' if: steps.changes.outputs.src_changed == 'true' && 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 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.changes.outputs.src_changed == 'true' && 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
- name: Publish Client linux-x64 - name: Publish Client linux-x64
if: steps.check_release.outputs.exists == 'false' if: steps.changes.outputs.src_changed == 'true' && steps.check_release.outputs.exists == 'false'
run: dotnet publish src/EchoHub.Client/EchoHub.Client.csproj -c Release -r linux-x64 --self-contained true -o publish/client-linux-x64 run: dotnet publish src/EchoHub.Client/EchoHub.Client.csproj -c Release -r linux-x64 --self-contained true -o publish/client-linux-x64
- name: Publish Client osx-x64 - name: Publish Client osx-x64
if: steps.check_release.outputs.exists == 'false' if: steps.changes.outputs.src_changed == 'true' && 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 - name: Publish Client osx-arm64
if: steps.check_release.outputs.exists == 'false' if: steps.changes.outputs.src_changed == 'true' && 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 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.changes.outputs.src_changed == 'true' && steps.check_release.outputs.exists == 'false'
run: | run: |
cd publish cd publish
zip -r ../EchoHub-Server-win-x64.zip server-win-x64/ zip -r ../EchoHub-Server-win-x64.zip server-win-x64/
@@ -164,7 +101,7 @@ jobs:
zip -r ../EchoHub-Client-osx-arm64.zip client-osx-arm64/ zip -r ../EchoHub-Client-osx-arm64.zip client-osx-arm64/
- name: Build release notes - name: Build release notes
if: steps.check_release.outputs.exists == 'false' if: steps.changes.outputs.src_changed == 'true' && steps.check_release.outputs.exists == 'false'
id: notes id: notes
run: | run: |
TAG="${{ steps.version.outputs.tag }}" TAG="${{ steps.version.outputs.tag }}"
@@ -196,7 +133,7 @@ jobs:
} >> "$GITHUB_OUTPUT" } >> "$GITHUB_OUTPUT"
- name: Create GitHub Release - name: Create GitHub Release
if: steps.check_release.outputs.exists == 'false' if: steps.changes.outputs.src_changed == 'true' && steps.check_release.outputs.exists == 'false'
run: | run: |
gh release create "${{ steps.version.outputs.tag }}" \ gh release create "${{ steps.version.outputs.tag }}" \
--title "EchoHub ${{ steps.version.outputs.tag }}" \ --title "EchoHub ${{ steps.version.outputs.tag }}" \