Fl4m3Ph03n1x

Fl4m3Ph03n1x

How to name the generated tarball from an Elixir release?

Background

I am making an elixir release in tarball format:

 defp releases,
    do: [
      my_app: [
        applications: [
          web_interface: :permanent,
          runtime_tools: :permanent
        ],
        steps: [:assemble, :tar],
        include_executables_for: [:windows]
      ]
    ]

The release file has all necessary files, but the name generated is $release_name-$version, meaning it will be something like: my_app-2.1.5.

Problem

This means that every time I release, I need to change shortcuts and other files to have the correct name of the tarball.

Question

Is there a way to give a name to the tarball created that wont change with every release?

Marked As Solved

wojtekmach

wojtekmach

Hex Core Team

Yeah I meant file rename. :slight_smile: glad it helped!

Also Liked

wojtekmach

wojtekmach

Hex Core Team

If there’s no built-in way to customise the path note you can always add a custom release step. You can grab name and version from the given %Mix.Release{} struct.

- steps: [:assemble, :tar],
+ steps: [:assemble, :tar, &rename_tar/1],

# ...

defp rename_tar(release) do
  # ...
  release
end
Fl4m3Ph03n1x

Fl4m3Ph03n1x

For future reference, this is what I ended up with:

  defp releases,
    do: [
      market_manager: [
        applications: [
          web_interface: :permanent,
          runtime_tools: :permanent
        ],
        steps: [:assemble, :tar, &rename_tar/1],
        include_executables_for: [:windows]
      ]
    ]

  defp rename_tar(release) do
    tar_folder_path =
      release.path
      |> Path.join("../../")
      |> Path.expand()

    tar_path = Path.join(tar_folder_path, "#{release.name}-#{release.version}.tar.gz")
    new_tar_path = Path.join(tar_folder_path, "application-data.tar.gz")

    case File.rename(tar_path, new_tar_path) do
      :ok -> release
      err -> err
    end
  end

It works like a charm :smiley:

Where Next?

Popular in Questions Top

aalberti333
As the title describes, I’m trying to run Enum.map() over a list of key/value pairs, where the value is a map. My data looks like this: ...
New
romenigld
I am trying to run a deploy with docker and I successfully runned with this command: docker build -t romenigld/blog-prod . but when I t...
New
Jim
As a follow up to my earlier question: I have the code compiling and running but not getting a successful login from the rest server. ...
New
Phillipp
Hey, I have a NanoPi-M3 and try to install Elixir on their Ubuntu image. I followed the Raspberry Pi installation instructions from the ...
New
qwerescape
Is there a way to get the call stack or stack trace at any point in the code? Not from exceptions, but an expression that returns how the...
New
fayddelight
I tried installing elixir 1.11.2 erlang 23.3.4 via asdf in my zsh shell. Enabled the versions locally and globally. When I list them ...
New
Exadra37
Sometimes I want to check if the input into a function is not a blank string. My first approach: defmodule Example do def do_stuff(s...
New
beno
I will often find my self writing things similar to: case some_value do nil -> something() "" -> something() _ -> someth...
New
wernerlaude
In AR this is so simple @articles = current_user.articles How to do in Ecto? def index(conn, _params) do current_user = conn.assig...
New
jc00ke
Expanding on this topic: https://forum.elixirforum.net/t/map-typespec-question/19217 Let’s say I have a map with required and optional k...
New

Other popular topics Top

Harrisonl
We have an ECS cluster with 4 services, where each task joins a single cluster, via discovery ECS discovery service. Currently when I de...
New
Patoshizzle
After calling mix ecto.create I get this error: 17:00:32.162 [error] GenServer #PID<0.412.0> terminating ** (Postgrex.Error) FATAL...
New
lessless
I believe there are people here who are dealing with CSV files import on the daily basis, and since Excel is a really popular tool there ...
New
albydarned
Hello all! I am typing this post from my new MacBook Pro with the M1 chip. I’m loving it so far, and will probably use it as my daily dr...
New
hariharasudhan94
I would like to know what is the best IDE for elixir development?
New
quazar
How to set Jason to encode all fields in ecto schema, I don’t care about security and implementing only is taking long list of attributes...
New
chrismccord
This release brings a number of exciting features, including integration with the new Phoenix LiveDashboard and Phoenix LiveView. There h...
New
vac
Hi, I'm quite new in Elixir and I'm trying to format a string to a PEM format. I have the certificate value like MIIDBTCCAe2...... and ...
New
WestKeys
Currently suffering from paralysis by [HTTP client] analysis. This is rather unusual in Elixirland as there tends to be consensus on the ...
New
Qqwy
Original source of discussion: This topic on the Pragmatic Programmers' Functional Web Development with Elixir, OTP, and Phoenix forum. ...
New

We're in Beta

About us Mission Statement