Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

rtk

cliffano154MIT3.1.1

Agnostic software release tool for managing versions on changelog (keep-a-changelog), multi-format files (JSON, Makefile, text, TOML, YAML), and also for tagging source code of a Git repo

release, versioning, json, makefile, text, toml, yaml, changelog, keep-a-changelog, git, zeus, kraken

readme

Avatar

Build Status Security Status Dependencies Status Coverage Status Published Version

RTK

RTK is an agnostic software release tool for managing versions on changelog (keep-a-changelog), multi-format files (JSON, Makefile, text, TOML, YAML), and also for tagging source code of a Git repo.

This involves updating the version number on various manifest files, updating the version number and datestamp on a changelog file, tagging the code with the release version name, updating the manifest files again with the next pre-release version, and then updating the changelog file again with the unreleased version. And you have to do this for various technologies, e.g. with a node.js project you need to update the package.json file, with an Ansible project you need to update YAML metadata file, and so on so forth with other tech stacks.

Enter RTK, which allows you to configure the manifest and changelog files in a .rtk.json file, and it will take care of the updating of the version numbers, the committing of the changes with relevant message, and the tagging of the code with the version name, all via a convenient CLI command rtk release .

RTK comes with a default set of steps, but it's also open for extension by implementing custom release scheme.

The default release scheme involves the following steps:

  • Replace pre-release version on resource paths with its release version
  • Commit the release version changes to SCM
  • Add release tag using its version value
  • Replace release version on resource paths with the next pre-release version
  • Commit the next pre-release version changes to SCM

RTK console screenshot

Installation

npm install -g rtk

Usage

Cut off a release using default RTK release scheme:

rtk release

By default, the release version will increment minor value, and the next pre-release version will increment patch value.

This default is based on the idea that most release involves additions and changes (which often mean minor value increment), more than removals (which could mean backward incompatible major value increment) and fixes (which often mean patch value increment).

However, in order to honour the possibility of fixes, the next pre-release version will increment patch value.

The increment types can be customised, e.g. to cut off a release with major release and minor post-release increment types:

rtk release --release-increment-type major --post-release-increment-type minor

Do a release dry run without modifying resource files and making any SCM changes:

rtk release --dry-run

Cut off a release with major release and minor post-release increment types:

rtk release --release-increment-type major --post-release-increment-type minor

Configuration

Resources can be configured in .rtk.json file.

Example json resource configuration:

{
  "resources": [
    {
      "path": "package.json",
      "type": "json",
      "params": {
        "property": "version"
      }
    }
  ]
}

Example json resource configuration with an array sub-property:

{
  "resources": [
    {
      "path": "package.json",
      "type": "json",
      "params": {
        "property": "versions[1].minor"
      }
    }
  ]
}

Example yaml resource configuration:

{
  "resources": [
    {
      "path": "playbook.yaml",
      "type": "yaml",
      "params": {
        "property": "version"
      }
    }
  ]
}

Example yaml resource configuration with an array sub-property:

{
  "resources": [
    {
      "path": "playbook.yaml",
      "type": "yaml",
      "params": {
        "property": "versions[1].minor"
      }
    }
  ]
}

Example keep-a-changelog resource configuration:

{
  "resources": [
    {
      "path": "CHANGELOG.md",
      "type": "keep-a-changelog"
    }
  ]
}

Example toml resource configuration:

{
  "resources": [
    {
      "path": "pyproject.toml",
      "type": "toml",
      "params": {
        "property": "version"
      }
    }
  ]
}

Example makefile resource configuration:

{
  "resources": [
    {
      "path": "Makefile",
      "type": "makefile",
      "params": {
        "variable": "version"
      }
    }
  ]
}

Example text resource configuration:

{
  "resources": [
    {
      "path": "somefile.txt",
      "type": "text",
      "params": {
        "regex": "(\\d+)\\.(\\d+)\\.(\\d+)(?:-([0-9A-Za-z-]+(?:\\.[0-9A-Za-z-]+)*))?"
      }
    }
  ]
}

It is also possible to force the release and post-release values instead of using the version scheme generated value: Note: because release and post-release values are specified at resource level, the SCM tag will still use the version scheme generated value

{
  "resources": [
    {
      "path": "package.json",
      "type": "json",
      "params": {
        "property": "version",
        "release_value": "1.2.3",
        "post_release_value": "master"
      }
    }
  ]
}

If you want to format the tag instead of using the version number as the tag, you can configure tagFormat property:

{
  "tagFormat": "v{version}",
  "resources": [...]
}

The above example will set the tag v1.2.3 for version 1.2.3 .

If you want to format the resource's release value, you can configure format property:

{
  "resources": [
    {
      "path": "Makefile",
      "type": "makefile",
      "params": {
        "variable": "version",
        "release_format": "v{version}"
      }
    }
  ]
}

Upgrade

From 0.x, 1.x, 2.x to 3.x:

Modify configuration which uses array sub-property syntax to use square brackets, e.g.:

  • from versions.1.minor to versions[1].minor
  • from a.b.0.d.e to a.b[0].d.e
  • from jobs.build.steps.0.with.ref to jobs.build.steps[0].with.ref

Failing to update the syntax will result in the following error:

file:///path/to/lib/node_modules/rtk/node_modules/dot-prop/index.js:176
    throw new Error('Cannot use string index');
    ^

Error: Cannot use string index
    at assertNotStringIndex (file:///path/to/lib/node_modules/rtk/node_modules/dot-prop/index.js:176:9)

Colophon

Developer's Guide

Build reports:

Release the Kraken

changelog

Changelog

All notable changes to this project will be documented in this file.

The format is based on Keep a Changelog, and this project adheres to Semantic Versioning.

3.1.1 - 2023-10-17

Fixed

  • Fix broken text resource type support
  • Fix broken toml resource type support

3.1.0 - 2023-10-12

Added

  • Add toml resource type [#13]

3.0.0 - 2023-07-23

Added

  • Add label to log messages when dry-run is enabled

Changed

  • Modify syntax for array sub-property following dot-prop 8.x upgrade

Fixed

  • Fix missing commit and tag messages in dry-run log output

2.3.0 - 2023-02-18

Added

  • Add text resource type [#7]

Changed

  • Set min node engine to >= 16.0.0
  • Move logger to bagofcli

2.2.0 - 2022-01-17

Added

  • Add resource-level version formatting [#6]
  • Add node 15 and 16 to CI workflow
  • Add upgrade-deps workflow
  • Add release-major, release-minor, release-patch workflows
  • Add publish workflow

2.1.0 - 2021-07-17

Added

  • Add array property support for yaml and json resource types

2.0.0 - 2020-07-08

Changed

  • Change module type to ESM
  • Set min node engine to >= 13.0.0
  • Replace lint type from jshint to eslint
  • Replace coverage from buster-istanbul to c8
  • Replace doc type from dox-foundation to jsdoc
  • Replace Travis CI with GH Actions

1.1.0 - 2020-06-19

Added

  • Add tag format support [#6]

1.0.0 - 2020-01-30

Added

  • Add new config properties resources.params.release_value and resources.params.post_release_value
  • Add support for custom release and post-release increment types

Changed

  • Change default post release version to use patch increment (minor increment was previously used)

0.2.0 - 2019-05-12

Added

  • Add yaml resource type
  • Add makefile resource type

0.1.0 - 2019-03-07

Added

  • Add git SCM scheme

Fixed

  • Fix release steps execution sequence
  • Fix changelog links removal following a release

0.0.1 - 2019-02-13

Added

  • Initial version