Versioning
Shipnotes computes the next version from the unreleased entries. shipnotes release writes it. The pull request check holds a release pull request to the same rules. The settings are under versioning.
Schemes
scheme |
Behavior |
|---|---|
semver (default) |
Releases carry a MAJOR.MINOR.PATCH version, with an optional pre-release such as -rc.1. |
none |
Releases carry no version. release_id must be date. current and next stop with an error, and release --version is refused. |
The rest of this page applies to semver.
The current version
Shipnotes uses the first value that it finds:
- The version of the newest release that has a version.
- The value in the first readable version file.
versioning.initial, which defaults to0.0.0.
Releases are ordered by date, then by id. Always release with a date on or after the date of the last release. An earlier --date makes an older release the newest one.
How the bump is computed
Each entry gets a level: major, minor, patch or no bump. Shipnotes decides it in this order:
- If the entry sets
bump, that value is the level.bump: nonemeans no bump. - If
bump.surfacesis set and the entry has none of those surfaces, there is no bump. - Shipnotes reads the entry’s value of
bump.fieldand looks it up inbump.levels. A value that is not inlevelsdoes not bump. For a list field, the highest level of its values applies.
The highest level of all entries wins. With release_id: version, a release without any level still takes a patch bump, because each release needs a new version.
With the default schema, kind decides:
kind |
Level |
|---|---|
removed |
major |
added, changed, deprecated |
minor |
fixed, security |
patch |
This configuration bumps from a compatibility field, and only for API changes:
fields:
title: { type: string, required: true }
kind: { type: enum, required: true, values: [added, changed, removed, fixed] }
compatibility: { type: enum, required: true, values: [additive, compatible_fix, breaking, none] }
surfaces:
app:
paths: [app/views/**, app/javascript/**]
api:
paths: [app/controllers/api/**]
versioning:
bump:
field: compatibility
levels: { breaking: major, additive: minor, compatible_fix: patch }
surfaces: [api]
An entry with surfaces: [app] does not bump the version here, unless it sets bump.
shipnotes status shows the level of each entry. This output is from a gem with the default schema:
$ shipnotes status
current version: 0.1.0
unreleased entries (2):
export-widgets-to-csv [minor]: Export widgets to CSV
price-rounding [patch]: Fix rounding in widget prices
next version: 0.2.0
Pre-releases
Choose a pre-release with --version:
shipnotes release --version 1.1.0-rc.1
A pre-release stands for the release that it precedes. A computed bump from a pre-release lands on its core version when that core already carries the level, the same rule as npm semver:
| Current | patch |
minor |
major |
|---|---|---|---|
2.0.0-rc.1 |
2.0.0 |
2.0.0 |
2.0.0 |
1.1.0-rc.1 |
1.1.0 |
1.1.0 |
2.0.0 |
1.1.1-rc.1 |
1.1.1 |
1.2.0 |
2.0.0 |
So a breaking entry after 1.1.0-rc.1 leads to 2.0.0, not 1.1.0.
Pre-releases sort by the semantic versioning rules. 1.1.0-rc.2 is newer than 1.1.0-rc.1, and 1.1.0 is newer than both.
Which versions a release can use
Without --version, the release uses the computed version. With --version, the chosen version must:
- be a valid
MAJOR.MINOR.PATCHversion, with an optional pre-release; - be greater than the current version;
- have a core version that is not below the computed version.
2.0.0-rc.1is allowed when the entries require2.0.0.
$ shipnotes release --version 1.0.5
shipnotes: version 1.0.5 must be greater than 1.1.0-rc.1
version 1.0.5 is below 1.1.0, which the entries require
The first release
The first release has nothing to bump from. When the releases folder is empty, the chosen version can equal the current version, and it can be below the computed version. Use this to keep the version that is already in your version file:
shipnotes release --version 0.1.0
Without --version, the first release also uses the computed version. After the first release, each release must be newer than the last.
Version files
release writes the new version to each file in versioning.files. The check verifies that every file holds the release version. A version file that changes outside a release fails the check.
versioning:
files:
- path: lib/acme_widgets/version.rb
pattern: 'VERSION = "(?<version>[^"]+)"'
- path: package.json
json: version
- path: openapi.json
json: info.version
With a pattern
pattern is a Ruby regular expression. Shipnotes reads and replaces the named group version. A pattern without named groups uses its first capture group.
When release writes the file, the pattern must match exactly once. Otherwise release stops with lib/acme_widgets/version.rb must match its pattern exactly once (found 2). Only the version text changes. The rest of the file stays as it is.
With a JSON path
json is a dot-separated path into a JSON document. version is the top-level key. info.version is the version key inside info. The key must exist. release rewrites the whole document with two-space indentation and a final newline.
Before and during the write
Before it writes anything, release checks that each version file exists and holds the current version:
shipnotes: lib/acme_widgets/version.rb is "0.3.0", but the release history is at 0.2.0
release computes the new content of every version file in memory first, and writes them before the release file. If one version file fails, for example because its pattern matches twice, release changes nothing. Fix the file and run release again.