Skip to content

Changelog & versioning

Record each change as a TOML fragment. Trellis uses the fragment kinds to plan version bumps and assemble changelogs. Configure kinds and templates in the root gleam.toml.

trellis changelog new [--package <pkg>] --kind <kind> --body <text>
trellis changelog check --base <ref> [--head <ref>] [--format text|json|github] [--strictness error|warn|off] [--pre <label>|none] [--bump <level>|<pkg>=<level>] [--set <pkg>=<version>]
trellis version plan [--json]
trellis version apply [--json]

A fragment is one file in .changes/unreleased/ with three keys: the package it belongs to, a configured change kind, and the entry text:

.changes/unreleased/lat_core-add-graph-parallel-task.toml
package = "lat_core"
kind = "Added"
body = "Add graph-parallel task scheduling"

The key is package; the pre-1.0 project spelling is not accepted.

changelog new writes one non-interactively. --kind and --body are explicit flags, which suits CI and agents as well as shells (--package can be omitted when the workspace has exactly one releasable package):

Terminal window
$ trellis changelog new --package lat_core --kind Fixed \
--body "Reject path deps that escape the workspace"
created .changes/unreleased/lat_core-reject-path-deps-that.toml

The filename is the package plus the first few words of the body, so a directory of fragments reads as a list of pending changes and two branches rarely pick the same name. A clash takes the next free -2, -3 suffix.

Invalid fragments (an unknown package, kind, or category, an empty body, unparseable TOML) are hard errors for check, plan, and apply, and doctor flags them on every PR.

A fragment takes one more optional key, category, when the workspace configures categories. Categories group entries by the part of a package that changed without affecting version bumps:

Terminal window
$ trellis changelog new --package lat_cli --kind Added --category build \
--body "A --watch flag"

changelog check maps a base...head diff to packages and fails (non-zero exit) if a changed releasable package has no unreleased fragment.

Terminal window
$ trellis changelog check --base origin/main
lat_core: 2 fragment(s)
lat_cli: needs a changelog entry

A package counts as changed when the diff touches any file under its directory, so a README edit trips the same gate as a behavior change. That makes the gate stricter than some repositories want; strictness turns it down.

For source bundles, changes in a direct or transitive bundled dependency also count as changes to each publishing package that includes it. Add a fragment for each publisher. The bundled package’s lifecycle and independent fragment rules do not change.

check counts only the fragments the branch itself wrote: those whose contents differ from the merge base of base...head, whether the branch added them outright or edited what the base branch already had. Fragments the branch left untouched document the PRs that added them.

This is what makes the gate per-PR. A package with an unreleased fragment from an earlier PR does not satisfy the check for a later PR that touches the same package; otherwise one entry excuses every change until the next release. The PR comment uses those fragments and the selected release mode to preview next versions, rather than using the accumulated backlog. A package whose only unreleased fragment came from the base branch shows —.

Comparing contents rather than reading the diff means an uncommitted fragment counts too, so running check locally before committing gives the same answer CI gives afterwards.

The preview uses local release configuration and explicit --pre, --bump, and --set overrides. With [tools.trellis.release] auto_pre = true, it continues the existing candidate label: 1.0.0-rc.1 becomes 1.0.0-rc.2. Explicit overrides take precedence. Select --pre none to preview stable promotion, or --pre rc to preview another RC without automatic mode selection:

Terminal window
trellis changelog check --base origin/main --format github --pre rc
trellis changelog check --base origin/main --format github --pre none

Stable packages use the fragment kinds to determine their next versions unless an override selects another version or a candidate cycle. Dependent packages use the same selected mode.

If a prerelease needs a mode or automatic selection finds conflicting labels, the comment reports Release preview unavailable with an explanation. It still reports fragment coverage and preserves the check’s verdict. Invalid flags, invalid fragments, and other planning errors remain errors.

The check is offline: it does not read a pending release PR or additional workflow overrides. The comment states that assumption. Its notes contain only this PR’s fragments and generated dependency entries, not archived candidate changes or the complete release changelog. It does not change versions, consume fragments, or authorize publication. version plan and version apply still require an explicit prerelease mode; auto_pre selects the mode for release pr and this preview.

Invalid fragments are not scoped. A fragment that does not parse fails check wherever it came from, because it blocks the next release for everyone. Scoping it would leave every PR green while the release stayed stuck.

