name: release-please

on:
  push:
    branches: [master]
  workflow_dispatch:

jobs:
  release:
    runs-on: ubuntu-latest
    outputs:
      paths_released: ${{ steps.release-pl.outputs.paths_released }}
    permissions:
      contents: write
      issues: write
      pull-requests: write
    steps:
      - uses: googleapis/release-please-action@v4
        id: release-pl
        with:
          token: ${{ secrets.GITHUB_TOKEN }}
          config-file: release-please-config.json
          manifest-file: .release-please-manifest.json
  publish:
    runs-on: ubuntu-latest
    needs: release
    if: ${{ needs.release.outputs.paths_released && needs.release.outputs.paths_released != '[]' }}
    permissions:
      contents: read
      id-token: write
    steps:
      - uses: actions/checkout@v6
      - uses: ./.github/actions/setup-deps
      - name: Publish packages
        run: |
          for p in $(echo '${{ needs.release.outputs.paths_released }}' | jq -r '.[]'); do
            pnpm -r --filter "./$p" release
          done
