name: Publish

on:
  workflow_call:
  workflow_dispatch:
  push:
    branches: ['main']

permissions: read-all

jobs:
  build-test-lint:
    name: Build & Test & Lint
    uses: ./.github/workflows/build-test-lint.yml
    permissions: read-all
  publish:
    name: Publish
    needs: build-test-lint
    runs-on: ubuntu-latest
    permissions:
      contents: read
      packages: write
    steps:
      - name: Checkout
        uses: actions/checkout@v4
      - name: Setup .NET
        uses: actions/setup-dotnet@v4
        with:
          dotnet-version: '9.0'
      - name: Pack
        run: dotnet pack
      - name: Publish
        run: dotnet nuget push Libraries/**/*.nupkg --api-key ${{ secrets.GITHUB_TOKEN }} --source https://nuget.pkg.github.com/microsoft/index.json --skip-duplicate