From 20cb9c165613b705d4a699fe3cfe5304e72e2a3c Mon Sep 17 00:00:00 2001 From: Beto Harris Date: Wed, 9 Apr 2025 11:01:38 -0500 Subject: [PATCH 1/7] Add metadata and configuration templates for publishing to BCR --- .bcr/metadata.template.json | 13 +++++++++++++ .bcr/presubmit.yml | 14 ++++++++++++++ .bcr/source.template.json | 5 +++++ 3 files changed, 32 insertions(+) create mode 100644 .bcr/metadata.template.json create mode 100644 .bcr/presubmit.yml create mode 100644 .bcr/source.template.json diff --git a/.bcr/metadata.template.json b/.bcr/metadata.template.json new file mode 100644 index 00000000000..21b410a1cbe --- /dev/null +++ b/.bcr/metadata.template.json @@ -0,0 +1,13 @@ +{ + "homepage": "https://github.com/grpc-ecosystem/grpc-gateway", + "maintainers": [ + { + "name": "Johan Brandhorst-Satzkorn", + "email": "johan.brandhorst@gmail.com", + "github": "johanbrandhorst" + } + ], + "repository": ["github:grpc-ecosystem/grpc-gateway"], + "versions": [], + "yanked_versions": {} +} diff --git a/.bcr/presubmit.yml b/.bcr/presubmit.yml new file mode 100644 index 00000000000..057707288af --- /dev/null +++ b/.bcr/presubmit.yml @@ -0,0 +1,14 @@ +bcr_test_module: + module_path: "MODULE.bazel" + matrix: + platform: ["debian10", "macos", "ubuntu2004", "windows"] + bazel: [6.x, 7.x, 8.x] + tasks: + run_tests: + name: "Build and test grpc-gateway module" + platform: ${{ platform }} + bazel: ${{ bazel }} + build_targets: + - "//..." + test_targets: + - "//..." diff --git a/.bcr/source.template.json b/.bcr/source.template.json new file mode 100644 index 00000000000..20374716f33 --- /dev/null +++ b/.bcr/source.template.json @@ -0,0 +1,5 @@ +{ + "integrity": "", + "strip_prefix": "{REPO}-{VERSION}", + "url": "https://github.com/{OWNER}/{REPO}/releases/download/{TAG}/{REPO}-{TAG}.tar.gz" +} From c34a36e5629c6d22118f63fd61ac46ce5471cc23 Mon Sep 17 00:00:00 2001 From: Beto Harris Date: Fri, 11 Apr 2025 17:25:04 -0500 Subject: [PATCH 2/7] Point the homepage to the docs site --- .bcr/metadata.template.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.bcr/metadata.template.json b/.bcr/metadata.template.json index 21b410a1cbe..4b15db0e83c 100644 --- a/.bcr/metadata.template.json +++ b/.bcr/metadata.template.json @@ -1,5 +1,5 @@ { - "homepage": "https://github.com/grpc-ecosystem/grpc-gateway", + "homepage": "https://grpc-ecosystem.github.io/grpc-gateway", "maintainers": [ { "name": "Johan Brandhorst-Satzkorn", From 73a79681445b115b0357be0832adc8c362c65f64 Mon Sep 17 00:00:00 2001 From: Beto Harris Date: Fri, 11 Apr 2025 18:08:36 -0500 Subject: [PATCH 3/7] Add a readme for the publish to BCR section --- .bcr/README.md | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 .bcr/README.md diff --git a/.bcr/README.md b/.bcr/README.md new file mode 100644 index 00000000000..a605a36ed36 --- /dev/null +++ b/.bcr/README.md @@ -0,0 +1,24 @@ +# Configuration to use Publish to BCR + +This directory contains a set of templates required by the [publish-to-bcr](https://github.com/bazel-contrib/publish-to-bcr/tree/main) plugin, which will publish a released version of **gRPC-Gateway** as a new module in the [Bazel Central Registry](https://registry.bazel.build/). + +The plugin aims to eliminate a manual publishing process for the module and initiate the process when a release is created. + +## Publish to BCR template files + +The configuration consists of three files placed in the `.bcr` directory: + +* `.bcr/metadata.template.json`: that describes the repository and maintainers' information. +* `.bcr/presubmit.yml`: describes the targets that will be built and tested on specific platforms and bazel versions to test the module. +* `.bcr/source.template.json`: that will automatically substitute values for the repository, owner, and tag based on the repository and release data. + +_For more information regarding the files that form a BCR entry, check the following references:_ + +* [Bazel registries](https://bazel.build/external/registry). +* [External dependencies overview](https://bazel.build/external/overview). + +## Result + +The final result of this process is the creation of a PR in the BCR repository to publish the released version. + +Once these templates are populated, the `publish-to-bcr` app should be configured as described [here](https://github.com/bazel-contrib/publish-to-bcr/tree/main?tab=readme-ov-file#how-it-works). From edde27eb48e3a42238cb4502fa611fa895f60799 Mon Sep 17 00:00:00 2001 From: Beto Harris Date: Tue, 15 Apr 2025 18:54:28 -0500 Subject: [PATCH 4/7] Add a configuration to keep the bezel version up to date --- renovate.json | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/renovate.json b/renovate.json index 7f5ed72f2a9..8f43c47f9e2 100644 --- a/renovate.json +++ b/renovate.json @@ -9,6 +9,18 @@ "postUpdateOptions": [ "gomodTidy" ], + "customManagers": [ + { + "customType": "regex", + "fileMatch": [".bcr/presubmit.yml"], + "matchStrings": [ + "bazel:\\s*\\[(?[0-9.x,\\s]+)\\]" + ], + "depNameTemplate": "Bazel", + "datasourceTemplate": "bazel", + "versioningTemplate": "regex:^\\d+\\.x$" + } + ], "packageRules": [ { "updateTypes": [ From bdc77470010c238bc3392b9abbb944439429bd9d Mon Sep 17 00:00:00 2001 From: Beto Harris Date: Wed, 28 May 2025 17:19:15 -0500 Subject: [PATCH 5/7] Add the configuration to publish the module in BCR using GH Actions --- .github/workflows/publish.yml | 35 +++++++++++++++++++++++++++++++++++ .github/workflows/release.yml | 9 +++++++++ 2 files changed, 44 insertions(+) create mode 100644 .github/workflows/publish.yml diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml new file mode 100644 index 00000000000..92044233978 --- /dev/null +++ b/.github/workflows/publish.yml @@ -0,0 +1,35 @@ +# Publish new releases to Bazel Central Registry. +name: Publish to BCR +on: + # Run the publish workflow after a successful release + # Will be triggered from the release.yaml workflow + workflow_call: + inputs: + tag_name: + required: true + type: string + secrets: + publish_token: + required: true + # In case of problems, let release engineers retry by manually dispatching + # the workflow from the GitHub UI + workflow_dispatch: + inputs: + tag_name: + description: git tag being released + required: true + type: string +jobs: + publish: + uses: bazel-contrib/publish-to-bcr/.github/workflows/publish.yaml@v0.1.0 + with: + tag_name: ${{ inputs.tag_name }} + # GitHub repository which is a fork of the upstream where the Pull Request will be opened. + registry_fork: grpc-ecosystem/bazel-central-registry + permissions: + attestations: write + contents: write + id-token: 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 }} \ No newline at end of file diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 9e325b335fc..0fb45806c78 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -60,3 +60,12 @@ jobs: compile-generator: true # Workaround for https://github.com/slsa-framework/slsa-github-generator/issues/1163 base64-subjects: "${{ needs.goreleaser.outputs.hashes }}" upload-assets: ${{ github.event_name == 'push' }} # upload to a new release when pushing via tag + # Job to publish the release to the Bazel Central Registry. + publish: + needs: [goreleaser] + uses: .github/workflows/publish.yaml + with: + tag_name: ${{ github.ref_name }} + 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 }} \ No newline at end of file From 7e8fc970c6d3e7dc600aaa7fbc5926f6670d8046 Mon Sep 17 00:00:00 2001 From: Beto Harris Date: Wed, 28 May 2025 17:21:14 -0500 Subject: [PATCH 6/7] Update platform versions to test --- .bcr/presubmit.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.bcr/presubmit.yml b/.bcr/presubmit.yml index 057707288af..3ffd08e0b23 100644 --- a/.bcr/presubmit.yml +++ b/.bcr/presubmit.yml @@ -1,7 +1,7 @@ bcr_test_module: module_path: "MODULE.bazel" matrix: - platform: ["debian10", "macos", "ubuntu2004", "windows"] + platform: ["debian11", "macos", "macos_arm64", "ubuntu2404", "windows"] bazel: [6.x, 7.x, 8.x] tasks: run_tests: From 3e99ba656af212284241fc5dc2cf3a2f3efac46c Mon Sep 17 00:00:00 2001 From: Beto Harris Date: Wed, 28 May 2025 18:04:13 -0500 Subject: [PATCH 7/7] Enable automerge for bazel-contrib/publish-to-bcr to keep the reusable workflow up to date --- renovate.json | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/renovate.json b/renovate.json index 8f43c47f9e2..96420e1cef0 100644 --- a/renovate.json +++ b/renovate.json @@ -56,6 +56,15 @@ "slsa-framework/slsa-github-generator" ], "pinDigests": false + }, + { + "matchManagers": [ + "github-actions" + ], + "matchPackageNames": [ + "bazel-contrib/publish-to-bcr" + ], + "automerge": true } ] }