version_bump/plugins/hex
The Hex / Gleam publish plugin (plugin name “hex”).
The Gleam analogue of @semantic-release/npm. It publishes the package to
the Hex package repository with gleam publish. Two things differ from npm:
the version lives in gleam.toml (not package.json), and Hex has no
dist-tag / channel concept, so add_channel is intentionally NOT implemented
(a prerelease is published as an ordinary semver prerelease and Hex surfaces
it as such).
- verify_conditions: a
gleam.tomlexists incontext.cwdcarrying thedescriptionandlicencesfields thatgleam publishrequires, and aHEXPM_API_KEYis available (skipped on a dry run, since a dry run never publishes — matching the npm/github plugins here). - prepare: rewrite the top-level
versionfield ofgleam.toml. - publish: run
gleam publish --yesand report the hex.pm release URL.
set_version and package_name are PURE string functions, exported so the
version rewrite and URL construction can be unit-tested without any IO.
Values
pub fn package_name(
gleam_toml: String,
) -> Result(String, error.ReleaseError)
Read the package name from a gleam.toml document. PURE.
pub fn plugin() -> plugin.Plugin
Build the Hex plugin: implements verify_conditions, prepare, and
publish. There is deliberately no add_channel — Hex has no dist-tags.
pub fn published_ok(output: String) -> Bool
True when gleam publish output confirms a successful publish. gleam prints
“Published package and documentation” on success; the lowercase “published”
in its <1.0.0 warning does not contain this marker, so an aborted publish is
correctly treated as a failure. Exposed for testing.
pub fn set_version(
gleam_toml: String,
version: String,
) -> Result(String, error.ReleaseError)
Replace the top-level version = "..." value in a gleam.toml document with
version, leaving the rest of the file intact. PURE.