|
| 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) |
0 commit comments