Skip to content

Commit 8ce087d

Browse files
Refactor CI/CD workflows and enhance NuGet packaging Refactored `build.yml` to separate build steps for `Component` and `Demo` projects, added a build summary, and removed code coverage and analysis steps. Updated `codeql.yml` with permissions, improved logging, and explicit builds for C# projects. Enhanced `deploy-pages.yml` with path triggers, GitHub Pages base path updates, SPA routing fixes, and file debugging steps. Refactored `nuget-publish.yml` to include dynamic versioning, targeted builds, improved artifact management, and package listing. Removed redundant `pages.yml` and `release.yml` workflows, consolidating functionality into other workflows. Enhanced `Component.csproj` with detailed NuGet metadata, inclusion of `README.md` and `logo.png` in the package, and enabled documentation file generation.
1 parent 3b069a3 commit 8ce087d

File tree

7 files changed

+80
-239
lines changed

7 files changed

+80
-239
lines changed

β€Ž.github/workflows/build.ymlβ€Ž

Lines changed: 10 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,6 @@ jobs:
1919
steps:
2020
- name: πŸ“₯ Checkout
2121
uses: actions/checkout@v4
22-
with:
23-
fetch-depth: 0 # برای GitVersion
2422

2523
- name: βš™οΈ Setup .NET
2624
uses: actions/setup-dotnet@v4
@@ -30,42 +28,16 @@ jobs:
3028
- name: πŸ“¦ Restore dependencies
3129
run: dotnet restore JsonViewer.Blazor.sln
3230

33-
- name: πŸ—οΈ Build
34-
run: dotnet build JsonViewer.Blazor.sln --no-restore --configuration Release
31+
- name: πŸ—οΈ Build Component
32+
run: dotnet build src/Component/Component.csproj --no-restore --configuration Release
3533

36-
- name: πŸ§ͺ Test
37-
run: dotnet test JsonViewer.Blazor.sln --no-build --configuration Release --verbosity normal
34+
- name: πŸ—οΈ Build Demo
35+
run: dotnet build src/Blazor.Demo/Blazor.Demo.csproj --no-restore --configuration Release
3836

39-
- name: πŸ“Š Code Coverage
37+
- name: βœ… Build Summary
4038
run: |
41-
dotnet test JsonViewer.Blazor.sln \
42-
--no-build \
43-
--configuration Release \
44-
--collect:"XPlat Code Coverage" \
45-
--results-directory ./coverage
46-
47-
- name: πŸ“€ Upload Coverage
48-
uses: codecov/codecov-action@v3
49-
with:
50-
directory: ./coverage
51-
fail_ci_if_error: false
52-
53-
analyze:
54-
name: πŸ” Code Analysis
55-
runs-on: ubuntu-latest
56-
57-
steps:
58-
- name: πŸ“₯ Checkout
59-
uses: actions/checkout@v4
60-
61-
- name: βš™οΈ Setup .NET
62-
uses: actions/setup-dotnet@v4
63-
with:
64-
dotnet-version: ${{ env.DOTNET_VERSION }}
65-
66-
- name: πŸ” Format Check
67-
run: dotnet format JsonViewer.Blazor.sln --verify-no-changes --no-restore
68-
69-
- name: πŸ“Š Code Analysis
70-
run: dotnet build JsonViewer.Blazor.sln -warnaserror
71-
39+
echo "## πŸ—οΈ Build Summary" >> $GITHUB_STEP_SUMMARY
40+
echo "" >> $GITHUB_STEP_SUMMARY
41+
echo "- **Component**: βœ… Built successfully" >> $GITHUB_STEP_SUMMARY
42+
echo "- **Demo**: βœ… Built successfully" >> $GITHUB_STEP_SUMMARY
43+
echo "- **.NET Version**: ${{ env.DOTNET_VERSION }}" >> $GITHUB_STEP_SUMMARY

β€Ž.github/workflows/codeql.ymlβ€Ž

