Skip to content

Commit c66dfa9

Browse files
authored
Add BCR GitHub workflow and configuration (#3782)
Signed-off-by: Matthieu MOREL <[email protected]>
1 parent 179e4b0 commit c66dfa9

File tree

6 files changed

+134
-0
lines changed

6 files changed

+134
-0
lines changed

.bcr/README.md

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
# BCR Publishing Configuration
2+
3+
This directory contains the template files required for publishing opentelemetry-cpp to the [Bazel Central Registry (BCR)](https://github.com/bazelbuild/bazel-central-registry).
4+
5+
## Files
6+
7+
### metadata.template.json
8+
Contains the module metadata including homepage, maintainers, and repository information. This is used to create/update the BCR metadata for the module.
9+
10+
### source.template.json
11+
Defines the source archive location and format. Placeholders like `{OWNER}`, `{REPO}`, `{TAG}`, and `{VERSION}` are automatically replaced during publishing.
12+
13+
### presubmit.yml
14+
Defines the BCR presubmit tests that run when a new version is published. Currently configured to test on:
15+
- Platforms: debian10, macos, ubuntu2004, windows
16+
- Bazel versions: 7.x, 8.x, 9.*
17+
18+
## Publishing Process
19+
20+
The publish-to-bcr workflow (`.github/workflows/publish-to-bcr.yml`) automates publishing to BCR.
21+
22+
### Prerequisites
23+
24+
**Create a Personal Access Token (PAT)**:
25+
- Create a Classic PAT with `workflow` and `repo` permissions
26+
- Add it as a secret named `BCR_PUBLISH_TOKEN` in repository settings
27+
28+
### How to Publish
29+
30+
The workflow can be triggered in two ways:
31+
32+
1. **Automatically**: When a new GitHub release is published
33+
2. **Manually**: Via workflow dispatch in GitHub Actions UI
34+
- Go to Actions → Publish to BCR → Run workflow
35+
- Enter the tag name (e.g., `v1.24.0`)
36+
37+
### What Happens
38+
39+
When triggered, the workflow:
40+
1. Generates a BCR entry using these templates
41+
2. Pushes the entry to your BCR fork
42+
3. Opens a pull request against the upstream BCR
43+
44+
### Using a Fork Registry
45+
46+
For development and testing, you can use a fork of the Bazel Central Registry:
47+
48+
1. Fork https://github.com/bazelbuild/bazel-central-registry
49+
2. Configure your fork URL in the workflow (modify the `publish-to-bcr.yml` file)
50+
3. Test changes in your fork before submitting to the official BCR
51+
52+
The configuration in this repository points to the **official** Bazel Central Registry at https://github.com/bazelbuild/bazel-central-registry. However, using a fork registry is recommended for testing and development to avoid polluting the official registry during experimentation.
53+
54+
## References
55+
56+
- [Publish to BCR Action](https://github.com/bazel-contrib/publish-to-bcr)
57+
- [Bazel Central Registry](https://github.com/bazelbuild/bazel-central-registry)
58+
- [BCR Module: opentelemetry-cpp](https://github.com/bazelbuild/bazel-central-registry/tree/main/modules/opentelemetry-cpp)

.bcr/metadata.template.json

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
{
2+
"homepage": "https://github.com/open-telemetry/opentelemetry-cpp",
3+
"maintainers": [
4+
{
5+
"name": "Keith Smiley",
6+
"email": "[email protected]",
7+
"github": "keith",
8+
"github_user_id": 283886
9+
},
10+
{
11+
"name": "Marc Alff",
12+
"email": "[email protected]",
13+
"github": "marcalff",
14+
"github_user_id": 17238896
15+
}
16+
],
17+
"repository": [
18+
"github:open-telemetry/opentelemetry-cpp"
19+
],
20+
"versions": [],
21+
"yanked_versions": {}
22+
}

.bcr/presubmit.yml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# Copyright The OpenTelemetry Authors
2+
# SPDX-License-Identifier: Apache-2.0
3+
matrix:
4+
platform: ["debian10", "macos", "ubuntu2004", "windows"]
5+
bazel: ["7.x", "8.x", "9.*"]
6+
tasks:
7+
verify_targets:
8+
platform: ${{ platform }}
9+
bazel: ${{ bazel }}
10+
build_flags:
11+
- '--cxxopt=-std=c++14'
12+
- '--host_cxxopt=-std=c++14'
13+
build_targets:
14+
- '@opentelemetry-cpp//api'

.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": "opentelemetry-cpp-{VERSION}",
4+
"url": "https://github.com/{OWNER}/{REPO}/archive/refs/tags/{TAG}.tar.gz"
5+
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
name: Publish to BCR
2+
3+
on:
4+
# Allow manual triggering for testing and recovery
5+
workflow_dispatch:
6+
inputs:
7+
tag_name:
8+
description: 'Tag name to publish (e.g., v1.24.0)'
9+
required: true
10+
type: string
11+
# Automatically trigger after a release is created
12+
release:
13+
types: [published]
14+
15+
jobs:
16+
publish:
17+
permissions:
18+
contents: write
19+
uses: bazel-contrib/publish-to-bcr/.github/workflows/[email protected]
20+
with:
21+
tag_name: ${{ inputs.tag_name || github.event.release.tag_name }}
22+
attest: false
23+
secrets:
24+
publish_token: ${{ secrets.BCR_PUBLISH_TOKEN }}

README.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,17 @@ license requirements.
6060

6161
Please refer to [INSTALL.md](./INSTALL.md).
6262

63+
### Bazel Central Registry
64+
65+
This project is available in the [Bazel Central Registry (BCR)](https://github.com/bazelbuild/bazel-central-registry/tree/main/modules/opentelemetry-cpp).
66+
To use it with Bazel, add the following to your `MODULE.bazel` file:
67+
68+
```python
69+
bazel_dep(name = "opentelemetry-cpp", version = "x.y.z")
70+
```
71+
72+
For the latest version, see [BCR: opentelemetry-cpp](https://github.com/bazelbuild/bazel-central-registry/tree/main/modules/opentelemetry-cpp).
73+
6374
## Getting Started
6475

6576
As an application owner or the library author, you can find the getting started

0 commit comments

Comments
 (0)