# axle release

Give each changed package a new version, changelog and tag, then publish it.

```sh
axle release --dry-run
axle release
git push --follow-tags
axle release publish
```

Releasing from a monorepo means working out which packages changed, giving each a new version, updating the packages that depend on them, writing changelogs and tags, and publishing in the right order. `axle release` does the first part in one commit you can review; `axle release publish` does the rest, and can run again after a failure.

## Versions from commits

By default, versions come from [Conventional Commits](https://www.conventionalcommits.org/). Each package gets the commits since its last tag that change files in its folder:

| Commit                                                                                               | Release |
| ---------------------------------------------------------------------------------------------------- | ------- |
| `feat: …`                                                                                            | minor   |
| `fix: …` or `perf: …`                                                                                | patch   |
| `<type>!: …`, such as `feat!: …`, or one with a `BREAKING CHANGE:` or `BREAKING-CHANGE:` footer line | major   |

Other types, such as `docs` or `chore`, don't release anything on their own. A version below 1.0.0 moves its minor number for a breaking change and its patch number for anything else. Tags are `<name>@<version>`, such as `@acme/ui@1.4.0`, or the format `tag` under `[release]` gives, such as `{name}-v{version}`; a package with no tag yet releases everything in its history.

## Versions from change files

With `versions = "changes"` under [`[release]`](https://axlers.dev/docs/reference/configuration.md#releases), each change is a Markdown file in `.changes/`, written with `axle release add` or by hand:

```sh
axle release add ui=minor web=patch --message "Buttons take an icon."
```

```markdown
---
'ui': minor
'web': patch
---

Buttons take an icon.
```

Commit the file with the change it describes. The names can be in single or double quotes, or in none. `axle release` adds the files up, writes their text into the changelogs and deletes them. A `README.md` in `.changes/` is left alone.

## What a release changes

`axle release` refuses to start while tracked files, or change files in `.changes/`, have changes that aren't committed. If committing or tagging fails, it puts the repository back as it was. Then, for each package it releases, it:

- writes the new version into its `package.json`;
- updates the ranges of every workspace package that depends on it, the root `package.json` and packages without a `version` included, in `dependencies`, `devDependencies`, `peerDependencies` and `optionalDependencies`, keeping `^`, `~` or `=`. Ranges such as `workspace:^` or `*` stay as they are;
- gives each package that depends on it, other than through `devDependencies`, a patch release of its own with the line "Updated dependencies";
- adds a section to the `CHANGELOG.md` in its folder, newest first, under the new version and today's date, with its breaking changes, features, fixes and other changes, unless `changelog = false` under `[release]`;
- updates the lockfile to match the new ranges, so a frozen install of the release commit works;
- commits all of it as `chore(release): ui@1.4.0, web@2.0.1` and makes an annotated tag for each new version.

The lockfile is updated by the package manager, which `axle release` runs at the root:

| Package manager | Command                                              |
| --------------- | ---------------------------------------------------- |
| pnpm            | `pnpm install --lockfile-only`                       |
| npm             | `npm install --package-lock-only --ignore-scripts`   |
| Yarn            | `yarn install --mode=update-lockfile --no-immutable` |
| Bun             | `bun install --lockfile-only`                        |
| nub             | `nub install --lockfile-only`                        |
| aube            | `aube install --lockfile-only`                       |

nub and aube update whichever lockfile the repository has. A Yarn 1 lockfile doesn't record workspace packages, so it's left alone, as are Bun's older `bun.lockb` and a `yarn.lock` with nub, which only reads it. If the command fails, nothing is released and the repository is put back as it was.

`--dry-run` prints the new versions, the files it would change and the changelog sections, and changes nothing. With nothing to release, it says so and exits with 0. Set `SOURCE_DATE_EPOCH` to date the changelogs from it instead of the clock.

Only packages with a `version` in their `package.json` are released, and the root `package.json` only when it's the only package. Versions follow [Semantic Versioning](https://semver.org/), such as `1.2.3` or `1.2.3-beta.1`; one Axle can't read stops the release with [`release-failed`](https://axlers.dev/docs/messages/release-failed.md). Build metadata, such as `+build.5`, is ignored when versions are compared, and a new version leaves it out.

## One version for every package

With `mode = "fixed"`, every package with a version gets the same new one: the highest version any of them has now, with the highest bump any change calls for. The commit is `chore(release): v<version>`. The commits counted are all those since the last `v<version>` tag, wherever they change files, and the release is tagged `v<version>`. The changelog is one `CHANGELOG.md` at the repository's root.

`alsoUpdate` lists other files whose version follows a fixed release, such as a `Cargo.toml` or a `gradle.properties`. On each of their lines whose key mentions `version`, such as `version = "1.4.0"` or `"version": "1.4.0"`, the current version is replaced with the new one. A line such as `log = { version = "1.4.0" }` is a dependency's, and stays as it is. `alsoUpdate` has no effect in `independent` mode.

```toml
[release]
mode = "fixed"
alsoUpdate = ["Cargo.toml", "editors/jetbrains/gradle.properties"]
```

## Pre-releases

```sh
axle release --pre beta
axle release
axle release --graduate
```

`axle release --pre beta` releases each package that changed as a pre-release named `beta`: a feature on `1.2.0` makes `1.3.0-beta.0`. While a package is on a pre-release, its next release, with `--pre beta` or with no option, moves only the number at the end, to `1.3.0-beta.1`, unless a change calls for more than the pre-release already has: a breaking change on `1.3.0-beta.1` makes `2.0.0-beta.0`. Another name starts again from 0 on the same version, so `--pre rc` on `1.3.0-beta.2` makes `1.3.0-rc.0`. Names are compared alphabetically, as [Semantic Versioning](https://semver.org/#spec-item-11) says, so `--pre alpha` on `1.3.0-beta.2` would make an older version, and stops with [`release-failed`](https://axlers.dev/docs/messages/release-failed.md).

`axle release --graduate` gives each package that's on a pre-release its stable version, even without new changes, so `1.3.0-rc.0` becomes `1.3.0`. Packages that aren't on a pre-release are released as usual.

A name starts with a letter and has only letters, digits and `-`. It's also the npm tag the pre-release is published under, so it can't be `latest`, or a name npm reads as a range of versions, such as `x` or `v2`.

Pre-releases work the same with commits and change files. The commits counted are those since the package's last tag, pre-release or not, and change files are deleted by the pre-release that uses them. Packages that depend on a pre-release get a range on it, such as `^1.3.0-beta.0`, and a release of their own, which is a pre-release too with `--pre`. In `fixed` mode every package gets the same pre-release.

Each pre-release has its own changelog section, such as `## 1.3.0-beta.1 (2026-12-05)`. The stable version's section collects the changes of every pre-release section above the last stable one, followed by its own, so it says everything that changed since the last stable version. The pre-release sections stay below it.

Tags are the usual ones with the pre-release version, such as `ui@1.3.0-beta.0` or `v1.3.0-beta.0`.

## Release groups

```toml
[release]
mode = "independent"

[[release.groups]]
name = "sdk"
packages = ["@acme/sdk-*"]
mode = "fixed"

[[release.groups]]
name = "tools"
packages = ["cli", "create-shop"]
tag = "{name}-v{version}"
changelog = false
```

A release group is a named set of packages released their own way. Its `packages` are names or globs, such as `@acme/sdk-*`, and a package can be in only one group: a package two groups match stops the release with [`package-in-two-release-groups`](https://axlers.dev/docs/messages/package-in-two-release-groups.md). A group can set `mode`, `versions`, `tag` and `changelog`; the keys it leaves out are the same as under `[release]`. Packages outside every group follow `[release]`.

- A `fixed` group gives its packages one version, the highest any of them has, with the highest bump any change calls for. The commits counted are those since the group's last tag that change files in any of its packages' folders. It's tagged `<group>@<version>` by default, such as `sdk@3.1.0`, and each of its packages' `CHANGELOG.md` gets the group's section.
- An `independent` group works as `independent` mode does, with its own tag format if it has one.
- In a `fixed` repository with groups, the commits counted for the packages outside every group are those that change files outside the grouped packages' folders.
- A package that depends on a package another group releases gets its range updated and a patch release, as within a group.

`tag` sets the format of the tags, under `[release]` or in a group, with `{name}`, the package's name or, in a `fixed` group, the group's, and `{version}`. A format needs `{version}`, and two sets of packages can't get the same tags, such as a group named `ui` and a package named `ui`; both stop with [`release-settings-have-a-mistake`](https://axlers.dev/docs/messages/release-settings-have-a-mistake.md).

With groups, `axle release` and `--dry-run` show the versions by group:

```text
sdk
  @acme/sdk-node  3.0.0 to 3.1.0
  @acme/sdk-web   3.0.0 to 3.1.0

tools
  cli  0.4.0 to 0.4.1

Outside any group
  util  1.0.0 to 1.0.1
```

`axle release --group sdk` releases only the packages of that group. Packages outside it that depend on them get their ranges updated, without a release of their own. A change file that also names packages outside the group is rewritten to keep only those, so they're released later.

## Publishing

`axle release publish` publishes every package whose version is tagged at the current commit, in dependency order, with the repository's package manager:

| Package manager  | Command                        |
| ---------------- | ------------------------------ |
| npm, Yarn 1, nub | `npm publish`                  |
| pnpm             | `pnpm publish --no-git-checks` |
| Yarn             | `yarn npm publish`             |
| Bun              | `bun publish`                  |
| aube             | `aube publish --no-git-checks` |

Before each, it asks the registry whether it already has that version, and skips it if so, so a failed publish can run again. The registry is the package's `publishConfig.registry`, its scope's registry in `.npmrc`, such as `@acme:registry=https://npm.pkg.github.com`, `npm_config_registry`, `registry` in `.npmrc`, or `https://registry.npmjs.org`, the first that's set. Axle reads the `.npmrc` in the package's folder, at the root and the user's, and sends the question with the `_authToken` `.npmrc` gives for that registry's address, and no other. `private` packages are versioned and tagged but never published. `--dry-run` says what it would publish and publishes nothing.

A pre-release is published under its name as the npm tag, with `--tag beta` after each of the commands above, never as `latest`, so installing the package still gets the latest stable version and `npm install ui@beta` gets the pre-release. A pre-release whose first part isn't a name npm can use, such as `1.0.0-1`, is published under `next`.

Plugins that can [`publish`](https://axlers.dev/docs/reference/plugins.md#publish) get every package released at the commit too, for registries Axle doesn't know, such as crates.io or a container registry.

### GitHub and GitLab releases

With `hosting` set under `[release]`, `axle release publish` also creates a release for each tag, at the current commit, in the repository `origin` points to. Its notes are the version's section of the changelog, under a heading such as `## 1.4.0` or `## [1.4.0] - 2026-12-05`, and empty when there isn't one. A GitHub release of a pre-release is marked as one. A release that's already there is skipped.

| `hosting` | Token                             | API                                             |
| --------- | --------------------------------- | ----------------------------------------------- |
| `github`  | `GITHUB_TOKEN`                    | `GITHUB_API_URL`, or `https://api.github.com`   |
| `gitlab`  | `GITLAB_TOKEN`, or `CI_JOB_TOKEN` | `CI_API_V4_URL`, or `https://gitlab.com/api/v4` |

## In CI

Run `axle release` where a person can review the commit, such as in a pull request, or on the main branch with a token that can push. Then, in the job that has the registry's token, check out the release commit with its tags and run `axle release publish`.

## Options

| Command                | Option           | What it does                                                 |
| ---------------------- | ---------------- | ------------------------------------------------------------ |
| `axle release`         | `--dry-run`      | shows the versions and changelogs, and changes nothing       |
| `axle release`         | `--pre <name>`   | releases pre-releases with this name, such as `1.3.0-beta.0` |
| `axle release`         | `--graduate`     | gives each package on a pre-release its stable version       |
| `axle release`         | `--group <name>` | releases only the packages of this release group             |
| `axle release add`     | `--message`      | what changed, for the changelog; also `-m`                   |
| `axle release publish` | `--dry-run`      | shows what would be published, and publishes nothing         |

Each problem has its own page: [`release-needs-a-clean-tree`](https://axlers.dev/docs/messages/release-needs-a-clean-tree.md), [`release-failed`](https://axlers.dev/docs/messages/release-failed.md), [`change-file-has-a-mistake`](https://axlers.dev/docs/messages/change-file-has-a-mistake.md), [`package-in-two-release-groups`](https://axlers.dev/docs/messages/package-in-two-release-groups.md), [`release-settings-have-a-mistake`](https://axlers.dev/docs/messages/release-settings-have-a-mistake.md), [`publish-failed`](https://axlers.dev/docs/messages/publish-failed.md) and [`hosting-token-missing`](https://axlers.dev/docs/messages/hosting-token-missing.md).