Lines changed: 4 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ jobs:
1313
analyze:
1414
name: πŸ” Analyze ${{ matrix.language }}
1515
runs-on: ubuntu-latest
16-
16+
1717
permissions:
1818
actions: read
1919
contents: read
@@ -26,57 +26,39 @@ jobs:
2626
language: [ 'csharp', 'javascript' ]
2727

2828
steps:
29-
# ========================================
30-
# 1️⃣ Checkout Repository
31-
# ========================================
3229
- name: πŸ“₯ Checkout repository
3330
uses: actions/checkout@v4
3431

35-
# ========================================
36-
# 2️⃣ Setup .NET (فقط برای C#)
37-
# ========================================
3832
- name: πŸ”§ Setup .NET
3933
if: matrix.language == 'csharp'
4034
uses: actions/setup-dotnet@v4
4135
with:
4236
dotnet-version: '7.0.x'
4337

44-
# ========================================
45-
# 3️⃣ Initialize CodeQL
46-
# ========================================
4738
- name: βš™οΈ Initialize CodeQL
4839
uses: github/codeql-action/init@v3
4940
with:
5041
languages: ${{ matrix.language }}
5142
queries: security-extended,security-and-quality
5243

53-
# ========================================
54-
# 4️⃣ Build Project (Manual - فقط برای C#)
55-
# ========================================
5644
- name: πŸ—οΈ Build C# Projects
5745
if: matrix.language == 'csharp'
5846
run: |
5947
echo "πŸ“¦ Restoring dependencies..."
6048
dotnet restore JsonViewer.Blazor.sln
61-
49+
6250
echo "πŸ—οΈ Building Component..."
6351
dotnet build src/Component/Component.csproj -c Release --no-restore
64-
52+
6553
echo "πŸ—οΈ Building Demo..."
6654
dotnet build src/Blazor.Demo/Blazor.Demo.csproj -c Release --no-restore
67-
55+
6856
echo "βœ… Build completed"
6957
70-
# ========================================
71-
# 5️⃣ Autobuild (فقط برای JavaScript)
72-
# ========================================
7358
- name: πŸ—οΈ Autobuild JavaScript
7459
if: matrix.language == 'javascript'
7560
uses: github/codeql-action/autobuild@v3
7661

77-
# ========================================
78-
# 6️⃣ Perform CodeQL Analysis
79-
# ========================================
8062
- name: πŸ” Perform CodeQL Analysis
8163
uses: github/codeql-action/analyze@v3
8264
with:

β€Ž.github/workflows/deploy-pages.ymlβ€Ž

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@ name: πŸš€ Deploy to GitHub Pages
33
on:
44
push:
55
branches: [ main ]
6+
paths:
7+
- 'src/**'
8+
- '.github/workflows/deploy-pages.yml'
69
workflow_dispatch:
710

811
permissions:
@@ -46,16 +49,27 @@ jobs:
4649
-o release \
4750
--nologo
4851
49-
- name: πŸ”§ Configure base path
52+
- name: πŸ”§ Configure base path for GitHub Pages
5053
run: |
51-
sed -i 's/<base href="\/" \/>/<base href="\/Blazor\/" \/>/g' release/wwwroot/index.html
54+
# Fix base href for GitHub Pages subdirectory
55+
sed -i 's|<base href="/" />|<base href="/Blazor/" />|g' release/wwwroot/index.html
56+
echo "βœ… Base href updated to /Blazor/"
57+
grep "<base" release/wwwroot/index.html
5258
5359
- name: πŸ“ Add .nojekyll file
5460
run: touch release/wwwroot/.nojekyll
5561

56-
- name: πŸ“ Add custom 404.html
62+
- name: πŸ“ Create 404.html for SPA routing
5763
run: cp release/wwwroot/index.html release/wwwroot/404.html
5864

65+
- name: πŸ“‹ List published files
66+
run: |
67+
echo "πŸ“‚ Contents of release/wwwroot:"
68+
ls -la release/wwwroot/
69+
70+
- name: βš™οΈ Setup Pages
71+
uses: actions/configure-pages@v4
72+
5973
- name: πŸ“€ Upload artifact
6074
uses: actions/upload-pages-artifact@v3
6175
with:
@@ -74,4 +88,3 @@ jobs:
7488
- name: 🌐 Deploy to GitHub Pages
7589
id: deployment
7690
uses: actions/deploy-pages@v4
77-

