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]Fragments
Section titled “Fragments”A fragment is one file in .changes/unreleased/ with three keys: the package
it belongs to, a configured change kind, and the entry text:
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):
$ 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.tomlThe 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:
$ trellis changelog new --package lat_cli --kind Added --category build \ --body "A --watch flag"Enforcing entries on PRs
Section titled “Enforcing entries on PRs”changelog check maps a base...head diff to packages and fails (non-zero
exit) if a changed releasable package has no unreleased fragment.
$ trellis changelog check --base origin/mainlat_core: 2 fragment(s)lat_cli: needs a changelog entryA 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.
Preview policy
Section titled “Preview policy”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:
trellis changelog check --base origin/main --format github --pre rctrellis changelog check --base origin/main --format github --pre noneStable 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.
Strictness
Section titled “Strictness”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. |
[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.
The JSON payload
Section titled “The JSON payload”--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.
Driving a PR comment
Section titled “Driving a PR comment”--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=truestrictness=errorhas_entries=trueneeds_entry=falseneeds_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_PREVIEWneeds_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.
Planning a release
Section titled “Planning a release”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].
$ trellis version planlat_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)Dependents bump too
Section titled “Dependents bump too”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_kindis 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_cliabove is0.4.3from its own fragment, not0.4.3from the ripple; whichever is larger wins. - Ripples follow
[dev-dependencies]path deps as well as[dependencies]. - A package excluded by
@releasenever 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.0The 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.
Linking entries to their source
Section titled “Linking entries to their source”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.
Default entry format
Section titled “Default entry format”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.
Commit and reference context
Section titled “Commit and reference context”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.
Applying it
Section titled “Applying it”version apply performs the release bookkeeping in one step. Per pending
package, it:
- Renders the new version section from the fragments (minijinja templates,
configurable) and stores it under
.changes/<package>/. - Reassembles the package’s
CHANGELOG.mdfrom its stored sections, newest first. - Updates the version in
gleam.toml, preserving its formatting. - Patches every package’s
manifest.tomlso 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.
Overriding the derived version
Section titled “Overriding the derived version”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.
$ 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 versionPrecedence 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.
Prereleases
Section titled “Prereleases”--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:
trellis version apply --set lat_cli=1.0.0 --pre rc # 1.0.0-rc.0trellis version apply --pre rc # 1.0.0-rc.1trellis version apply --pre none # 1.0.0Once 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:
$ trellis version planerror: `lat_cli` is at prerelease 1.0.0-rc.2; pass --pre <label> for anotherprerelease or --pre none to promote itA prerelease belongs to no release series, so it moves no series tag; exact tags apply as usual, and Hex accepts prerelease versions.
Adopting an existing changelog
Section titled “Adopting an existing changelog”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.
$ trellis version applybumped lat_core: 1.2.0 -> 1.3.0adopted existing changelog history as .changes/lat_core/v1.2.0.mdTrellis 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:
$ trellis doctorwarning: package `lat_core` has changelog history that trellis has not batchedyet; it will be adopted on the next releaseFrom here, publishing covers turning pending fragments
into a release PR (trellis release pr), tags, and Hex publishes.