Getting started

This guide sets up Shipnotes in a gem called acme_widgets. At the end, the gem has a changelog entry, a CI check and its first release. The steps for a Rails app are the same, except for init.

Install

Add the gem to the development group of your Gemfile:

gem "shipnotes", group: :development

If you mount the Rails engine, put the gem in the default group instead. Then install it:

bundle install

Create the configuration

Run init in the project root. For a gem, give it the file that holds VERSION:

bundle exec shipnotes init --version-file lib/acme_widgets/version.rb
created .shipnotes.yml
created changelog/unreleased/
created changelog/releases/

init writes .shipnotes.yml and two folders, each with a .keep file. It stops with an error if .shipnotes.yml already exists. The file it writes for acme_widgets is:

# Shipnotes configuration. Every key is optional; see the README for the full list.
directory: changelog

fields:
  title: { type: string, required: true, description: One line that names the change }
  kind: { type: enum, required: true, values: [added, changed, deprecated, removed, fixed, security] }
  body: { type: text, description: Details for the reader }

surfaces: {}

versioning:
  scheme: semver
  release_id: version
  files:
    - path: lib/acme_widgets/version.rb
      pattern: 'VERSION = "(?<version>[^"]+)"'

render:
  output: CHANGELOG.md

The init options are:

Option Effect
--version-file PATH Adds PATH to versioning.files with the pattern VERSION = "(?<version>[^"]+)". release then writes the new version to that file.
--rails Adds an app surface for app/views/**, app/javascript/**, config/routes.rb and config/routes/**, without app/views/admin/**. Without --version-file, it also sets release_id: date.

For a Rails app, run bundle exec shipnotes init --rails. The Configuration page describes every key.

Commit the new files before you continue:

git add .shipnotes.yml changelog
git commit -m "Add Shipnotes"

Write the first entry

Make a change on a branch. Then add an entry for it. On a terminal, shipnotes new asks for each field:

$ bundle exec shipnotes new
title (One line that names the change): Export widgets to CSV
kind [added, changed, deprecated, removed, fixed, security]: added
body (Details for the reader) (optional): AcmeWidgets.export writes every widget to a CSV file.
created changelog/unreleased/export-widgets-to-csv.yml

You can also give every field as a flag:

bundle exec shipnotes new --title "Export widgets to CSV" --kind added \
  --body "AcmeWidgets.export writes every widget to a CSV file."

The entry is one YAML file. Its file name is its id:

---
title: Export widgets to CSV
kind: added
body: AcmeWidgets.export writes every widget to a CSV file.

You can edit this file by hand. Writing entries explains the fields and the validation rules.

See the pending release

status lists the unreleased entries, the bump that each entry causes and the next version:

$ bundle exec shipnotes status
current version: 0.1.0
unreleased entries (1):
  export-widgets-to-csv [minor]: Export widgets to CSV
next version: 0.2.0

lint validates every entry and release file:

$ bundle exec shipnotes lint
✓ changelog entries are valid

Run the check

Commit the entry. Then run the same check that CI runs, against your base branch:

$ git add -A && git commit -m "Export widgets to CSV"
$ bundle exec shipnotes check main
✓ shipnotes check passed against main

The check reads committed files only. Without an entry, the check fails:

✗ entry: this diff needs a changelog entry (any entry); add one with `shipnotes new`

Add the CI job

Add this job to a GitHub Actions workflow that runs on pull requests:

changelog:
  if: github.event_name == 'pull_request'
  runs-on: ubuntu-latest
  permissions: { contents: read, pull-requests: read }
  steps:
    - uses: actions/checkout@v4
      with: { fetch-depth: 0 }
    - uses: ruby/setup-ruby@v1
      with: { bundler-cache: true }
    - env:
        GH_TOKEN: ${{ github.token }}
        PR_NUMBER: ${{ github.event.pull_request.number }}
      run: bundle exec shipnotes check "origin/${{ github.base_ref }}" --skip-label no-changelog

fetch-depth: 0 is necessary, because the check compares your branch with its merge base. A pull request with the no-changelog label skips the entry rule. The other checks still run. Pull request check explains each check and the options.

Make the first release

After the change merges, create a release branch from your default branch and run release. Use --dry-run first to see what it changes:

$ bundle exec shipnotes release --dry-run
would release 0.2.0 (0.1.0 -> 0.2.0) with export-widgets-to-csv
  would write changelog/releases/0.2.0.yml
  would write lib/acme_widgets/version.rb
  would write CHANGELOG.md
  would delete changelog/unreleased/export-widgets-to-csv.yml

The first release can keep the version that is already in your version file. To release 0.1.0 instead of 0.2.0, run bundle exec shipnotes release --version 0.1.0. Later releases must be newer than the last one.

Run the release without --dry-run:

bundle exec shipnotes release

Open the result as its own pull request. The check verifies it and prints release PR verified. After the merge, publish the gem and create a GitHub release with the output of shipnotes notes. Releasing shows a workflow that does this when the version changes.