Elixir Releases @ Elixir 1.9 mix release

Malreddy Ankanna
4 min readJun 26, 2019

--

New mix task for Elixir releases

Created Using Canva.com

This article is all about showing the live demo of Elixir Releases, a brand new mix task mix release .

Mix Task Commands

MIX_ENV=prod mix release
MIX_ENV=prod mix release release_name

The above commands will generate a self-contained releases.

What is self-contained?

  1. No Source Code is required
  2. Not require Erlang or Elixir.
  3. Loads only required Elixir and Erlang Libraries instead all
  4. Includes Erlang VM(Virtual Machine)

Live Demo

Project Creation

Let’s create a new mix project hello for demonstration.

mix new hello

Basic Release Configuration

A release can be configured in our mix.exs file under the :releases key inside def project:

To keep it tidy, I created a new private function releases .

How to run a release?

You just need to specify the release name. Here demo is our new release name.

The above configuration is enough to release our hello application for demo purpose.

MIX_ENV=prod mix release demo
release screenshot

Do we need to always specify release name ?

NO NEED TO SPECIFY EVERY-TIME

Let’s give a try.

MIX_ENV=prod mix release 

Still works ‼️

As we are having only one configuration for release.

What happens if there are more than one (1) configurations ?

❌ ❌

IT RAISE AN ERROR

Let’s check it.

I just updated the releases function by adding another configuration demo2. Check the following screenshot

file: mix.exs

Now run the task without specifying the release name.

MIX_ENV=prod mix release

1.9.0 Release BUG 🐞

Specifying Default Release option :default_release

Though they mentioned to set :default_release option in our project root configuration, there is a bug in the recent release where the default setting was never read . Hope to get it fixed in the coming release.

Can we change the default release directory?

OF COURSE WE CAN CHANGE

Just add

path: "your path"

option to the release configuration like in the following screenshot

Now run the release MIX_ENV=prod mix release demo. All the releases will move to my_releases folder in the project.

You can see a lot of information logs to the console while you run the release. Though it is informative, sometimes it looks weird.

We can provide the

quiet: true

option to simply run the release with out any verbose.

Check out the following screenshot for adding the option.

I purposely added two configurations, with and without quiet: true option like below

Now run both releases and see the difference.

The left side is with quiet: true and right side without quiet option.

There are lot things to read about releases for better usage.

This is just a glance of releases in Elixir 1.9.0. For Better understanding and in depth reading check →Elixir mix release.

Hope you liked it.

Thanks for reading.

Join Our Telegram Channel and support us.

Check out the GitHub repository on Killer Elixir Tips

Glad if you can contribute with a ★

--

--

Malreddy Ankanna
Malreddy Ankanna

Written by Malreddy Ankanna

Programmer & Writer, I write about coding, thoughts, ideas, personal musings, technical articles, and tutorials.https://bio.link/blackode

No responses yet