Skip to content

Commit b544852

Browse files
committed
Add BCR configuration and workflow for Bazel Central Registry publishing
Signed-off-by: Matthieu MOREL <matthieu.morel35@gmail.com>
1 parent e5256b0 commit b544852

File tree

5 files changed

+191
-0
lines changed

5 files changed

+191
-0
lines changed

.bcr/README.md

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
# Bazel Central Registry (BCR) Publishing
2+
3+
This directory contains template files used to publish `proxy-wasm-cpp-sdk` to the [Bazel Central Registry](https://github.com/bazelbuild/bazel-central-registry).
4+
5+
## Overview
6+
7+
The BCR publishing automation uses these template files to create new entries in the Bazel Central Registry when a new release is tagged. This allows users to consume this SDK as a Bazel module using `bzlmod`.
8+
9+
## Files
10+
11+
### metadata.template.json
12+
13+
Contains metadata about the module including:
14+
- Homepage and repository URL
15+
- Maintainer information (populated from CODEOWNERS)
16+
- Version tracking
17+
18+
**Note**: The maintainer information is populated from the CODEOWNERS file. The `versions` field is automatically updated by the publishing workflow.
19+
20+
### source.template.json
21+
22+
Defines how to fetch the source code for a release:
23+
- Source archive URL pattern
24+
- Archive integrity hash (filled automatically)
25+
- Strip prefix for archive extraction
26+
27+
### presubmit.yml
28+
29+
Defines tests that run in BCR CI to validate each release:
30+
- Test targets to build/run
31+
- Bazel versions to test against
32+
- Platforms to test on
33+
34+
## Publishing Process
35+
36+
When a new tag is pushed (e.g., `v1.0.0`):
37+
38+
1. The GitHub Actions workflow (`.github/workflows/publish-to-bcr.yml`) is automatically triggered
39+
2. The workflow uses these template files to generate a BCR entry
40+
3. A pull request is opened against https://github.com/bazelbuild/bazel-central-registry
41+
4. Once approved by BCR maintainers, the PR is merged to publish the new version
42+
43+
## Maintainer Instructions
44+
45+
### Prerequisites
46+
47+
1. **Create a Personal Access Token (PAT)**:
48+
- Go to GitHub Settings > Developer settings > Personal access tokens > Tokens (classic)
49+
- Click "Generate new token (classic)"
50+
- Name it something like "BCR Publish Token"
51+
- Select scopes: `repo` (Full control of private repositories) and `workflow` (Update GitHub Action workflows)
52+
- Generate and copy the token
53+
54+
2. **Add the token as a repository secret**:
55+
- Go to your repository Settings > Secrets and variables > Actions
56+
- Click "New repository secret"
57+
- Name: `BCR_PUBLISH_TOKEN`
58+
- Value: Paste your PAT
59+
- Click "Add secret"
60+
61+
### Creating a Release
62+
63+
1. **Tag a new version**:
64+
```bash
65+
git tag -a v1.0.0 -m "Release v1.0.0"
66+
git push origin v1.0.0
67+
```
68+
69+
This will automatically trigger the "Publish to BCR" workflow.
70+
71+
2. **Monitor the publish workflow**:
72+
- Go to Actions tab in your repository
73+
- Find the "Publish to BCR" workflow run
74+
- Ensure it completes successfully
75+
- Check https://github.com/bazelbuild/bazel-central-registry for the new pull request
76+
77+
3. **Complete the BCR submission**:
78+
- Review the pull request in the BCR
79+
- Wait for BCR maintainers to review and merge
80+
81+
### Troubleshooting
82+
83+
- **Workflow fails with authentication error**: Check that `BCR_PUBLISH_TOKEN` secret is set correctly
84+
- **Workflow fails to create PR**: Ensure you have a fork of bazel-central-registry configured in the workflow
85+
- **BCR CI fails**: Review the `presubmit.yml` configuration and ensure test targets are correct
86+
- **Integrity hash mismatch**: Ensure the release archive is created correctly and hasn't been modified
87+
88+
## References
89+
90+
- [Bazel Central Registry](https://github.com/bazelbuild/bazel-central-registry)
91+
- [publish-to-bcr documentation](https://github.com/bazel-contrib/publish-to-bcr)
92+
- [Bzlmod User Guide](https://bazel.build/docs/bzlmod)

.bcr/metadata.template.json

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
{
2+
"homepage": "https://github.com/proxy-wasm/proxy-wasm-cpp-sdk",
3+
"maintainers": [
4+
{
5+
"name": "Piotr Sikora",
6+
"email": "piotrsikora@google.com",
7+
"github": "PiotrSikora",
8+
"github_user_id": 190297
9+
},
10+
{
11+
"name": "Martijn Eken",
12+
"email": "martijneken@google.com",
13+
"github": "martijneken",
14+
"github_user_id": 2081190
15+
},
16+
{
17+
"name": "Michael Warres",
18+
"email": "mpwarres@google.com",
19+
"github": "mpwarres",
20+
"github_user_id": 156047
21+
}
22+
],
23+
"repository": [
24+
"github:proxy-wasm/proxy-wasm-cpp-sdk"
25+
],
26+
"versions": [],
27+
"yanked_versions": {}
28+
}

.bcr/presubmit.yml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# Copyright 2025 Google LLC
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
matrix:
16+
platform: ["debian11", "macos", "ubuntu2204"]
17+
bazel: [6.x, 7.x, 8.x]
18+
tasks:
19+
verify_targets:
20+
name: "Build example WebAssembly modules"
21+
platform: ${{ platform }}
22+
bazel: ${{ bazel }}
23+
build_targets:
24+
- "@proxy-wasm-cpp-sdk//..."

.bcr/source.template.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"integrity": "",
3+
"strip_prefix": "{REPO}-{VERSION}",
4+
"url": "https://github.com/{OWNER}/{REPO}/archive/refs/tags/{TAG}.tar.gz"
5+
}
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
# Copyright 2025 Google LLC
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
name: Publish to BCR
16+
17+
on:
18+
# Automatic trigger when a tag is published
19+
push:
20+
tags:
21+
- 'v*'
22+
# Manual trigger for testing and initial setup
23+
workflow_dispatch:
24+
inputs:
25+
tag_name:
26+
description: 'Tag name to publish (e.g., v1.0.0)'
27+
required: true
28+
type: string
29+
30+
jobs:
31+
publish:
32+
permissions:
33+
contents: write
34+
id-token: write
35+
attestations: write
36+
uses: bazel-contrib/publish-to-bcr/.github/workflows/publish.yaml@v1
37+
with:
38+
tag_name: ${{ inputs.tag_name || github.ref_name }}
39+
registry_fork: bazelbuild/bazel-central-registry
40+
attest: false
41+
secrets:
42+
publish_token: ${{ secrets.BCR_PUBLISH_TOKEN }}

0 commit comments

Comments
 (0)