Upgrading from v0.9.0 or earlier. The counts were previously unscoped, so a PR touching a package that already had an unreleased fragment passed without adding its own. Those PRs now report a missing entry, and the payload advanced to trellis.changelog_check/2. Set strictness to warn to land the reporting without failing builds while the open PRs catch up.

changelog.strictness controls whether a missing entry fails the check:

Value Effect
error Default. A missing entry fails the run.
warn Reported, exit 0. Advisory, so the comment still appears but the check stays green.
off Not checked. Packages and fragment counts are still reported.
gleam.toml
[tools.trellis.changelog]
strictness = "warn"

--strictness error|warn|off overrides it for one run, so a workflow can gate harder on ready-for-review PRs than the workspace default without editing the manifest.

Strictness governs missing entries, not broken ones. A fragment that does not parse, or that names an unknown package or kind, fails check at every setting including off. That is malformed input, not a policy call.

--format json emits a payload (including a markdown preview) ready for a PR sticky comment:

{
"schema": "trellis.changelog_check/2",
"ok": false,
"strictness": "error",
"has_entries": true,
"needs_entry": true,
"invalid_fragments": [],
"packages": [
{ "name": "lat_core", "changed": true, "has_entry": true, "fragments": 2 },
{ "name": "lat_cli", "changed": true, "has_entry": false, "fragments": 0 }
],
"preview": "### Changelog check\n\n| package | fragments | version |\n| --- | --- | --- |\n…"
}

needs_entry states the fact; ok states the verdict after strictness is applied, and matches the exit code. fragments, has_entry, and has_entries count only the fragments this branch wrote (see Scope). The schema field is there so a workflow can assert on the format it expects; the JSON output page covers what it promises. preview is guaranteed to be present and a string, but its Markdown is prose, so render it rather than parsing it.

--format github emits the same facts as key=value lines for $GITHUB_OUTPUT, so a workflow can post the comment without a jq pipeline:

ok=true
strictness=error
has_entries=true
needs_entry=false
needs_entry_packages=[]
invalid_fragments=[]
preview<<TRELLIS_PREVIEW
### Changelog check
| package | fragments | version |
| --- | --- | --- |
| lat_core | ✅ 2 | 1.2.0 → 1.3.0 |
### Release preview
Uses local release configuration and supplied overrides; assumes no pending release intent or additional workflow overrides. Notes include only this PR's fragments and generated dependency entries, not the complete release changelog. This preview does not authorize publication.
<details>
<summary><code>lat_core</code> 1.2.0 → 1.3.0</summary>
## v1.3.0 - 2026-07-11
### Added
- add a --dry-run flag
### Fixed
- stop truncating long names
</details>
TRELLIS_PREVIEW

needs_entry_packages and invalid_fragments are JSON arrays, read with fromJSON(); preview uses GitHub’s heredoc form because it is multi-line. See CI recipes for the workflow.

The table covers packages the PR touched or documented with a fragment. The release preview also includes dependent packages whose versions ripple, with generated Dependencies entries. Each collapsed section uses the shared version planner and changelog renderer, but includes only this PR’s contribution. See Preview policy for the mode selection and offline assumptions. If a fragment does not parse, the versions and release preview are omitted and the problem is reported instead.

version plan is the dry run: each pending package’s next version, computed from its fragments’ kinds. The largest bump among a package’s fragments wins; kinds and the bump each implies are configurable under [tools.trellis.changelog].

Terminal window
$ trellis version plan
lat_core: 1.1.0 -> 1.2.0 (2 fragment(s))
lat_mid: 0.5.0 -> 0.5.1 (dependencies: lat_core)
lat_cli: 0.4.2 -> 0.4.3 (1 fragment(s), dependencies: lat_core, lat_mid)

lat_mid owns no fragment, yet it is in that plan. When a package bumps, so does everything that path-depends on it, transitively.

A path dependency specifies no version requirement in the repository. At publish time, trellis converts it to a Hex requirement using the dependency’s current version. Bumping dependents releases those updated requirements.

The rules:

  • A rippled package bumps by whatever dependency_kind is configured to bump, patch by default. It needs no fragment of its own.
  • A package with its own fragments keeps its own bump; a ripple never lowers it. lat_cli above is 0.4.3 from its own fragment, not 0.4.3 from the ripple; whichever is larger wins.
  • Ripples follow [dev-dependencies] path deps as well as [dependencies].
  • A package excluded by @release never bumps, and a ripple stops there rather than skipping past it to its dependents.

