Quick Glance @ Elixir 1.9 Releases feature

Blackode
Blackode
Jun 26, 2019 · 4 min read

New mix task for Elixir releases

Image for post
Image for post
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:

Image for post
Image for post

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
Image for post
Image for post
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 
Image for post
Image for post

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

Image for post
Image for post
file: mix.exs

Now run the task without specifying the release name.

MIX_ENV=prod mix release
Image for post
Image for post

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

Image for post
Image for post

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

Image for post
Image for post

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.

Image for post
Image for post

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

Image for post
Image for post

Now run both releases and see the difference.

Image for post
Image for post

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

Image for post
Image for post

Glad if you can contribute with a ★

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch

Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore

Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store