Skip to content

Manual NuGet Publish #12

Manual NuGet Publish

Manual NuGet Publish #12

name: Manual NuGet Publish
on:
workflow_dispatch:
inputs:
reason:
description: 'Reason for manual publish'
required: false
default: 'Manual publish'
versionSuffix:
description: 'NuGet pre-release suffix (e.g. "preview.1" → 2.0.0-preview.1). Leave empty for a stable 2.0.0 publish.'
required: false
default: ''
packVersion:
description: 'Explicit full package version (e.g. 2.1.0-RC.2). Leave empty to use the version each project declares.'
required: false
default: ''
permissions:
contents: read
packages: write
env:
DOTNET_VERSION: '11.0.100-rc.1.26425.128'
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true
DOTNET_CLI_TELEMETRY_OPTOUT: true
DOTNET_NOLOGO: true
jobs:
publish:
name: Manually Publish to NuGet.org
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v7
with:
fetch-depth: 0
- name: Setup .NET 11 (RC)
uses: actions/setup-dotnet@v6
with:
dotnet-version: '11.0.100-rc.1.26425.128'
- name: Restore dependencies
run: dotnet restore SharpCoreDB.CI.slnf --configfile NuGet.Config
- name: Build
run: dotnet build SharpCoreDB.CI.slnf --configuration Release --no-restore /p:ContinuousIntegrationBuild=true
- name: Pack NuGet packages
shell: bash
env:
VERSION_SUFFIX: ${{ github.event.inputs.versionSuffix }}
EXPLICIT_VERSION: ${{ github.event.inputs.packVersion }}
run: |
PACK_ARGS=(
SharpCoreDB.CI.slnf
--configuration Release
--output ./artifacts
/p:ContinuousIntegrationBuild=true
--configfile NuGet.Config
)
if [ -n "$EXPLICIT_VERSION" ]; then
PACK_ARGS+=("/p:Version=${EXPLICIT_VERSION}")
echo "::warning::Publishing with explicit version ${EXPLICIT_VERSION}"
elif [ -n "$VERSION_SUFFIX" ]; then
PACK_ARGS+=("/p:VersionSuffix=${VERSION_SUFFIX}")
echo "::warning::Publishing PRE-RELEASE packages with suffix ${VERSION_SUFFIX}"
else
echo "Packing with the version declared by each project."
fi
echo "::group::Pack NuGet packages"
dotnet pack "${PACK_ARGS[@]}"
echo "::endgroup::"
- name: Publish packages in dependency order
shell: bash
env:
NUGET_API_KEY: ${{ secrets.NUGET_API_KEY }}
NUGET_SOURCE: https://api.nuget.org/v3/index.json
run: |
set -euo pipefail
push_layer() {
local layer_name="$1"
shift
local found_any=false
echo "::group::Publishing $layer_name"
for pattern in "$@"; do
for pkg in ./artifacts/${pattern}; do
[ -f "$pkg" ] || continue
found_any=true
echo " ↗ Pushing $(basename "$pkg")"
dotnet nuget push "$pkg" \
--api-key "$NUGET_API_KEY" \
--source "$NUGET_SOURCE" \
--skip-duplicate
done
done
echo "::endgroup::"
if [ "$found_any" = true ]; then
echo "⏳ Waiting 30s for NuGet.org to index $layer_name..."
sleep 30
fi
}
push_layer "Layer 0 (core)" \
"SharpCoreDB.[0-9]*.nupkg" \
"SharpCoreDB.Aspire.Hosting.*.nupkg" \
"SharpCoreDB.Client.Protocol.*.nupkg" \
"SharpCoreDB.Server.Protocol.*.nupkg"
push_layer "Layer 1 (core dependents)" \
"SharpCoreDB.Graph.[0-9]*.nupkg" \
"SharpCoreDB.VectorSearch.*.nupkg" \
"SharpCoreDB.Functional.[0-9]*.nupkg" \
"SharpCoreDB.EventSourcing.*.nupkg" \
"SharpCoreDB.Analytics.*.nupkg" \
"SharpCoreDB.Distributed.*.nupkg" \
"SharpCoreDB.Identity.*.nupkg" \
"SharpCoreDB.Serilog.Sinks.*.nupkg"
push_layer "Layer 2 (mid-level)" \
"SharpCoreDB.Client.[0-9]*.nupkg" \
"SharpCoreDB.EntityFrameworkCore.[0-9]*.nupkg" \
"SharpCoreDB.Extensions.*.nupkg" \
"SharpCoreDB.Data.Provider.*.nupkg" \
"SharpCoreDB.Server.Core.*.nupkg" \
"SharpCoreDB.CQRS.*.nupkg" \
"SharpCoreDB.Projections.*.nupkg"
push_layer "Layer 3 (top-level)" \
"SharpCoreDB.Server.[0-9]*.nupkg" \
"SharpCoreDB.Graph.Advanced.*.nupkg" \
"SharpCoreDB.Provider.Sync.*.nupkg" \
"SharpCoreDB.Provider.YesSql.*.nupkg" \
"SharpCoreDB.Functional.Dapper.*.nupkg" \
"SharpCoreDB.Functional.EntityFrameworkCore.*.nupkg" \
"SharpCoreDB.Functional.Linq2DB.*.nupkg"
push_layer "Remaining packages" \
"*.nupkg"
echo "✅ All packages published in dependency order."
- name: Create release summary
run: |
echo "## 📦 Manual NuGet Publish Completed" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "**Reason**: ${{ github.event.inputs.reason }}" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "Published $(ls -1 ./artifacts/*.nupkg | wc -l) package(s) to NuGet.org" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "### Packages" >> $GITHUB_STEP_SUMMARY
ls -1 ./artifacts/*.nupkg | xargs -I {} basename {} >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "**Triggered by**: @${{ github.actor }}" >> $GITHUB_STEP_SUMMARY
echo "**Commit**: ${{ github.sha }}" >> $GITHUB_STEP_SUMMARY