61 lines
1.8 KiB
YAML
61 lines
1.8 KiB
YAML
name: Publish NuGet Packages
|
|
|
|
on:
|
|
push:
|
|
tags:
|
|
- 'v*' # Trigger only on semantic version tags
|
|
|
|
jobs:
|
|
publish:
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
|
- name: Checkout repository
|
|
uses: actions/checkout@v3
|
|
|
|
- name: Setup .NET
|
|
uses: actions/setup-dotnet@v3
|
|
with:
|
|
dotnet-version: 9.0.x
|
|
|
|
- name: Restore dependencies
|
|
run: dotnet restore
|
|
|
|
- name: Build all projects
|
|
run: dotnet build -c Release
|
|
|
|
- name: Pack all projects
|
|
run: |
|
|
set -e
|
|
for projfile in $(find . -name "*.csproj"); do
|
|
if grep -q "<IsPackable>True</IsPackable>" "$projfile"; then
|
|
echo "Packing $projfile..."
|
|
if ! dotnet pack "$projfile" -c Release -o ./artifacts; then
|
|
echo "Failed to pack $projfile"
|
|
fi
|
|
fi
|
|
done
|
|
|
|
- name: Publish all packages
|
|
env:
|
|
NUGET_API_KEY: ${{ secrets.NUGET_TOKEN }}
|
|
run: |
|
|
set -x
|
|
set +e
|
|
for projfile in $(find . -name "*.csproj"); do
|
|
if grep -q "<IsPackable>True</IsPackable>" "$projfile"; then
|
|
projname=$(basename "$projfile" .csproj)
|
|
echo "Checking $projname..."
|
|
pkg=$(find "$projname/bin/Release" -maxdepth 1 -type f \
|
|
-name "$projname.*.nupkg" ! -name "*.symbols.nupkg" | sort -V | tail -n1)
|
|
if [ -n "$pkg" ]; then
|
|
echo "Pushing $pkg"
|
|
dotnet nuget push "$pkg" \
|
|
--source "https://git.personalnas.com/api/packages/Misaki/nuget/index.json" \
|
|
--api-key "$NUGET_API_KEY"
|
|
else
|
|
echo "No package found for $projname"
|
|
fi
|
|
fi
|
|
done
|