This document summarizes the key learnings from adding a new module version to the Bazel Central Registry (BCR).
mkdir -p modules/<module_name>/<version>
MODULE.bazel
file: Copy from a previous version if possible and update the version number. If the module has dependencies, ensure they are correctly listed.source.json
file: Copy from a previous version if possible and update the version number. This file contains the URL of the source archive, its integrity hash, and the strip_prefix
. If the source archive doesn‘t contain a MODULE.bazel
or BUILD.bazel
file, you’ll need to provide them in an overlay
.overlay
and patches
directories: If the module requires any overlays or patches, copy these directories from a previous version if they exist.presubmit.yml
: The validation script will fail if modules/<module_name>/<version>/presubmit.yml
does not exist. You can usually copy this file from a previous version.metadata.json
: The validation script will fail if the new version is not added to the versions
list in modules/<module_name>/metadata.json
.tools/bcr_validation.py
script is the most important tool for this process. Run it early and often. Use the --check
flag to specify the module and version you are working on: bazel run //tools:bcr_validation -- --check <module_name>@<version>
.update_integrity
tool: The bazel run //tools:update_integrity -- <module name> --version=<version>
command is the correct way to update the integrity hashes in source.json
.overlay
vs. patches
:overlay
: Use this to add or overwrite files in the downloaded source archive. The files to be overlaid should be placed in an overlay
subdirectory within the version directory.patches
: Use this to apply changes to existing files in the source archive. Patch files should be placed in a patches
subdirectory.MODULE.bazel
Duplication: The MODULE.bazel
file must exist in two places:modules/<module_name>/<version>/MODULE.bazel
).overlay
directory (modules/<module_name>/<version>/overlay/MODULE.bazel
). The file in the overlay
directory should be a symlink to the one at the root.bazel_compatibility
: When using overlay
, the MODULE.bazel
file must specify the bazel_compatibility
attribute.bazel run //tools:setup_presubmit_repos -- --module <module_name>@<version>
command sets up a local test environment.bazel build
command to run for local testing.bazel clean --expunge
to clear the caches.