Ruby API

The command line uses a few Ruby classes. A project can call the same classes, for example from a Rake task or a custom page. Load them with require "shipnotes". Every error that Shipnotes raises is a Shipnotes::Error.

Shipnotes::Config

Shipnotes::Config.load(root, path: nil) reads .shipnotes.yml in root, or the file at path relative to root. A missing file gives the defaults. An invalid file raises Shipnotes::Config::Error with the message that the Configuration page lists.

require "shipnotes"

config = Shipnotes::Config.load(Dir.pwd)
config.directory                  # => "changelog"
config.unreleased_dir             # => "changelog/unreleased"
config.fields.keys                # => ["title", "kind", "body", "bump"]
config.surfaces.keys              # => [] without surfaces
config.versioning.semver?         # => true

Shipnotes::Config.new(root:, data:) builds a configuration from a hash with string keys, without a file:

config = Shipnotes::Config.new(root: Dir.pwd, data: { "surfaces" => { "app" => { "paths" => ["app/views/**"] } } })
config.check.require_entry        # => "surfaces"

Other readers: root, rules, triggers, check, versioning, render, publication, requires, releases_dir, field(name), surface(key), surfaces? and contract_surfaces.

Shipnotes::Repository

Shipnotes::Repository.new(config) reads the changelog files in the working tree.

repository = Shipnotes::Repository.new(config)
repository.entries.map(&:id)      # => ["add-widget-tags"]
repository.releases.map(&:id)     # => ["0.2.0", "1.0.0"], oldest first
repository.last_version           # => "1.0.0"
repository.problems.map(&:to_s)   # => [] when lint passes
Method Returns
entries The unreleased entries, as Shipnotes::Entry values.
releases The valid release files, oldest first, as Shipnotes::Release values. An invalid release file is left out.
released_entries A hash of entry id to entry, for every released entry.
last_version The version of the newest release that has one, or nil.
problems The lint problems. Each has path and message, and to_s gives PATH: MESSAGE.

A Shipnotes::Entry has id, data, title, surfaces, to_h and []. entry["body"] reads any field. A Shipnotes::Release has id, date, version, entries, includes_entry?(id) and to_h.

Shipnotes::Renderer

Shipnotes::Renderer.new(config) renders Markdown from the releases. It shows only public entries.

renderer = Shipnotes::Renderer.new(config)
renderer.changelog                          # the changelog as a String
renderer.changelog(unreleased: true)        # with an Unreleased section
renderer.notes(repository.releases.last)    # one release, for a GitHub release
renderer.write                              # writes render.output, returns its path or nil

changelog uses render.template when it is set. notes always uses the built-in release notes layout.

Custom templates

Set render.template to an ERB file, relative to the root:

render:
  template: config/changelog.md.erb
  headings: { fixed: Bug fixes }

The template uses ERB with the - trim mode, so -%> removes the line break after a tag. Shipnotes changes three or more line breaks in a row to two. This template lists each change with its id:

# <%= title %>

All notable changes to acme_widgets.
<% releases.each do |release| -%>

## <%= release.version %> (<%= release.date %>)
<% groups(release.entries).each do |name, entries| -%>

### <%= name %>

<% entries.each do |entry| -%>
- <%= entry.title %> (`<%= entry.id %>`)
<% end -%>
<% end -%>
<% end -%>

The output is:

# Changelog

All notable changes to acme_widgets.

## 1.0.0 (2026-12-02)

### Removed

- Remove the legacy XML export (`remove-the-legacy-xml-export`)

## 0.2.0 (2026-12-01)

### Added

- Export widgets to CSV (`export-widgets-to-csv`)

### Bug fixes

- Fix rounding in widget prices (`price-rounding`)

The template runs in a Shipnotes::Renderer::View. It can call these methods:

| Method | Returns | | — | — | | title | render.title. | | releases | The releases with public entries, newest first. Each has only its public entries. | | unreleased | The public unreleased entries with --unreleased, otherwise []. | | config | The Shipnotes::Config. | | release_heading(release) | [ID] - DATE, with ` (VERSION) when the version differs from the id. | | groups(entries) | Pairs of [heading, entries] by render.group_by. The heading is nil without grouping. | | heading(value) | The heading for a group value: its item in render.headings, or the value with _ and - changed to spaces and the first letter capitalized. | | section(entries, level: 3) | Markdown for the grouped entries, with headings at level. | | entry_markdown(entry) | One list item: the title, and the render.details` fields indented under it. |

The built-in template is:

# <%= title %>
<% if unreleased.any? -%>

## [Unreleased]
<%= section(unreleased) -%>
<% end -%>
<% releases.each do |release| -%>

## <%= release_heading(release) %>
<%= section(release.entries) -%>
<% end -%>

Shipnotes::Publication

Shipnotes::Publication.new(config, repository: Repository.new(config), flag_enabled: nil) applies the publication rules. The Rails engine uses it. You can use it in your own page.

publication = Shipnotes::Publication.new(config, flag_enabled: ->(flag) { Flipper.enabled?(flag) })
publication.releases(surface: "app").each do |release|
  release.entries.each { |entry| puts "#{release.date} #{entry.title} (#{publication.status(entry)})" }
end
Method Returns
releases(surface: nil) The releases with public entries, newest first. surface is a key or a list of keys. With it, each release keeps only the entries on those surfaces.
entries(surface: nil) The entries of those releases, in one list.
public_entries(entries) The public entries of a list.
public?(entry) true when the entry is public.
status(entry) "pending" when the entry’s flag is off, otherwise "released".

Shipnotes::Releaser

Shipnotes::Releaser.new(config) runs a release, as shipnotes release does. call takes version:, date: and dry_run:. All are optional. It returns nil when there is no unreleased entry.

result = Shipnotes::Releaser.new(config).call(dry_run: true)
result.version            # => "1.1.0"
result.previous_version   # => "1.0.0"
result.level              # => :minor
result.entries            # => ["add-widget-tags"]
result.written            # => ["changelog/releases/1.1.0.yml", "lib/acme_widgets/version.rb", "CHANGELOG.md"]
result.deleted            # => ["changelog/unreleased/add-widget-tags.yml"]

The result also has id, date and dry_run. When the release cannot run, call raises Shipnotes::Releaser::Error with the reason. See Releasing.

Shipnotes::Check

Shipnotes::Check.new(config, base:, entry_required: true, oasdiff: nil) runs the pull request check. config.root must be in a git repository.

result = Shipnotes::Check.new(config, base: "origin/main").call
result.passed?   # => true when there is no error
result.errors    # => ["entry: this diff needs a changelog entry (any entry); add one with `shipnotes new`"]
result.notes     # => ["trigger: feature flag"]

entry_required: false has the effect of --skip-entry. oasdiff: has the effect of --oasdiff. A git failure raises Shipnotes::GitDiff::Error.

For differs, see Contracts and differs.