diff --git a/.bcr/README.md b/.bcr/README.md new file mode 100644 index 0000000000..3a67dfa744 --- /dev/null +++ b/.bcr/README.md @@ -0,0 +1,58 @@ +# BCR Publishing Configuration + +This directory contains the template files required for publishing opentelemetry-cpp to the [Bazel Central Registry (BCR)](https://github.com/bazelbuild/bazel-central-registry). + +## Files + +### metadata.template.json +Contains the module metadata including homepage, maintainers, and repository information. This is used to create/update the BCR metadata for the module. + +### source.template.json +Defines the source archive location and format. Placeholders like `{OWNER}`, `{REPO}`, `{TAG}`, and `{VERSION}` are automatically replaced during publishing. + +### presubmit.yml +Defines the BCR presubmit tests that run when a new version is published. Currently configured to test on: +- Platforms: debian10, macos, ubuntu2004, windows +- Bazel versions: 7.x, 8.x, 9.* + +## Publishing Process + +The publish-to-bcr workflow (`.github/workflows/publish-to-bcr.yml`) automates publishing to BCR. + +### Prerequisites + +**Create a Personal Access Token (PAT)**: + - Create a Classic PAT with `workflow` and `repo` permissions + - Add it as a secret named `BCR_PUBLISH_TOKEN` in repository settings + +### How to Publish + +The workflow can be triggered in two ways: + +1. **Automatically**: When a new GitHub release is published +2. **Manually**: Via workflow dispatch in GitHub Actions UI + - Go to Actions → Publish to BCR → Run workflow + - Enter the tag name (e.g., `v1.24.0`) + +### What Happens + +When triggered, the workflow: +1. Generates a BCR entry using these templates +2. Pushes the entry to your BCR fork +3. Opens a pull request against the upstream BCR + +### Using a Fork Registry + +For development and testing, you can use a fork of the Bazel Central Registry: + +1. Fork https://github.com/bazelbuild/bazel-central-registry +2. Configure your fork URL in the workflow (modify the `publish-to-bcr.yml` file) +3. Test changes in your fork before submitting to the official BCR + +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. + +## References + +- [Publish to BCR Action](https://github.com/bazel-contrib/publish-to-bcr) +- [Bazel Central Registry](https://github.com/bazelbuild/bazel-central-registry) +- [BCR Module: opentelemetry-cpp](https://github.com/bazelbuild/bazel-central-registry/tree/main/modules/opentelemetry-cpp) diff --git a/.bcr/metadata.template.json b/.bcr/metadata.template.json new file mode 100644 index 0000000000..4db3fb8817 --- /dev/null +++ b/.bcr/metadata.template.json @@ -0,0 +1,22 @@ +{ + "homepage": "https://github.com/open-telemetry/opentelemetry-cpp", + "maintainers": [ + { + "name": "Keith Smiley", + "email": "keithbsmiley@gmail.com", + "github": "keith", + "github_user_id": 283886 + }, + { + "name": "Marc Alff", + "email": "marc.alff@oracle.com", + "github": "marcalff", + "github_user_id": 17238896 + } + ], + "repository": [ + "github:open-telemetry/opentelemetry-cpp" + ], + "versions": [], + "yanked_versions": {} +} diff --git a/.bcr/presubmit.yml b/.bcr/presubmit.yml new file mode 100644 index 0000000000..a0dc2acb10 --- /dev/null +++ b/.bcr/presubmit.yml @@ -0,0 +1,12 @@ +matrix: + platform: ["debian10", "macos", "ubuntu2004", "windows"] + bazel: ["7.x", "8.x", "9.*"] +tasks: + verify_targets: + platform: ${{ platform }} + bazel: ${{ bazel }} + build_flags: + - '--cxxopt=-std=c++14' + - '--host_cxxopt=-std=c++14' + build_targets: + - '@opentelemetry-cpp//api' diff --git a/.bcr/source.template.json b/.bcr/source.template.json new file mode 100644 index 0000000000..94d3157d74 --- /dev/null +++ b/.bcr/source.template.json @@ -0,0 +1,5 @@ +{ + "integrity": "", + "strip_prefix": "opentelemetry-cpp-{VERSION}", + "url": "https://github.com/{OWNER}/{REPO}/archive/refs/tags/{TAG}.tar.gz" +} diff --git a/.github/workflows/publish-to-bcr.yml b/.github/workflows/publish-to-bcr.yml new file mode 100644 index 0000000000..4c32b8afd1 --- /dev/null +++ b/.github/workflows/publish-to-bcr.yml @@ -0,0 +1,24 @@ +name: Publish to BCR + +on: + # Allow manual triggering for testing and recovery + workflow_dispatch: + inputs: + tag_name: + description: 'Tag name to publish (e.g., v1.24.0)' + required: true + type: string + # Automatically trigger after a release is created + release: + types: [published] + +jobs: + publish: + permissions: + contents: write + uses: bazel-contrib/publish-to-bcr/.github/workflows/publish.yaml@v1.0.0 + with: + tag_name: ${{ inputs.tag_name || github.event.release.tag_name }} + attest: false + secrets: + publish_token: ${{ secrets.BCR_PUBLISH_TOKEN }} diff --git a/README.md b/README.md index 05d52c37e4..b08715a100 100644 --- a/README.md +++ b/README.md @@ -60,6 +60,17 @@ license requirements. Please refer to [INSTALL.md](./INSTALL.md). +### Bazel Central Registry + +This project is available in the [Bazel Central Registry (BCR)](https://github.com/bazelbuild/bazel-central-registry/tree/main/modules/opentelemetry-cpp). +To use it with Bazel, add the following to your `MODULE.bazel` file: + +```python +bazel_dep(name = "opentelemetry-cpp", version = "x.y.z") +``` + +For the latest version, see [BCR: opentelemetry-cpp](https://github.com/bazelbuild/bazel-central-registry/tree/main/modules/opentelemetry-cpp). + ## Getting Started As an application owner or the library author, you can find the getting started