Hex.pm Hexdocs.pm Github.com

Expublish

Automate SemVer and best practices for elixir package releases.

Installation

Add :expublish to your dev dependencies in mix.exs:

{:expublish, "~> 2.2", only: [:dev]}

Create a CHANGELOG.md in the root folder of your project. It must contain a placeholder:

<!-- %% CHANGELOG_ENTRIES %% -->

Do not keep track of the release file. Put the following line in your .gitignore:

RELEASE.md

The file is deleted after every successful release.

Usage

1. Create a new RELEASE.md containing the new changelog entry:

$ echo "- changelog entry one\n- changelog entry two" > RELEASE.md

2. Run one of mix expublish.(major|minor|patch):

$ mix expublish.minor

About

Using mix expublish guarantees:

  • A clean git working directory
  • Passing tests
  • Increased version in mix.exs
  • A new changelog entry
  • A new version git commit and tag

Expublish was built with a CI integrated continuous release process in mind. The mix task makes certain assumptions and automatically pushes and publishes the new package version to git and hex respectively.

This and other behavior can be changed using various options. Here are the commonly used ones:

# Go through all the task steps without any writing changes (no commit, no tag, no push, no publish):
$ mix expublish.minor --dry-run

# Do not push the new version commit and tag to git and do not publish the new package on hex:
$ mix expublish.minor --disable-push --disable-publish

# Skip the test run:
$ mix expublish.minor --disable-test

# Ignore untracked files in git check before creating a new release:
$ mix expublish.minor --allow-untracked

# Push the git commit to a different branch and/or remote:
$ mix expublish.minor --branch=release --remote=upstream

# Provide custom commit- or tag-prefixes:
$ mix expublish.minor --tag-prefix=rc --commit-prefix="Version bump"

Reference

The mix task is defined as:

mix expublish.[level] [options]

Level

LevelDescription
majorWhen making incompatible API changes.
minorWhen adding functionality in a backwards compatible manner.
patchWhen making backwards compatible bug fixes.

Options

OptionDefaultDescription
-h, --helpfalsePrint help.
-d, --dry-runfalsePerform dry run (no writes, no commits).
--allow-untrackedfalseSkip untracked files when checking git porcelain.
--disable-testfalseDisable test run.
--disable-publishfalseDisable hex publish.
--disable-pushfalseDisable git push.
--branch=string"master"Remote branch for git push.
--remote=string"origin"Remote name for git push.
--commit-prefix=string"Version release"Prefix for commit message.
--tag-prefix=string"v"Prefix for release tag.

Apart from the mix task, Expublish exposes a public interface which can be used to create new releases from other elixir applications or scripts.