Each rippled package gets a generated changelog entry, rendered like any other:

## v0.5.1 - 2026-07-11
### Dependencies
- Updated lat_core to 1.2.0

The entries are generated at plan time and never written to .changes/unreleased/, because the body embeds the dependency’s new version, which is only settled once the whole plan is computed. Hand-written entries of the same kind share the heading rather than producing a second section. A ripple entry names no category, so in a workspace using them it files under uncategorized_label.

Custom change_format templates can link each entry to the commit that added its fragment and to references in that commit’s subject. This is optional context, not proof that the same commit contains the code change.

The default renders each fragment as a Markdown bullet containing its body:

[tools.trellis.changelog]
change_format = "- {{ body }}"

To keep the default and add a commit link, copy - {{ body }} and append the optional link:

[tools.trellis.changelog]
change_format = '- {{ body }}{% if commit %} ([commit](https://github.com/example/project/commit/{{ commit }})){% endif %}'

Replace https://github.com/example/project with your repository URL. When commit is unavailable, this template produces the default output.

The entry context adds two values:

Value Shape When unavailable
commit Full Git object ID string null
issues Ordered array of reference objects []

Each reference has a positive integer number, nullable owner and repo, and nullable kind. Trellis recognizes #42, owner/repo#42, and HTTP or HTTPS GitHub.com issue and PR URLs. A bare reference has no repository fields or type. A qualified reference supplies both repository fields but no type. An /issues/42 URL sets kind to issue; a /pull/42 URL sets it to pull_request. These types come from the URL syntax, not an API check.

For the subject Fix #42 and other/lib#17 (https://github.com/other/lib/pull/17), issues contains:

[
{ "number": 42, "owner": null, "repo": null, "kind": null },
{ "number": 17, "owner": "other", "repo": "lib", "kind": "pull_request" }
]

References keep first-occurrence order. Repeated references with the same owner, repository, and number merge into one record. A later URL can supply the type; if URLs disagree, the first explicit type wins. Bare references stay separate because trellis does not resolve the current repository. Commit bodies, footers, fragment bodies, and other commits are not scanned. Commas and semicolons can separate references without spaces, such as https://github.com/other/lib/pull/17,#42. References inside URL queries and anchors are not extracted as separate records.

Templates construct the links. Trellis does not parse remotes, resolve URLs, check whether an issue exists, or make API requests. Set the repository URL in your template. This example keeps the default bullet and body, then adds commit and reference links:

[tools.trellis.changelog]
change_format = '''
{% set repository_url = "https://github.com/example/project" %}- {{ body }}{% if commit %} ([commit]({{ repository_url }}/commit/{{ commit }})){% endif %}{% for issue in issues %}{% set issue_repository_url = "https://github.com/" ~ issue.owner ~ "/" ~ issue.repo if issue.owner else repository_url %} ([{% if issue.owner %}{{ issue.owner }}/{{ issue.repo }}{% endif %}#{{ issue.number }}]({{ issue_repository_url }}/{% if issue.kind == "pull_request" %}pull{% else %}issues{% endif %}/{{ issue.number }})){% endfor %}'''

This template uses /issues/ when the type is unknown. GitHub redirects PR numbers addressed that way. The default remains - {{ body }}.

Trellis walks local Git history from HEAD for version apply, or --head for changelog check. It follows renames detected by Git at 50% similarity and stops at the addition in the current file lifetime. Later edits keep the original source; deletion and recreation start a new lifetime. After a squash merge, the source is the surviving squash commit.

New uncommitted fragments and generated dependency entries have no source. If parent histories identify different additions, or traversal reaches a shallow boundary, trellis leaves the metadata absent. Rename detection is heuristic, so it cannot recover every earlier path. Preview links can change after a squash merge or when more history becomes available.

Full history is not required to release. Trellis does not fetch history. Unavailable context does not fail a check or release; unexpected optional lookup failures produce a warning on stderr, outside JSON output. Fragment validation, rendering, version planning, and file-write errors remain errors. The fragment format and existing JSON schemas are unchanged.

version apply performs the release bookkeeping in one step. Per pending package, it:

  1. Renders the new version section from the fragments (minijinja templates, configurable) and stores it under .changes/<package>/.
  2. Reassembles the package’s CHANGELOG.md from its stored sections, newest first.
  3. Updates the version in gleam.toml, preserving its formatting.
  4. Patches every package’s manifest.toml so locked workspace-internal dependencies match the new versions.

