85 lines
2.4 KiB
YAML
85 lines
2.4 KiB
YAML
name: NuGet Package Publish
|
|
|
|
on:
|
|
push:
|
|
|
|
jobs:
|
|
nuget:
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Setup .NET
|
|
uses: actions/setup-dotnet@v4
|
|
with:
|
|
dotnet-version: 10.0.x
|
|
|
|
- name: Restore
|
|
run: dotnet restore CBDDC.Libs.slnx
|
|
|
|
- name: Pack
|
|
run: dotnet pack CBDDC.Libs.slnx --configuration Release --no-restore --output artifacts/nuget
|
|
|
|
- name: Verify expected packages
|
|
shell: bash
|
|
run: |
|
|
set -euo pipefail
|
|
|
|
expected=(
|
|
"ZB.MOM.WW.CBDDC.Core"
|
|
"ZB.MOM.WW.CBDDC.Hosting"
|
|
"ZB.MOM.WW.CBDDC.Network"
|
|
"ZB.MOM.WW.CBDDC.Persistence"
|
|
)
|
|
|
|
for id in "${expected[@]}"; do
|
|
if ! compgen -G "artifacts/nuget/${id}.*.nupkg" > /dev/null; then
|
|
echo "Missing package for ${id}"
|
|
exit 1
|
|
fi
|
|
done
|
|
|
|
find artifacts/nuget -name '*.nupkg' ! -name '*.symbols.nupkg' -print
|
|
|
|
- name: Publish to Gitea NuGet
|
|
shell: bash
|
|
env:
|
|
NUGET_SOURCE_URL: ${{ github.server_url }}/api/packages/${{ github.repository_owner }}/nuget/index.json
|
|
NUGET_USERNAME: ${{ secrets.NUGET_USERNAME || github.repository_owner }}
|
|
NUGET_TOKEN: ${{ secrets.NUGET_TOKEN }}
|
|
run: |
|
|
set -euo pipefail
|
|
|
|
if [ -z "${NUGET_TOKEN:-}" ]; then
|
|
echo "Missing required secret: NUGET_TOKEN"
|
|
echo "Set repository Actions secret NUGET_TOKEN to a Gitea PAT with package write permission."
|
|
echo "Optional: set NUGET_USERNAME if your PAT owner differs from repository owner."
|
|
exit 1
|
|
fi
|
|
|
|
dotnet nuget add source "$NUGET_SOURCE_URL" \
|
|
--name gitea \
|
|
--username "$NUGET_USERNAME" \
|
|
--password "$NUGET_TOKEN" \
|
|
--store-password-in-clear-text
|
|
|
|
shopt -s nullglob
|
|
packages=(artifacts/nuget/*.nupkg)
|
|
if [ ${#packages[@]} -eq 0 ]; then
|
|
echo "No NuGet packages found to publish."
|
|
exit 1
|
|
fi
|
|
|
|
for pkg in "${packages[@]}"; do
|
|
if [[ "$pkg" == *.symbols.nupkg ]]; then
|
|
continue
|
|
fi
|
|
|
|
dotnet nuget push "$pkg" \
|
|
--source gitea \
|
|
--api-key "$NUGET_TOKEN" \
|
|
--skip-duplicate
|
|
done
|