Skip to content

Publishing

Publishing a workspace means turning pending changelog fragments into version bumps, recording what shipped as git tags, and pushing packages to Hex in dependency order with workspace path dependencies rewritten to real Hex requirements. Trellis covers each step, and every step is idempotent, so re-running a partially failed release is safe.

trellis release pr [--base <branch>] [--branch <branch>] [--pre <label|none>] [--set <pkg=version>] [--bump <pkg=level>]
trellis tag plan [--json]
trellis tag create [--push] [--github-release]
trellis publish <pkg | --tag <tag> | --all-untagged> [--dry-run]
trellis lockfile refresh [--package <pkg>]

Tag format, path-dep rewriting, and Hex retry policy are configured under [tools.trellis.publish]:

gleam.toml
[tools.trellis.publish]
exact_tag_format = "{name}-v{version}" # lat_core-v1.2.0
series_tag_format = "{name}-v{series}" # lat_core-v1.2, lat_cli-v0.4
# Which tags a release maintains, one entry per tag. "exact" keeps the whole
# version and is immutable; "major" (v1) and "minor" (v1.2) truncate it and
# move. Default ["exact"].
package_tags = ["exact"]
# Per-package overrides, keyed by a member-path glob.
package_tags_overrides = { "packages/lat_cli" = ["exact", "major", "minor"] }
# How a path dep is rewritten to a Hex requirement at publish time, from the
# dependency's current version X.Y.Z:
# minor → ">= X.Y.Z and < (X+1).0.0" (default)
# patch → ">= X.Y.Z and < X.(Y+1).0"
# exact → "== X.Y.Z"
path_dep_requirement = "minor"
retry = { attempts = 5, initial_delay = "30s", multiplier = 2 }
repository_tag_package = "lat_cli" # anchor package
repository_tag_format = "repo-v{series}" # repo-v0.4
# All three repository keys are required together, or omitted together.
repository_tags = ["major", "minor"] # repo-v0 and repo-v0.4

trellis release pr turns pending fragments into a release pull request: it runs version apply on a release branch (default release/pending), commits the bumps, force-pushes (so the branch is regenerated on each run), and creates or updates the PR via the GitHub API. It needs a token: GITHUB_TOKEN (ambient in GitHub Actions), GH_TOKEN, or a logged-in gh CLI as the fallback (gh auth token). The body carries the bump table and each package’s new CHANGELOG section. It requires a clean working tree and is a no-op when there are no fragments.

release pr accepts the same repeatable --set and --bump, plus --pre, as version plan and version apply. Use one release branch and one open PR for the whole cycle:

Terminal window
# Choose the stable target and candidate label: 1.3.0-rc.0.
trellis release pr --set lat_core=1.3.0 --pre rc
# After merging and publishing that PR, prepare 1.3.0-rc.1.
trellis release pr --pre rc
# After the last candidate merges and publishes, prepare stable promotion.
trellis release pr --pre none

Each request regenerates from the selected base, not the old release branch. Retrying against an unchanged base produces the same candidate version; the next candidate follows a merge. This is version repeatability, not a promise of identical commit hashes or rendering dates. On a prerelease base, choose a label, --pre none, or an explicit version override instead of relying on the default stable bump.

Candidate fragments stay unreleased, including fragments for dependent packages bumped by the release plan. Stable promotion consumes them and renders the final changelog. Review and merge each PR before publishing; never publish an unmerged candidate branch.

The Gleam/Hex workflow handles manual requests, pauses automatic preparation during this cycle, and publishes only the approved merge commit. It blocks new preparation until publication and tagging of the previous merged release succeed, then restores automatic stable preparation after a published promotion.

tag plan lists the tags the current versions call for and don’t have yet. tag create reconciles them in topological order; --push pushes them, and --github-release (which implies --push and needs the same GitHub token as release pr) also creates a GitHub Release per exact tag, with the matching CHANGELOG section as the body. --dry-run reports every tag, push, and release it would perform without doing any of them.