version apply makes no Hex network calls.

Each package’s CHANGELOG.md is a generated file: the source of truth is the version sections under .changes/<package>/, and apply reassembles the changelog from them.

The fragment kinds do not always determine the version you want: a breaking change filed as Fixed and already merged, a package that should jump straight to 1.0.0 from 0.4.3 (a minor under the pre-1.0 rule), or a one-off number matching something upstream.

Three flags override the derivation. plan and apply accept them identically, so an override is previewable before it is applied.

Terminal window
$ trellis version plan --bump major # the whole plan
$ trellis version plan --bump lat_cli=major # one package
$ trellis version plan --set lat_cli=1.0.0 # an exact version

Precedence runs --set → per-package --bump → workspace-wide --bump → the derived level. Naming a package in both --bump and --set, naming one that is not a releasable package, or pinning a version that is not ahead of the current one are all errors raised before anything is written.

--pre <label> starts a release candidate at <label>.0. Repeating it advances the counter within the same base version rather than deriving a fresh bump from the same fragments:

Terminal window
trellis version apply --set lat_cli=1.0.0 --pre rc # 1.0.0-rc.0
trellis version apply --pre rc # 1.0.0-rc.1
trellis version apply --pre none # 1.0.0

Once a package is a candidate, --bump and --set cannot move it to another version series. Continue 1.0.0-rc.n within 1.0.0, or promote it to 1.0.0 with --pre none before starting a different series.

Each candidate includes only new changes. Trellis removes its fragments from .changes/unreleased/ and archives their source entries beside the candidate’s Markdown section, in .changes/<package>/v<prerelease>.toml. Commit both files. If you configure a different changelog dir, trellis stores the archives there.

Archives also preserve extracted commit and reference metadata before trellis consumes the fragments. Final promotion reuses those records, not the release commit. Old archives without metadata remain valid. Invalid optional metadata produces a warning and is omitted; invalid required fragment fields still block promotion.

--pre none combines those archived entries with any new unreleased fragments for the final version. For example, 1.0.0-rc.0 includes changes A and B, 1.0.0-rc.1 includes change C, and 1.0.0 includes A, B, and C plus any changes added after RC 1. Trellis keeps each candidate’s section unchanged and uses the configured grouping and templates for the final rollup.

The rollup includes only this package’s candidates for the target version, including earlier labels such as beta. Archives from other version series do not enter the rollup. Dependency entries use the final dependency versions rather than earlier candidate versions. Archives stay alongside the release history after promotion; they do not become pending changes for the next release.

fragments_retained is true for a candidate because trellis retains its fragments in archives, not in unreleased.

A prerelease labels the whole plan, rippled dependents included, so the workspace moves as one coherent candidate. A package that only gained fragments after the RC was cut still bumps normally under --pre none, so a late arrival never blocks the promotion.

An explicit version apply --pre <label> advances packages already in the cycle even without new fragments. Such a candidate has no new source entries; --pre none can still promote it and collect its earlier candidates.

Once a package sits at a prerelease, a plain version apply is an error rather than a silent bump to the next release; leaving a cycle has to be explicit:

Terminal window
$ trellis version plan
error: `lat_cli` is at prerelease 1.0.0-rc.2; pass --pre <label> for another
prerelease or --pre none to promote it

A prerelease belongs to no release series, so it moves no series tag; exact tags apply as usual, and Hex accepts prerelease versions.

On a package’s first release, trellis imports existing CHANGELOG.md history as one section under .changes/<package>/. It removes a leading title and surrounding whitespace, then stores the remaining headings and entries under the newest version its headings mention, or the current package version if none parse.

Terminal window
$ trellis version apply
bumped lat_core: 1.2.0 -> 1.3.0
adopted existing changelog history as .changes/lat_core/v1.2.0.md

Trellis preserves the imported headings and entries without reformatting them. It imports history once; later releases assemble CHANGELOG.md from the stored version sections.

doctor reports pending adoptions so this is never a surprise mid-release, and doctor --fix performs the capture up front, so the restructuring lands in its own reviewable diff:

Terminal window
$ trellis doctor
warning: package `lat_core` has changelog history that trellis has not batched
yet; it will be adopted on the next release

From here, publishing covers turning pending fragments into a release PR (trellis release pr), tags, and Hex publishes.