A script to help when releasing new versions for packages

Releasing new versions for a package is a chore. You have to run the tests, add a tag to your repo, publish on hex, etc. This is something we should automate. Inspired by this article here: https://hypothesis.works/articles/continuous-releases/, I’ve written a script to make it much easier. You can find it here: https://gist.github.com/tmbb/24ed381aa60abd5514072f44eaa91eaf#file-release-exs

Unlike the example from the Hypothesis project above, this isn’t triggered by a commit to the master branch. This is just a script you can add to your project. If you add this script as an alias (for example, release) to your mix file, and follow some simple conventions, you can generate a release with mix release.

This will:

  1. Run your tests (and interrupt is they fail).

  2. Read a special RELEASE.md file which you have to create and contains a line which specifies which type of release it is (patch, minor or major), as well as the text for the changelog entry

  3. Bump the current version and set it in your mix.exs file (it assumes you have a line of the form @version "x.x.x")

  4. Commit the changes to git and add a tag with the version number so that it is easy to track in the repo

  5. Publish the package on hex

For more details, just read the script. This script is something you’ll want to customize to your workflow, so I won’t package this in any way, Just dump this script somewhere in your mix project, set the alias and you’re good to go.

5 Likes