Each entry in a package’s package_tags falls into one of two lifecycles:

  • Exact tags ({name}-v{version}) are immutable. They are created once, fetched when origin already has them, and never rewritten. Local and remote disagreeing about what one names is an error, not something to reconcile.
  • Series tags ({name}-v{series}) move. Releasing a new version in the series force-moves its tag to the release commit and force-pushes it, so consumers can track lat_cli-v0.4 and follow the series instead of chasing patch tags. trellis pin gives git-dependency consumers a reviewable way to do exactly that. The signal is the package’s manifest version stored at the tag, so a commit that does not release the package, such as another package’s release or a docs change, leaves its series tags alone. The series is derived from the version; see series tags.
  • Repository tags are independent of any package’s list. Trellis moves the configured tag only when the anchor package’s manifest version differs from the version at that tag. A series change creates a new tag and leaves the prior series tag intact.
Terminal window
$ trellis tag plan
lat_core: 1.2.0 needs tag lat_core-v1.2.0
lat_cli: 0.4.3 needs tag lat_cli-v0.4.3
lat_cli: 0.4.3 moves tag lat_cli-v0.4
$ trellis tag create --github-release
tagged lat_core-v1.2.0
pushed lat_core-v1.2.0
tagged lat_cli-v0.4.3
pushed lat_cli-v0.4.3
moved lat_cli-v0.4
force-pushed lat_cli-v0.4

--github-release skips every moving tag. A release attached to a moving tag would silently retarget on the next release, so only immutable per-version tags carry one.

Prereleases use immutable exact tags such as lat_core-v1.3.0-rc.0 when package_tags includes exact. Neither package nor repository moving series tags advance during a candidate release. New GitHub releases for prerelease manifest versions have prerelease: true; stable versions have it set to false, regardless of custom tag spelling. Retrying skips an existing GitHub release rather than rewriting it. If an older candidate release was misclassified, its owner must correct its prerelease setting on GitHub.

With no exact entry a package has no per-version tags at all, so there is no tag to trigger a publish from: run trellis publish --all-untagged on release-PR merge instead. Passing a series tag to publish --tag is an error, because it names a package but no particular version.

Repository tags identify repository snapshots rather than package releases, so neither publish --tag nor ci tag-package resolves them.

publish selects members whose release lifecycle is hex. A named package and --tag <tag> both refuse a workspace or git_only package, and --all-untagged only ever considers hex members. Without source bundling, it runs these steps per package, in dependency order:

  1. Idempotency check. One Hex API query; versions already published are skipped.
  2. Validation. gleam format --check, gleam build --warnings-as-errors, and gleam test, run against the original manifest with path deps intact.
  3. Path-dep rewrite. Computed from the graph, never hand-listed: each workspace path dependency becomes the Hex requirement derived from that dep’s current version, per path_dep_requirement. The version map only ever holds hex members, so a path dependency on a git_only or workspace member needs explicit source bundling; otherwise the rewrite fails rather than publishing something Hex could never resolve.
  4. Publish. gleam publish --yes.
  5. Restore. The original gleam.toml comes back even when publishing fails; the repo never shows rewritten files.

Every Hex-touching step runs under the configured retry backoff policy.

Terminal window
# Publish the package a pushed tag points at:
trellis publish --tag "$GITHUB_REF_NAME"
# Or publish everything whose version isn't on Hex yet, in one run:
trellis publish --all-untagged
# See what would be published (and rewritten) without doing it:
trellis publish --all-untagged --dry-run

--tag lat_core-v1.2.0 resolves a pushed tag to its package and refuses to publish if the tag version doesn’t match gleam.toml. --all-untagged publishes everything not yet on Hex, enabling a single publish run per release instead of one per tag.

Dev-only path deps to a non-hex package are left alone, because Hex doesn’t ship dev dependencies. Without explicit source bundling, a regular [dependencies] path dep to a package whose lifecycle is less capable than its dependent’s refuses to publish, and doctor catches that boundary on every PR; see Release lifecycle.

Use source bundling when a Hex package needs code from a workspace package that you do not want to publish on Hex. Keep separate packages for development; trellis copies the selected dependency’s source into the publishing package for release.

Bundling copies source; it does not rewrite modules. Trellis does not rename modules, add a package-name prefix, or rewrite imports. Module names must be unique across the publishing package, its bundled dependencies, and the other dependencies in a consumer’s build. Use distinct module paths, such as lib_a/parser and lib_b/parser, rather than defining parser in both packages. Different package names alone do not prevent module collisions.

