yarn version

Updates the package version.

Updating versions

Using the yarn version command you can update the version of your package via the command line.

For example, starting with this package.json package.json:

{
  "name": "example-yarn-package",
  "version": "1.0.1",
  "description": "An example package to demonstrate Yarn"
}

When we run the yarn version command:

yarn version
info Current version: 1.0.1
question New version: 1.0.2
info New version: 1.0.2
✨  Done in 9.42s.

We will get this updated package.json:

{
  "name": "example-yarn-package",
  "version": "1.0.2",
  "description": "An example package to demonstrate Yarn"
}

Note: The new version you enter must be a valid SemVer version.

Git tags

If you run yarn version within a Git repository a Git tag will be created by default following the format v0.0.0.

You can customize the git tag that is created or disable this behavior by using yarn config set.

To change the prefix of the git tag you can use version-tag-prefix:

yarn config set version-tag-prefix "v"

Or you can change the git message using version-git-message where %s is the version string:

yarn config set version-git-message "v%s"

You can also turn signing git tags on or off using version-sign-git-tag:

yarn config set version-sign-git-tag false

You can even enabled or disable the git tagging behavior entirely by using version-git-tag:

yarn config set version-git-tag true

If you would like to stop git commit hooks from running, you can disable them using version-commit-hooks:

yarn config set version-commit-hooks false

Commands

yarn version

Create a new version using an interactive session to prompt you for a new version.

yarn version --new-version <version>

Creates a new version specified by <version>.

yarn version --major
yarn version --minor
yarn version --patch

Creates a new version by incrementing the major, minor, or patch number of the current version.

yarn version --no-git-tag-version

Creates a new version without creating a git tag.

yarn version --no-commit-hooks

Bypasses running commit hooks when committing the new version.