Skip to content

Commit 2ff7c48

Browse files
author
MPCoreDeveloper
committed
DI workflow for nuget packages order changed
1 parent 93637bd commit 2ff7c48

2 files changed

Lines changed: 149 additions & 6 deletions

File tree

.github/workflows/ci.yml

Lines changed: 80 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -204,14 +204,90 @@ jobs:
204204
name: nuget-packages
205205
path: ./artifacts
206206

207-
- name: Publish to NuGet.org
208-
run: dotnet nuget push ./artifacts/*.nupkg --api-key ${{ secrets.NUGET_API_KEY }} --source https://api.nuget.org/v3/index.json --skip-duplicate
209-
207+
- name: Publish packages in dependency order
208+
shell: bash
209+
env:
210+
NUGET_API_KEY: ${{ secrets.NUGET_API_KEY }}
211+
NUGET_SOURCE: https://api.nuget.org/v3/index.json
212+
run: |
213+
set -euo pipefail
214+
215+
push_layer() {
216+
local layer_name="$1"
217+
shift
218+
local found_any=false
219+
220+
echo "::group::Publishing $layer_name"
221+
for pattern in "$@"; do
222+
for pkg in ./artifacts/${pattern}; do
223+
[ -f "$pkg" ] || continue
224+
found_any=true
225+
echo " ↗ Pushing $(basename "$pkg")"
226+
dotnet nuget push "$pkg" \
227+
--api-key "$NUGET_API_KEY" \
228+
--source "$NUGET_SOURCE" \
229+
--skip-duplicate || true
230+
done
231+
done
232+
echo "::endgroup::"
233+
234+
# Wait for NuGet.org indexing before pushing the next layer
235+
if [ "$found_any" = true ]; then
236+
echo "⏳ Waiting 30s for NuGet.org to index $layer_name..."
237+
sleep 30
238+
fi
239+
}
240+
241+
# Layer 0 – no internal dependencies
242+
push_layer "Layer 0 (core)" \
243+
"SharpCoreDB.[0-9]*.nupkg" \
244+
"SharpCoreDB.Client.Protocol.*.nupkg" \
245+
"SharpCoreDB.Server.Protocol.*.nupkg"
246+
247+
# Layer 1 – depends on core only
248+
push_layer "Layer 1 (core dependents)" \
249+
"SharpCoreDB.Graph.[0-9]*.nupkg" \
250+
"SharpCoreDB.VectorSearch.*.nupkg" \
251+
"SharpCoreDB.Functional.[0-9]*.nupkg" \
252+
"SharpCoreDB.EventSourcing.*.nupkg" \
253+
"SharpCoreDB.Analytics.*.nupkg" \
254+
"SharpCoreDB.Distributed.*.nupkg" \
255+
"SharpCoreDB.Identity.*.nupkg" \
256+
"SharpCoreDB.Serilog.Sinks.*.nupkg"
257+
258+
# Layer 2 – depends on layer 1
259+
push_layer "Layer 2 (mid-level)" \
260+
"SharpCoreDB.Client.[0-9]*.nupkg" \
261+
"SharpCoreDB.EntityFrameworkCore.[0-9]*.nupkg" \
262+
"SharpCoreDB.Extensions.*.nupkg" \
263+
"SharpCoreDB.Data.Provider.*.nupkg" \
264+
"SharpCoreDB.Server.Core.*.nupkg" \
265+
"SharpCoreDB.CQRS.*.nupkg" \
266+
"SharpCoreDB.Projections.*.nupkg"
267+
268+
# Layer 3 – depends on layer 2
269+
push_layer "Layer 3 (top-level)" \
270+
"SharpCoreDB.Server.[0-9]*.nupkg" \
271+
"SharpCoreDB.Graph.Advanced.*.nupkg" \
272+
"SharpCoreDB.Provider.Sync.*.nupkg" \
273+
"SharpCoreDB.Provider.YesSql.*.nupkg" \
274+
"SharpCoreDB.Functional.Dapper.*.nupkg" \
275+
"SharpCoreDB.Functional.EntityFrameworkCore.*.nupkg"
276+
277+
# Catch any remaining packages not in the layers above
278+
push_layer "Remaining packages" \
279+
"*.nupkg"
280+
281+
echo "✅ All packages published in dependency order."
282+
210283
- name: Create release summary
211284
run: |
212-
echo "## 📦 NuGet Packages Published" >> $GITHUB_STEP_SUMMARY
285+
echo "## 📦 NuGet Packages Published (Dependency-Ordered)" >> $GITHUB_STEP_SUMMARY
213286
echo "" >> $GITHUB_STEP_SUMMARY
214287
echo "Published $(ls -1 ./artifacts/*.nupkg | wc -l) package(s) to NuGet.org" >> $GITHUB_STEP_SUMMARY
215288
echo "" >> $GITHUB_STEP_SUMMARY
289+
echo "Packages were published in 4 layers based on their dependency chain," >> $GITHUB_STEP_SUMMARY
290+
echo "with 30-second waits between layers for NuGet.org indexing." >> $GITHUB_STEP_SUMMARY
291+
echo "" >> $GITHUB_STEP_SUMMARY
216292
echo "### Packages" >> $GITHUB_STEP_SUMMARY
217293
ls -1 ./artifacts/*.nupkg | xargs -I {} basename {} >> $GITHUB_STEP_SUMMARY

.github/workflows/publish-manual.yml

Lines changed: 69 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,75 @@ jobs:
4343
- name: Pack NuGet packages
4444
run: dotnet pack SharpCoreDB.CI.slnf --configuration Release --output ./artifacts /p:ContinuousIntegrationBuild=true --configfile NuGet.Config
4545

46-
- name: Publish to NuGet.org
47-
run: dotnet nuget push ./artifacts/*.nupkg --api-key ${{ secrets.NUGET_API_KEY }} --source https://api.nuget.org/v3/index.json --skip-duplicate
46+
- name: Publish packages in dependency order
47+
shell: bash
48+
env:
49+
NUGET_API_KEY: ${{ secrets.NUGET_API_KEY }}
50+
NUGET_SOURCE: https://api.nuget.org/v3/index.json
51+
run: |
52+
set -euo pipefail
53+
54+
push_layer() {
55+
local layer_name="$1"
56+
shift
57+
local found_any=false
58+
59+
echo "::group::Publishing $layer_name"
60+
for pattern in "$@"; do
61+
for pkg in ./artifacts/${pattern}; do
62+
[ -f "$pkg" ] || continue
63+
found_any=true
64+
echo " ↗ Pushing $(basename "$pkg")"
65+
dotnet nuget push "$pkg" \
66+
--api-key "$NUGET_API_KEY" \
67+
--source "$NUGET_SOURCE" \
68+
--skip-duplicate || true
69+
done
70+
done
71+
echo "::endgroup::"
72+
73+
if [ "$found_any" = true ]; then
74+
echo "⏳ Waiting 30s for NuGet.org to index $layer_name..."
75+
sleep 30
76+
fi
77+
}
78+
79+
push_layer "Layer 0 (core)" \
80+
"SharpCoreDB.[0-9]*.nupkg" \
81+
"SharpCoreDB.Client.Protocol.*.nupkg" \
82+
"SharpCoreDB.Server.Protocol.*.nupkg"
83+
84+
push_layer "Layer 1 (core dependents)" \
85+
"SharpCoreDB.Graph.[0-9]*.nupkg" \
86+
"SharpCoreDB.VectorSearch.*.nupkg" \
87+
"SharpCoreDB.Functional.[0-9]*.nupkg" \
88+
"SharpCoreDB.EventSourcing.*.nupkg" \
89+
"SharpCoreDB.Analytics.*.nupkg" \
90+
"SharpCoreDB.Distributed.*.nupkg" \
91+
"SharpCoreDB.Identity.*.nupkg" \
92+
"SharpCoreDB.Serilog.Sinks.*.nupkg"
93+
94+
push_layer "Layer 2 (mid-level)" \
95+
"SharpCoreDB.Client.[0-9]*.nupkg" \
96+
"SharpCoreDB.EntityFrameworkCore.[0-9]*.nupkg" \
97+
"SharpCoreDB.Extensions.*.nupkg" \
98+
"SharpCoreDB.Data.Provider.*.nupkg" \
99+
"SharpCoreDB.Server.Core.*.nupkg" \
100+
"SharpCoreDB.CQRS.*.nupkg" \
101+
"SharpCoreDB.Projections.*.nupkg"
102+
103+
push_layer "Layer 3 (top-level)" \
104+
"SharpCoreDB.Server.[0-9]*.nupkg" \
105+
"SharpCoreDB.Graph.Advanced.*.nupkg" \
106+
"SharpCoreDB.Provider.Sync.*.nupkg" \
107+
"SharpCoreDB.Provider.YesSql.*.nupkg" \
108+
"SharpCoreDB.Functional.Dapper.*.nupkg" \
109+
"SharpCoreDB.Functional.EntityFrameworkCore.*.nupkg"
110+
111+
push_layer "Remaining packages" \
112+
"*.nupkg"
113+
114+
echo "✅ All packages published in dependency order."
48115
49116
- name: Create release summary
50117
run: |

0 commit comments

Comments
 (0)