gleam.toml
[tools.trellis]
members = ["packages/*"]
[tools.trellis.publish.bundle]
lib_a = ["lib_b"]
[tools.trellis.publish.lifecycle.packages]
"packages/lib_b" = "workspace"

In packages/lib_a/gleam.toml, keep the normal path dependency:

[dependencies]
lib_b = { path = "../lib_b" }

The publish.bundle keys are exact publishing package names, not paths or globs. List each direct non-Hex runtime dependency. A selected package must have lifecycle workspace or git_only; bundling does not change its lifecycle. Trellis also includes its transitive non-Hex runtime path dependencies once, but keeps Hex packages as external requirements. It does not include bundled packages’ tests or dev dependencies.

For example, these workspace sources:

Development packages
packages/lib_a/src/lib_a.gleam
packages/lib_b/src/lib_b.gleam
packages/lib_b/src/lib_b/parser.gleam

produce one package’s source tree:

Published lib_a source
src/lib_a.gleam
src/lib_b.gleam
src/lib_b/parser.gleam

Keep import lib_b and import lib_b/parser unchanged. The published package has lib_a’s name and version, with no runtime dependency entry for lib_b. Consumers install lib_a without a separate lib_b Hex release.

For trellis publish lib_a, trellis creates a temporary package, combines the source trees, removes bundled dependency entries, and adds their external runtime requirements. It runs gleam format --check, gleam build --warnings-as-errors, and gleam test in that directory before publishing from it. It keeps the checkout’s source, manifests, and lockfiles unchanged and removes the temporary package after success or failure. Publisher tests can still use local dev-only path dependencies. Run the bundled packages’ own tests through your normal workspace test task.

Run the workspace tests and bundle checks before a release:

Terminal window
trellis run test
trellis doctor
trellis publish lib_a --dry-run

doctor checks the combined source inventory and manifest without building the package or creating a temporary package. Dry-run reports the bundled packages and external requirements without running Gleam; it still queries Hex to check whether the version already exists.

Check Conflicts it can detect
trellis doctor File and module-name collisions inside each configured bundle, incompatible internal-module rules, and differing dependency or compiler requirements.
trellis publish lib_a --dry-run The same preparation conflicts for the selected unpublished package.
trellis publish lib_a Preparation conflicts plus errors from building and testing the combined package with its resolved dependencies before upload.

Two independent publishers can each include the same module names without a conflict in either package alone. A consumer that installs both, or installs a bundled package alongside a separate release of its bundled dependency, can still encounter a collision. Neither publisher’s doctor check can predict that future dependency combination; the consumer’s build must check it.

Trellis preserves module names and imports, including native Erlang and JavaScript source files and their local source helpers. It preserves internal_modules rules, including each package’s defaults, and rejects patterns that would make another package’s public modules internal. It merges identical dependency requirements and promotes an identical publisher dev dependency to runtime when needed. Differing version requirements or compiler constraints require you to align the manifests first.

Bundled OTP application startup modules, priv directories, and runtime git dependencies are not supported. Trellis merges erlang.extra_applications but rejects references to removed bundled applications. Native code must not rely on the bundled package’s former OTP application identity; trellis cannot detect dynamic application-name references.

Write a changelog fragment for each publishing package affected by a change in bundled code. changelog check includes direct and transitive bundled changes in those packages’ checks. A workspace dependency still has no independent release or changelog; a git_only dependency keeps its own rules.

Bundling publishes the dependency’s source in the Hex archive. Check that you can redistribute it and that the publishing package declares the required licences. Trellis includes attributed licence notices in a standard licence file.

lockfile refresh --package <pkg> scopes gleam deps download to one package, with retry. Refreshing the whole workspace at once is what gets a runner rate-limited by Hex.

Both of these flows are supported; the difference is policy, not tooling:

Shape Flow
Tags as trigger Release PR merges → tag create --push → each pushed tag triggers a workflow running publish --tag "$GITHUB_REF_NAME".
Tags as record Release PR merges → publish --all-untagged (one run, topologically ordered) → tag create --push --github-release records what shipped.

The CI recipes provide a copyable publish-then-tag workflow with candidate/promotion controls and recovery.