Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions .bcr/README.md
Original file line number Diff line number Diff line change
@@ -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).
13 changes: 13 additions & 0 deletions .bcr/metadata.template.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"homepage": "https://grpc-ecosystem.github.io/grpc-gateway",
"maintainers": [
{
"name": "Johan Brandhorst-Satzkorn",
"email": "[email protected]",
"github": "johanbrandhorst"
}
],
"repository": ["github:grpc-ecosystem/grpc-gateway"],
"versions": [],
"yanked_versions": {}
}
14 changes: 14 additions & 0 deletions .bcr/presubmit.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
bcr_test_module:
module_path: "MODULE.bazel"
matrix:
platform: ["debian11", "macos", "macos_arm64", "ubuntu2404", "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:
- "//..."
5 changes: 5 additions & 0 deletions .bcr/source.template.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"integrity": "",
"strip_prefix": "{REPO}-{VERSION}",
"url": "https://github.com/{OWNER}/{REPO}/releases/download/{TAG}/{REPO}-{TAG}.tar.gz"
}
35 changes: 35 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -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/[email protected]
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 }}
Comment on lines +34 to +35
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I take it I need to create these tokens? Where can I get one? Why are there two?

9 changes: 9 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
21 changes: 21 additions & 0 deletions renovate.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,18 @@
"postUpdateOptions": [
"gomodTidy"
],
"customManagers": [
{
"customType": "regex",
"fileMatch": [".bcr/presubmit.yml"],
"matchStrings": [
"bazel:\\s*\\[(?<currentValue>[0-9.x,\\s]+)\\]"
],
"depNameTemplate": "Bazel",
"datasourceTemplate": "bazel",
"versioningTemplate": "regex:^\\d+\\.x$"
}
],
"packageRules": [
{
"updateTypes": [
Expand Down Expand Up @@ -44,6 +56,15 @@
"slsa-framework/slsa-github-generator"
],
"pinDigests": false
},
{
"matchManagers": [
"github-actions"
],
"matchPackageNames": [
"bazel-contrib/publish-to-bcr"
],
"automerge": true
}
]
}
Loading