name: Publish NuGet Package
permissions:
contents: read
packages: write
on:
push:
branches:
- main
paths:
- 'laicrypto/**'
- '.github/workflows/nuget.yml'
- 'README.md'
jobs:
publish:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: '6.0.x'
- name: Restore, Build & Pack
run: |
cd laicrypto
dotnet restore
dotnet build --configuration Release --no-restore
dotnet pack --configuration Release --no-build -o ./nupkg
- name: Push to NuGet.org
env:
NUGET_API_KEY: ${{ secrets.NUGET_API_KEY }}
run: |
cd laicrypto/nupkg
for pkg in *.nupkg; do
echo "Pushing $pkg to NuGet.org..."
dotnet nuget push "$pkg" \
--api-key "$NUGET_API_KEY" \
--source "https://api.nuget.org/v3/index.json" \
--skip-duplicate
done