# Config

> The bump.json file, where bump finds it, every key with its type and default, the tag and message templates, and the validation errors.

The config file is optional. Without it, bump uses the defaults: [lockstep mode](/modes/#lockstep), the packages of your workspace files, and `v{version}` tags.

## Example

```jsonc [bump.json]
{
  "$schema": "https://unpkg.com/bump/schema.json",
  "independent": true,
  "packages": ["packages/*", "crates/*", "!packages/internal-*"],
  "groups": {
    // these always release together
    "web": ["@acme/ui", "@acme/app"],
  },
  "preid": "next",
  "tag": "{name}@{version}",
  "message": "release: {tags}",
}
```

## Config file

The file is `bump.json` or `bump.jsonc`. bump reads both names as JSONC, so both allow comments and trailing commas.

bump finds the file in this order:

1. It starts in the `--cwd` directory, which is `.` by default.
2. It searches upward for `bump.json` or `bump.jsonc`. It stops at the top level of the git repository.
3. The first directory with a config file is the **root**. Without a config file, the root is the top level of the git repository.

All paths in the config are relative to the root. bump runs the lockfile commands in the root too. See [Lockfiles](/lockfiles/).

One directory can hold only one of the two files:

```console
$ bump patch
FAIL Keep one of "/private/tmp/acme/bump.json" and "/private/tmp/acme/bump.jsonc"
```

bump never writes the config file.

## Keys

| Key | Type | Default | Description |
| --- | --- | --- | --- |
| [`$schema`](#schema) | string | | The JSON schema, for editors. bump ignores it. |
| [`independent`](#independent) | boolean | `false` | Give each package, or each group, its own version and tag. |
| [`packages`](#packages) | string, or string[] | your workspace files | Directory globs of the packages. |
| [`groups`](#groups) | object of string[] | `{}` | Packages that release together. Independent mode only. |
| [`preid`](#preid) | string | `"next"` | The preid of a new prerelease line. |
| [`tag`](#tag) | string | `"v{version}"`; `"{name}@{version}"` in independent mode | The tag name. |
| [`message`](#message) | string | `"v{version}"`; `"release: {tags}"` in independent mode | The subject of the release commit. |

Any other key is an error.

### `$schema`

The URL of the JSON schema:

```jsonc [bump.json]
{
  "$schema": "https://unpkg.com/bump/schema.json"
}
```

Your editor uses it to check the keys and to show their docs. bump ignores the value, but it must be a string. The schema checks the types and the `preid` format. bump checks the [template rules](#templates) when it runs.

### `independent`

Selects the mode. With `false`, all versioned packages are one unit, with one version and one tag. With `true`, each group is a unit, and each other versioned package is a unit of its own. See [Lockstep and independent](/modes/).

### `packages`

Directory globs, relative to the root. A string is one glob.

```jsonc [bump.json]
{
  "packages": ["packages/*", "crates/*", "!packages/internal-*"]
}
```

- Each glob matches directories. bump does not search inside a matched directory, so `packages/*` finds `packages/core/package.json`, but not `packages/core/fixtures/package.json`.
- A glob that starts with `!` excludes. It removes each directory that it matches, and each directory inside one that it matches.
- `.` is the root directory.
- bump skips `node_modules` directories, directories whose names start with `.`, and each directory inside them.
- In each directory, bump looks for a `package.json` and a `Cargo.toml`. One directory can hold one of each.

Without `packages`, each ecosystem uses its own workspace files:

- **npm**: `workspaces` in the root `package.json`, an array of globs or an object with a `packages` array, and `packages` in the root `pnpm-workspace.yaml`. bump uses both when both exist. With neither, the root directory.
- **Cargo**: `members` and `exclude` of `[workspace]` in the root `Cargo.toml`. The root is a member too when the same file has a `[package]`. Each path dependency of a member inside the root is a member too, as in Cargo. Without `[workspace]`, the root directory.

For which manifests count as packages, see [Package rules](/how-it-works/#package-rules).

### `groups`

Group names, each with a list of package names. The packages of a group release together, with one version and one tag.

```jsonc [bump.json]
{
  "independent": true,
  "groups": {
    "web": ["@acme/ui", "@acme/app"]
  }
}
```

Groups need `"independent": true`. See [Groups](/groups/) for the rules.

### `preid`

The preid of a new prerelease line, when you do not give `--preid`. It starts with a letter, and has only letters, digits, and `-`. See [Prereleases](/prereleases/).

### `tag`

The name of each release tag. See [Templates](#templates).

```jsonc [bump.json]
{
  "independent": true,
  "tag": "{name}-v{version}"
}
```

bump finds earlier releases by this name. A tag belongs to a unit only when the full tag name matches the template. When you change `tag`, bump does not find the tags of the old form. See [No tag found](/errors/#no-tag-found).

### `message`

The subject of the release commit. See [Templates](#templates).

```jsonc [bump.json]
{
  "independent": true,
  "message": "chore: release {tags}"
}
```

Each annotated tag uses its own tag name as its message.

## Templates

`tag` and `message` are templates. A placeholder in braces becomes a value:

| Placeholder | Value | `tag` | `message` |
| --- | --- | --- | --- |
| `{version}` | The new version of the unit. | Required. | Lockstep mode only. |
| `{name}` | The name of the unit: the package name, or the group name. | Required in independent mode. Not allowed in lockstep mode. | Not allowed. |
| `{tags}` | The new tags, in release order, joined with `, `. | Not allowed. | Allowed. |

- Placeholders are case-sensitive: `{Version}` is an error.
- A placeholder can occur more than one time.
- There is no escape for a literal brace. Any other text in braces is an error.

>>>
@@@ config.md
<<<
- **Cargo**: `members` and `exclude` of `[workspace]` in the root `Cargo.toml`. The root is a member too when the same file has a `[package]`. Each path dependency of a member inside the root is a member too, as in Cargo. Without `[workspace]`, the root directory.
===
- **Cargo**: `[workspace]` in the root `Cargo.toml`. Without `[workspace]`, the root directory. See [Find the crates](/cargo/#find-the-crates).
Before a release, bump checks each new tag with `git check-ref-format`. A scoped name such as `@acme/cli@0.4.2` is valid. A tag with a space or a `:` is not:

```console
$ bump minor
FAIL Invalid tag name: "@acme/core:0.1.0"
```

## Validation

bump checks the config before it reads the packages. Each error names the key and the file:

```console
$ bump patch
FAIL "version" was removed: versions come from the manifests in "/private/tmp/acme/bump.json"
```

| Problem | Error |
| --- | --- |
| `version` key | `"version" was removed: versions come from the manifests` |
| `single` key | `"single" was removed: use "packages": ["."]` |
| `all` key | `"all" was removed: use --all` |
| Unknown key | `Unknown "workspaces" key` |
| `independent` not a boolean | `"independent" must be a boolean` |
| `packages` empty, or not strings | `"packages" must be a string or a non-empty array of strings` |
| `groups` not an object | `"groups" must be an object` |
| An empty group | `"groups.web" must be a non-empty array of package names` |
| `groups` in lockstep mode | `"groups" needs "independent": true` |
| Invalid `preid` | `Invalid "preid" value: "1rc"` |
| Empty `tag` or `message` | `"tag" must be a non-empty string` |
| Unknown placeholder | `Unknown "{name}" placeholder in "tag"` |
| Missing placeholder | `Missing "{version}" placeholder in "tag"` |
| Single brace | `Unmatched brace in "tag"` |
| Invalid JSONC | `Invalid JSON in "<file>": <parser message>` |
| Not an object | `"<file>" must hold a JSON object` |

Each message in the table ends with ` in "<file>"`, except the last two, which name the file at the start.

The group rules give more errors, which name the package and the group. See [Groups](/groups/#errors).

The [JS API](/api/) takes the same keys as options, except `$schema` and `preid`. Its `preid` option is the `--preid` flag, not this key. An error in an option ends with `in the options`.

## Schema file

The package ships the schema as `bump/schema.json`. The URL `https://unpkg.com/bump/schema.json` serves the latest version. To pin the schema to your installed version, use the local file:

```jsonc [bump.json]
{
  "$schema": "./node_modules/bump/schema.json"
}
```
