sourceconditiontarget

Description

The bazelmod resource reads and writes the version of one dependency in a MODULE.bazel file, the bazel_dep entries of Bzlmod:

bazel_dep(name = "rules_python", version = "0.27.0")
bazel_dep(name = "gazelle", version = "0.35.0")
source

Returns the version currently pinned for module.

condition

Checks that the file pins the expected version.

target

Updates that version. A file already holding it is left untouched.

It is the local half of the pair: bazelregistry finds the version available upstream, bazelmod writes it into your repository.

Parameters

NameTypeDescriptionRequired
filestring

File specifies the path to the MODULE.bazel file

compatible:

  • source
  • condition
  • target

example:

  • MODULE.bazel
  • path/to/MODULE.bazel
modulestring

Module specifies the Bazel module name to target

compatible:

  • source
  • condition
  • target

example:

  • rules_go
  • gazelle
  • protobuf

Both file and module are mandatory (missing either aborts the run with wrong spec content, preceded by bazelmod file undefined or bazelmod module undefined).

file

The path to the MODULE.bazel file, e.g. MODULE.bazel or path/to/MODULE.bazel. There is no default, and no files list (use one target per file).

module

The module name as it appears in bazel_dep(name = …​), e.g. rules_go.

Example

sources:
  latest:
    name: Get the latest version of rules_python
    kind: bazelregistry
    spec:
      module: rules_python
targets:
  rules_python:
    name: Bump Bazel module rules_python
    kind: bazelmod
    sourceid: latest
    spec:
      file: project2/MODULE.bazel
      module: rules_python