name: Publish to BCR

on:
  # Allow manual triggering for testing and recovery
  workflow_dispatch:
    inputs:
      registry_fork:
        default: open-telemetry/bazel-central-registry
        description: The Bazel registry fork to push to when opening up a pull request"
        type: string
      tag_name:
        description: 'Tag name to publish (e.g., v1.24.0)'
        required: true
        type: string
  # Automatically trigger after a release is created
  release:
    types: [published]

permissions:
  contents: read

jobs:
  publish:
    permissions:
      contents: write
      id-token: write
      attestations: write
    uses: bazel-contrib/publish-to-bcr/.github/workflows/publish.yaml@0a23c53c2baffdaf2ce8dd23c2c0e45eb3b79093 # v1.2.0
    with:
      tag_name: ${{ inputs.tag_name || github.event.release.tag_name }}
      registry_fork: ${{ inputs.registry_fork || 'open-telemetry/bazel-central-registry' }}
      attest: true
    secrets:
      publish_token: ${{ secrets.BCR_PUBLISH_TOKEN }}
