version_bump/config
Configuration shapes plus the entry point for loading config from a project.
The load implementation (reading .releaserc / release.config / package.json)
is fleshed out by the config module work; the type is owned here so every
other module can depend on it without a cycle.
Types
A single branch entry from configuration (before resolution against git).
pub type BranchConfig {
BranchConfig(
name: String,
channel: option.Option(String),
prerelease: option.Option(String),
range: option.Option(String),
)
}
Constructors
-
BranchConfig( name: String, channel: option.Option(String), prerelease: option.Option(String), range: option.Option(String), )
pub type Config {
Config(
repository_url: option.Option(String),
tag_format: String,
branches: List(BranchConfig),
plugins: List(PluginSpec),
dry_run: Bool,
ci: Bool,
versioning_mode: semver.VersioningMode,
)
}
Constructors
-
Config( repository_url: option.Option(String), tag_format: String, branches: List(BranchConfig), plugins: List(PluginSpec), dry_run: Bool, ci: Bool, versioning_mode: semver.VersioningMode, )Arguments
- versioning_mode
-
SemVer “initial development” (0.y.z) mode. In
InitialDevelopment, while major is 0 a breaking change bumps the minor version instead of jumping to 1.0.0, and the first release starts at 0.1.0. Parsed from the booleaninitial_developmentconfig key.
A configured plugin: its module name plus raw, string-keyed options. Options are kept as strings here to avoid a dynamic value type in the core; individual plugins parse what they need.
pub type PluginSpec {
PluginSpec(name: String, options: dict.Dict(String, String))
}
Constructors
-
PluginSpec(name: String, options: dict.Dict(String, String))
Values
pub fn default() -> Config
The default configuration for a Gleam project: commit analysis, release
notes, publishing to Hex, and a GitHub release, over the conventional release
branches. (This is the Gleam-first analogue of semantic-release’s defaults,
which publish to npm; swap hex for npm to release a JavaScript package.)
pub fn load(
cwd cwd: String,
) -> Result(Config, error.ReleaseError)
Load configuration from the project rooted at cwd, falling back to
default() when no config file is present.
The lookup order is:
.releaserc.json.releaserc(parsed as JSON)release.config.json.releaserc.toml(parsed as TOML)[tools.version_bump]ingleam.toml(the Gleam-native location; also derivesrepository_urlfrom the[repository]field)- the
"release"key ofpackage.json
The first file that exists and parses wins; its values are merged over
default(). Since every Gleam project has a gleam.toml, step 5 means a
Gleam package needs no separate config file: with no [tools.version_bump]
table it still releases using the defaults plus the derived repository URL.
When nothing is found, Ok(default()) is returned.
pub fn parse_gleam_toml_config(
toml_string: String,
) -> Result(Config, error.ReleaseError)
Parse the [tools.version_bump] table out of a gleam.toml — the
Gleam-native config location. Keys use snake_case (tag_format, dry_run,
branches, plugins). repository_url is taken from the table if present,
otherwise derived from gleam.toml’s standard [repository] field. Per-plugin
options live in [tools.version_bump.plugin_options.<name>] sub-tables.
A gleam.toml with no [tools.version_bump] table still yields a working
config (defaults plus the derived repository URL). Exposed for testing.
pub fn parse_json_config(
json_string: String,
) -> Result(Config, error.ReleaseError)
Parse a JSON configuration document, merging any recognised keys over the defaults. Unknown keys are ignored. Exposed for testing.
pub fn parse_package_json_config(
json_string: String,
) -> Result(Config, error.ReleaseError)
Parse the "release" object out of a package.json document. If there is
no "release" key the project simply has no semantic-release config there,
so the defaults are returned.
pub fn parse_toml_config(
toml_string: String,
) -> Result(Config, error.ReleaseError)
Parse a TOML configuration document, merging recognised keys over the defaults. Exposed for testing.