57 lines
1.5 KiB
YAML
57 lines
1.5 KiB
YAML
name: Publish NuGet Packages
|
|
|
|
on:
|
|
pull_request:
|
|
branches:
|
|
- main
|
|
workflow_dispatch:
|
|
|
|
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: 10.0.x
|
|
|
|
- name: Restore dependencies
|
|
run: dotnet restore
|
|
|
|
- name: Build all projects
|
|
run: dotnet build -c Release
|
|
|
|
- name: Pack all projects
|
|
run: |
|
|
for projfile in $(find . -name "*.csproj"); do
|
|
if grep -q "<GeneratePackageOnBuild>True</GeneratePackageOnBuild>" "$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: |
|
|
for pkg in ./artifacts/*.nupkg; do
|
|
# Skip if no files exist (in case globs fail)
|
|
[ -e "$pkg" ] || continue
|
|
|
|
# Skip symbol packages if they exist
|
|
if [[ "$pkg" == *".symbols.nupkg" ]]; then
|
|
continue
|
|
fi
|
|
|
|
echo "Pushing $pkg..."
|
|
dotnet nuget push "$pkg" \
|
|
--source "https://git.personalnas.com/api/packages/Misaki/nuget/index.json" \
|
|
--api-key "$NUGET_API_KEY" \
|
|
--skip-duplicate
|
|
done |