Writing entries
An entry describes one change. It is one YAML file in changelog/unreleased/. shipnotes release later moves every unreleased entry into one release file.
Entry files
The file name is the entry’s id. changelog/unreleased/export-widgets-to-csv.yml has the id export-widgets-to-csv.
title: Export widgets to CSV
kind: added
body: AcmeWidgets.export writes every widget to a CSV file.
These rules apply to the file:
- The file name must be a lowercase slug: letters
a-z, digits and-, starting with a letter or digit. - The extension must be
.yml. Any other file in the changelog folder is a lint error. Files whose names start with., such as.keep, are ignored. - The content must be a YAML mapping. Aliases are not allowed.
- An id must be unique. An unreleased entry cannot reuse the id of an entry in a release.
The directory comes from the directory key in .shipnotes.yml. The default is changelog. See Configuration.
The default schema
Without a fields key, Shipnotes uses the Keep a Changelog schema:
| Field | Type | Required | Values |
|---|---|---|---|
title |
string | yes | One line that names the change. |
kind |
enum | yes | added, changed, deprecated, removed, fixed, security |
body |
text | no | Details for the reader. |
kind decides the version bump. removed bumps the major version. added, changed and deprecated bump the minor version. fixed and security bump the patch version. To use other fields, see fields.
Fields that Shipnotes adds
Shipnotes adds two fields to every schema. You cannot declare them yourself.
| Field | Added when | Type | Purpose |
|---|---|---|---|
surfaces |
surfaces are configured |
list, required | The surfaces the change touches, for example [app, api]. The allowed values are the surface keys. |
bump |
always | enum, optional | major, minor, patch or none. Overrides the computed bump for this entry. |
An entry for an app with app and api surfaces looks like this:
title: List widgets over the API
kind: added
surfaces: [api]
body: GET /api/widgets returns every widget on the account.
Use bump when the computed level is wrong for one change. bump takes precedence over the bump field and over versioning.bump.surfaces:
title: Rename the widget_id parameter to id
kind: changed
surfaces: [api]
bump: major
bump: none removes the entry from the bump. With release_id: version, a release still takes at least a patch bump. Versioning has the full rule.
Create an entry with shipnotes new
shipnotes new writes a valid entry file. It takes the values from flags. On a terminal, it asks for each field that a flag did not set.
Interactive
On a terminal, new asks for the fields in schema order:
$ shipnotes new
title (One line that names the change): Bulk delete widgets
kind [added, changed, deprecated, removed, fixed, security]: 1
body (Details for the reader) (optional):
surfaces (Which surfaces the change touches) [app, api] (comma separated): app,api
created changelog/unreleased/bulk-delete-widgets.yml
- For an enum, type the value or its position in the list.
1selects the first value. - For a list, separate the values with commas.
- For an optional field, press Enter to skip it. A field with a
defaultshows it in brackets and uses it when you press Enter. - An invalid answer prints the error and asks again.
newdoes not ask forbump. Set it with--bump.
With flags
new makes one flag for each field in your schema. A field name with _ becomes a flag with -, so breaking_change becomes --breaking-change. Run shipnotes new --help to see the flags for your schema:
$ shipnotes new --help
Usage: shipnotes new [--FIELD VALUE ...] [--slug SLUG]
--root DIR Project root (default: the nearest folder with .shipnotes.yml)
--title VALUE One line that names the change
--kind VALUE Set kind
--body VALUE Details for the reader
--bump VALUE Override the version bump
--field NAME=VALUE Set any field
--slug SLUG File name for the entry (default: from the title)
-h, --help Show this help
The flag help text is the field’s description, or Set NAME without one.
shipnotes new --title "List widgets over the API" --kind added --surfaces api
shipnotes new --title "Faster search" --kind changed --field surfaces=app --field audience=internal
--field NAME=VALUEsets any field by its schema name.- A list value is comma separated:
--surfaces app,api. - A boolean value is true for
true,yes,yor1, and false for any other text. --slug SLUGsets the file name. Without it,newmakes a slug from the title, with at most 60 characters. If that id is taken,newadds-2,-3and so on.
When the input is not a terminal, new does not ask. A field that has no flag gets its default. If a required field is still empty, new stops and prints the flags it needs:
$ shipnotes new --title "Export widgets" < /dev/null
shipnotes: missing required fields: kind
pass --kind added|changed|deprecated|removed|fixed|security
new validates the entry before it writes the file. It never writes an invalid entry.
Validation
shipnotes lint validates every file under the changelog directory. It prints one line for each problem and exits with status 1:
$ shipnotes lint
✗ changelog/notes.txt: only .yml files belong in changelog/
✗ changelog/unreleased/Bad_Name.yml: file name must be a lowercase slug (a-z, 0-9, -)
✗ changelog/unreleased/Bad_Name.yml: unknown fields: colour
✗ changelog/unreleased/Bad_Name.yml: kind must be one of added, changed, deprecated, removed, fixed, security
When every file is valid, it prints ✓ changelog entries are valid and exits with status 0.
Entry errors
| Message | Cause |
|---|---|
must be a mapping |
The file is not a YAML mapping. |
is not valid YAML: ... |
The YAML does not parse. |
file name must be a lowercase slug (a-z, 0-9, -) |
The file name is not a slug. |
unknown fields: NAME, ... |
The entry has a field that the schema does not declare. |
NAME is required |
A required field is missing or empty. |
NAME must be a string |
A string or text field has another type. |
NAME must be one of A, B, C |
An enum value is not in values. |
NAME must be a non-empty list |
A list field is not a non-empty list of strings. |
NAME lists a value twice |
A list field repeats a value. |
NAME has unknown values: X (allowed: A, B) |
A list value is not in values. |
NAME must be a YYYY-MM-DD date |
A date field is not a valid date. |
NAME must be true or false |
A boolean field is not true or false. |
NAME is required when FIELD VALUE |
A rule requires the field. |
NAME cannot be "VALUE" when FIELD VALUE |
A rule rejects the value. |
id ID is already in release RELEASE; pick a new file name |
A release already holds an entry with this id. |
A rule with a message prints that message instead of its own errors.
Release file errors
Lint also validates the files in changelog/releases/. shipnotes release writes these files, so an error usually means a hand edit. Each entry in a release is validated against the current schema. If you remove a field from the schema, the old releases that use it become invalid. Keep a field in the schema while a release uses it.
| Message | Cause |
|---|---|
release id is missing |
The file has no release key. |
release ID does not match its file name |
The file name is not ID.yml. |
date must be a YYYY-MM-DD date |
date is missing or not valid. |
release must be a version or a YYYY.MM.DD.N id |
The id has neither format. |
version "X" does not match release ID |
A version id differs from version. |
date DATE does not match release ID |
A date id differs from date. |
entries must be a non-empty list |
The release has no entries. |
entries[N] needs a slug id |
An entry has no valid id. |
entry ID is already in release RELEASE |
Two releases hold the same entry. |
shipnotes status prints the problem count. shipnotes release refuses to run while a problem exists. shipnotes check reports each problem with a schema: prefix.