workflows: publish gazelle in a separate BCR pull request (#4413)

Publishing `rules_python` and `rules_python_gazelle_plugin` in a single
BCR pull request couples `rules_python_gazelle_plugin` presubmit and
review to `rules_python` releases.

Restrict the `publish` job to `.` and add a `publish_gazelle` job with
`module_roots: gazelle` so `rules_python_gazelle_plugin` is submitted in
its own BCR pull request.
diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml
index 146bdde..6212bb9 100644
--- a/.github/workflows/publish.yml
+++ b/.github/workflows/publish.yml
@@ -27,9 +27,25 @@
     uses: bazel-contrib/publish-to-bcr/.github/workflows/publish.yaml@v1.7.0
     with:
       tag_name: ${{ inputs.tag_name }}
-      module_roots: |
-        .
-        gazelle
+      module_roots: .
+      # GitHub repository which is a fork of the upstream where the Pull Request will be opened.
+      registry_fork: bazel-contrib/bazel-central-registry
+      attest: false
+      # Create non-draft PRs so the BCR bazel-io bot processes them. Otherwise,
+      # since a bazel-contrib bot, we have to wait for BCR maintainers to mark it
+      # non-draft or approve it.
+      draft: false
+    permissions:
+      contents: write
+    secrets:
+      # Necessary to push to the BCR fork, and to open a pull request against a registry
+      publish_token: ${{ secrets.publish_token || secrets.BCR_PUBLISH_TOKEN }}
+
+  publish_gazelle:
+    uses: bazel-contrib/publish-to-bcr/.github/workflows/publish.yaml@v1.7.0
+    with:
+      tag_name: ${{ inputs.tag_name }}
+      module_roots: gazelle
       # GitHub repository which is a fork of the upstream where the Pull Request will be opened.
       registry_fork: bazel-contrib/bazel-central-registry
       attest: false
diff --git a/tests/workflows/workflow_permissions_test.py b/tests/workflows/workflow_permissions_test.py
index 81153bd..b1c7057 100644
--- a/tests/workflows/workflow_permissions_test.py
+++ b/tests/workflows/workflow_permissions_test.py
@@ -145,8 +145,8 @@
     assert report_failure_needs == expected_needs
 
 
-def test_publish_bcr_splits_sphinxdocs_pr():
-    """Validates that publish.yml publishes sphinxdocs in a separate job."""
+def test_publish_bcr_splits_module_prs():
+    """Validates that publish.yml publishes each module root in a separate job."""
     rf = runfiles.CreateOrRaise()
     publish_path = rf.root() / "rules_python/.github/workflows/publish.yml"
     bcr_config_path = rf.root() / "rules_python/.bcr/config.yml"
@@ -155,15 +155,19 @@
     bcr_config = yaml.safe_load(bcr_config_path.read_text(encoding="utf-8"))
 
     jobs = publish_content["jobs"]
-    assert set(jobs.keys()) == {"publish", "publish_sphinxdocs"}
+    assert set(jobs.keys()) == {"publish", "publish_gazelle", "publish_sphinxdocs"}
 
     def _parse_module_roots(job: dict) -> list[str]:
         raw = job["with"]["module_roots"]
         return [line.strip() for line in raw.splitlines() if line.strip()]
 
     publish_roots = _parse_module_roots(jobs["publish"])
+    gazelle_roots = _parse_module_roots(jobs["publish_gazelle"])
     sphinxdocs_roots = _parse_module_roots(jobs["publish_sphinxdocs"])
 
-    assert publish_roots == [".", "gazelle"]
+    assert publish_roots == ["."]
+    assert gazelle_roots == ["gazelle"]
     assert sphinxdocs_roots == ["sphinxdocs"]
-    assert set(publish_roots) | set(sphinxdocs_roots) == set(bcr_config["moduleRoots"])
+    assert (set(publish_roots) | set(gazelle_roots) | set(sphinxdocs_roots)) == set(
+        bcr_config["moduleRoots"]
+    )