β€Ž.github/workflows/nuget-publish.ymlβ€Ž

Lines changed: 26 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,7 @@ on:
88
version:
99
description: 'Version to publish (e.g., 1.0.0)'
1010
required: true
11-
prerelease:
12-
description: 'Is this a prerelease?'
13-
type: boolean
14-
default: false
11+
default: '0.0.3-beta'
1512

1613
env:
1714
DOTNET_VERSION: '7.0.x'
@@ -34,25 +31,40 @@ jobs:
3431
with:
3532
dotnet-version: ${{ env.DOTNET_VERSION }}
3633

34+
- name: πŸ” Determine Version
35+
id: version
36+
run: |
37+
if [ "${{ github.event_name }}" == "release" ]; then
38+
VERSION="${{ github.event.release.tag_name }}"
39+
# Remove 'v' prefix if present
40+
VERSION="${VERSION#v}"
41+
else
42+
VERSION="${{ github.event.inputs.version }}"
43+
fi
44+
echo "VERSION=$VERSION" >> $GITHUB_OUTPUT
45+
echo "πŸ“¦ Package Version: $VERSION"
46+
3747
- name: πŸ“¦ Restore dependencies
38-
run: dotnet restore JsonViewer.Blazor.sln
48+
run: dotnet restore ${{ env.PROJECT_PATH }}
3949

4050
- name: πŸ—οΈ Build
41-
run: dotnet build JsonViewer.Blazor.sln --configuration Release --no-restore
42-
43-
- name: πŸ§ͺ Run tests
44-
run: dotnet test JsonViewer.Blazor.sln --configuration Release --no-build --verbosity normal
51+
run: dotnet build ${{ env.PROJECT_PATH }} --configuration Release --no-restore
4552

4653
- name: πŸ“¦ Pack Component
4754
run: |
4855
dotnet pack ${{ env.PROJECT_PATH }} \
4956
--configuration Release \
5057
--no-build \
5158
--output ./packages \
52-
/p:PackageVersion=${{ github.event.inputs.version || github.event.release.tag_name }} \
59+
/p:PackageVersion=${{ steps.version.outputs.VERSION }} \
5360
/p:IncludeSymbols=true \
5461
/p:SymbolPackageFormat=snupkg
5562
63+
- name: πŸ“‹ List Packages
64+
run: |
65+
echo "πŸ“¦ Created packages:"
66+
ls -la ./packages/
67+
5668
- name: πŸš€ Push to NuGet
5769
run: |
5870
dotnet nuget push ./packages/*.nupkg \
@@ -61,17 +73,15 @@ jobs:
6173
--skip-duplicate
6274
6375
- name: πŸ“€ Upload NuGet Package Artifacts
64-
uses: actions/upload-artifact@v3
76+
uses: actions/upload-artifact@v4
6577
with:
6678
name: nuget-packages
67-
path: ./packages/*.nupkg
79+
path: ./packages/*
6880

69-
- name: πŸ“ Create Release Notes
70-
if: github.event_name == 'release'
81+
- name: πŸ“ Create Summary
7182
run: |
7283
echo "## πŸ“¦ NuGet Package Published" >> $GITHUB_STEP_SUMMARY
7384
echo "" >> $GITHUB_STEP_SUMMARY
7485
echo "- **Package**: JsonViewer.Blazor" >> $GITHUB_STEP_SUMMARY
75-
echo "- **Version**: ${{ github.event.release.tag_name }}" >> $GITHUB_STEP_SUMMARY
86+
echo "- **Version**: ${{ steps.version.outputs.VERSION }}" >> $GITHUB_STEP_SUMMARY
7687
echo "- **NuGet**: https://www.nuget.org/packages/JsonViewer.Blazor" >> $GITHUB_STEP_SUMMARY
77-

β€Ž.github/workflows/pages.ymlβ€Ž

Lines changed: 0 additions & 115 deletions
This file was deleted.

0 commit comments

Comments
Β (0)