version_bump/branch

The branching / channel model (MVP).

semantic-release resolves the configured branches against the branches that actually exist in the repository, classifying each into one of three kinds:

This module is pure: it never shells out to git. The caller passes in the list of branch names discovered in the repository (git_branches) and the list of tags (tags); everything here is string / semver manipulation.

Types

A resolved release branch (after merging config with discovered git branches).

pub type Branch {
  Branch(
    name: String,
    type_: BranchType,
    channel: option.Option(String),
    prerelease: option.Option(String),
    range: option.Option(String),
    main: Bool,
  )
}

Constructors

How a branch participates in the release flow.

pub type BranchType {
  ReleaseBranch
  MaintenanceBranch
  PrereleaseBranch
}

Constructors

  • ReleaseBranch
  • MaintenanceBranch
  • PrereleaseBranch

Values

pub fn last_release(
  tags: List(String),
  branch: Branch,
  tag_format: String,
) -> option.Option(release.LastRelease)

Pick the highest existing release on branch from a list of git tags.

Tags are matched against tag_format (e.g. "v${version}"); the embedded version is parsed as semver. Only versions compatible with the branch are considered:

  • PrereleaseBranch — only versions whose first prerelease identifier is the branch’s prerelease id (e.g. 1.0.0-beta.2 on the beta branch).
  • MaintenanceBranch — only non-prerelease versions inside the branch’s range (e.g. 1.x admits 1.*.*, 1.2.x admits 1.2.*).
  • ReleaseBranch — only non-prerelease versions.

Returns the highest matching version as a LastRelease, or None when no tag matches.

pub fn next_version(
  last: option.Option(release.LastRelease),
  rtype: semver.ReleaseType,
  branch: Branch,
  mode: semver.VersioningMode,
) -> Result(String, error.ReleaseError)

Compute the next version string for branch, given the last release and the ReleaseType the commits warrant.

With no previous release the first version is 1.0.0 (or 0.1.0 in InitialDevelopment mode), with the branch’s prerelease identifier appended on a prerelease branch. Otherwise the last version is bumped by rtype — in InitialDevelopment mode a breaking change is downshifted to a minor bump while major is 0 (see semver.effective_release_type).

pub fn resolve(
  config: config.Config,
  git_branches: List(String),
  current: String,
) -> Result(#(Branch, List(Branch)), error.ReleaseError)

Resolve the configured branches against the branches that exist in the repository, returning the resolved current branch together with every resolved branch.

Each BranchConfig whose name appears in git_branches is classified into a Branch. Configured branches that do not exist in the repository are dropped (they cannot be released against). The current branch must be one of the resolved branches, otherwise a ConfigError is returned.

Search Document