Skip to content

Commit 92d5660

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

File tree

5 files changed

+173
-0
lines changed

5 files changed

+173
-0
lines changed

.bcr/README.md

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
# BCR Publishing Templates
2+
3+
This directory contains templates used by the [Publish to BCR](https://github.com/bazel-contrib/publish-to-bcr) GitHub Action to automatically publish new versions of proxy-wasm-rust-sdk to the [Bazel Central Registry (BCR)](https://github.com/bazelbuild/bazel-central-registry).
4+
5+
## Files
6+
7+
- **metadata.template.json**: Contains repository metadata including homepage, maintainers, and repository location
8+
- **source.template.json**: Template for generating the source.json file that tells BCR where to download release archives
9+
- **presubmit.yml**: Defines build and test tasks that BCR will run to verify each published version
10+
11+
## How it works
12+
13+
When a new tag matching the pattern `v*.*.*` is created:
14+
1. The GitHub Actions workflow triggers the Publish to BCR action
15+
2. The workflow uses these templates to generate a BCR entry
16+
3. A pull request is automatically created against the Bazel Central Registry
17+
4. Once merged, the new version becomes available to Bazel users via bzlmod
18+
19+
## Template Variables
20+
21+
The following variables are automatically substituted:
22+
- `{OWNER}`: Repository owner (proxy-wasm)
23+
- `{REPO}`: Repository name (proxy-wasm-rust-sdk)
24+
- `{VERSION}`: Version number extracted from the tag (e.g., `0.2.5` from `v0.2.5`)
25+
- `{TAG}`: Full tag name (e.g., `v0.2.5`)
26+
27+
## Setup Requirements
28+
29+
Before publishing to BCR can work, the following setup is required:
30+
31+
### 1. Fork the Bazel Central Registry
32+
33+
Create a fork of [bazelbuild/bazel-central-registry](https://github.com/bazelbuild/bazel-central-registry) in your GitHub account or organization. This fork is used to create pull requests against the upstream BCR.
34+
35+
### 2. Create a Personal Access Token (PAT)
36+
37+
Create a "Classic" Personal Access Token with the following permissions:
38+
- **repo**: Full control of private repositories (required to push to the BCR fork)
39+
- **workflow**: Update GitHub Action workflows (required to trigger workflows)
40+
41+
To create the token:
42+
1. Go to GitHub Settings → Developer settings → Personal access tokens → Tokens (classic)
43+
2. Click "Generate new token (classic)"
44+
3. Give it a descriptive name (e.g., "BCR Publish Token")
45+
4. Select the `repo` and `workflow` scopes
46+
5. Click "Generate token" and copy the token value
47+
48+
> **Note**: Fine-grained PATs are not fully supported yet because they cannot open pull requests against public repositories.
49+
50+
### 3. Configure the Repository Secret
51+
52+
Add the PAT as a repository secret named `BCR_PUBLISH_TOKEN`:
53+
1. Go to your repository Settings → Secrets and variables → Actions
54+
2. Click "New repository secret"
55+
3. Name: `BCR_PUBLISH_TOKEN`
56+
4. Value: Paste the PAT created in step 2
57+
5. Click "Add secret"
58+
59+
### 4. Configure the Registry Fork (Optional)
60+
61+
If your BCR fork is not in the same organization as this repository, you may need to update the workflow in `.github/workflows/publish-to-bcr.yml` to specify the `registry_fork` parameter.
62+
63+
## More Information
64+
65+
- [Publish to BCR documentation](https://github.com/bazel-contrib/publish-to-bcr)
66+
- [BCR documentation](https://bazel.build/external/registry)

.bcr/metadata.template.json

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
"homepage": "https://github.com/proxy-wasm/proxy-wasm-rust-sdk",
3+
"maintainers": [
4+
{
5+
"name": "Piotr Sikora",
6+
"github": "PiotrSikora",
7+
"github_user_id": 190297
8+
}
9+
],
10+
"repository": [
11+
"github:proxy-wasm/proxy-wasm-rust-sdk"
12+
],
13+
"versions": [],
14+
"yanked_versions": {}
15+
}

.bcr/presubmit.yml

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
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:
17+
- debian11
18+
- ubuntu2004
19+
- ubuntu2004_arm64
20+
- macos
21+
- macos_arm64
22+
bazel:
23+
- 7.x
24+
- 8.x
25+
- 9.*
26+
27+
tasks:
28+
verify_targets_wasm:
29+
name: Verify build targets (wasm32-unknown-unknown)
30+
platform: ${{ platform }}
31+
bazel: ${{ bazel }}
32+
build_flags:
33+
- "--platforms=@rules_rust//rust/platform:wasm"
34+
build_targets:
35+
- "@proxy_wasm_rust_sdk//..."
36+
37+
verify_targets_wasi:
38+
name: Verify build targets (wasm32-wasip1)
39+
platform: ${{ platform }}
40+
bazel: ${{ bazel }}
41+
build_flags:
42+
- "--platforms=@rules_rust//rust/platform:wasi"
43+
build_targets:
44+
- "@proxy_wasm_rust_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": "proxy-wasm-rust-sdk-{VERSION}",
4+
"url": "https://github.com/{OWNER}/{REPO}/releases/download/v{VERSION}/proxy-wasm-rust-sdk-{VERSION}.tar.gz"
5+
}
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
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+
# Publishes new releases to the Bazel Central Registry.
16+
# See .bcr/README.md for more information.
17+
name: Publish to BCR
18+
19+
on:
20+
# Automatically trigger when a version tag is pushed
21+
push:
22+
tags:
23+
- "v*.*.*"
24+
25+
# Allow manual dispatch from the GitHub UI for retries
26+
workflow_dispatch:
27+
inputs:
28+
tag_name:
29+
description: "Git tag to publish (e.g., v0.2.5)"
30+
required: true
31+
type: string
32+
33+
jobs:
34+
publish:
35+
uses: bazel-contrib/publish-to-bcr/.github/workflows/publish.yaml@v1.0.0
36+
with:
37+
tag_name: ${{ inputs.tag_name || github.ref_name }}
38+
permissions:
39+
attestations: write
40+
contents: write
41+
id-token: write
42+
secrets:
43+
publish_token: ${{ secrets.BCR_PUBLISH_TOKEN }}

0 commit comments

Comments
 (0)