name: release-please

on:
  push:
    branches:
      - main

permissions:
  contents: write
  pull-requests: write
  actions: write

jobs:
  release-please:
    if: github.repository == 'mdn/mdn-http-observatory'
    runs-on: ubuntu-latest
    steps:
      - name: Release
        uses: GoogleCloudPlatform/release-please-action@45996ed1f6d02564a971a2fa1b5860e934307cf7 # v5.0.0
        id: release
        with:
          config-file: .github/release-please-config.json
          manifest-file: .github/release-please-manifest.json
          token: ${{ secrets.RELEASE_PLEASE_GITHUB_TOKEN }}

      - name: Publish
        if: steps.release.outputs.release_created == 'true'
        run: |
          gh workflow run npm-publish.yml \
            --repo ${{ github.repository }} \
            --ref "$TAG_NAME" \
            -f tag="$TAG_NAME"
        env:
          GH_TOKEN: ${{ github.token }}
          TAG_NAME: ${{ steps.release.outputs.tag_name }}
