on:
  workflow_dispatch:

name: Release .NET SDK

jobs:
  release-sdks:
    name: release-dotnet
    runs-on: ubuntu-latest
    steps:
      - name: Checkout
        uses: actions/checkout@v3
      - name: Install extism shared library
        shell: bash
        run: |
          mkdir -p /home/runner/.local/bin/  
          export PATH="/home/runner/.local/bin/:$PATH"
          curl https://raw.githubusercontent.com/extism/cli/main/install.sh | sh
          extism --sudo --prefix /usr/local install
      - name: Setup .NET Core SDK
        uses: actions/setup-dotnet@v3.0.3
        with:
           dotnet-version: 7.x
      - name: Test .NET Sdk
        run: |
          cd dotnet
          LD_LIBRARY_PATH=/usr/local/lib dotnet test ./Extism.sln
      - name: Publish .NET Sdk
        run: |
          cd dotnet/src/Extism.Sdk/
          dotnet pack -c Release
          dotnet nuget push --source https://api.nuget.org/v3/index.json ./bin/Release/*.nupkg --api-key ${{ secrets.NUGET_API_KEY }}
