# `Mix.Release`
[🔗](https://github.com/elixir-lang/elixir/blob/7ff272706afc522e74121493b7166719985cb099/lib/mix/lib/mix/release.ex#L5)

Defines the release structure and convenience for assembling releases.

# `application`

```elixir
@type application() :: atom()
```

# `mode`

```elixir
@type mode() :: :permanent | :transient | :temporary | :load | :none
```

# `strip_beam_opts`

```elixir
@type strip_beam_opts() :: [keep: [String.t()], compress: boolean()]
```

Options for stripping BEAM files.

# `sys_config`

```elixir
@type sys_config() :: [{application(), keyword()}]
```

Erlang/OTP sys.config structure.

A list of tuples where each tuple contains an application name and its
configuration as a keyword list. This is the standard format for Erlang
application configuration.

# `t`

```elixir
@type t() :: %Mix.Release{
  applications: %{required(application()) =&gt; keyword()},
  boot_scripts: %{required(atom()) =&gt; [{application(), mode()}]},
  config_providers: [{module(), term()}],
  erts_source: charlist() | nil,
  erts_version: charlist(),
  name: atom(),
  options: keyword(),
  overlays: [String.t()],
  path: String.t(),
  steps: [(t() -&gt; t()) | :assemble, ...],
  version: String.t(),
  version_path: String.t()
}
```

# `__struct__`
*struct* 

The Mix.Release struct has the following read-only fields:

  * `:name` - the name of the release as an atom
  * `:version` - the version of the release as a string
  * `:path` - the path to the release root
  * `:version_path` - the path to the release version inside the release
  * `:applications` - a map of application with their definitions
  * `:erts_source` - the ERTS source as a charlist (or nil)
  * `:erts_version` - the ERTS version as a charlist

The following fields may be modified as long as they keep their defined types:

  * `:boot_scripts` - a map of boot scripts with the boot script name
    as key and a keyword list with **all** applications that are part of
    it and their modes as value
  * `:config_providers` - a list of `{config_provider, term}` tuples where the
    first element is a module that implements the `Config.Provider` behaviour
    and `term` is the value given to it on `c:Config.Provider.init/1`
  * `:options` - a keyword list with all other user supplied release options
  * `:overlays` - a list of extra files added to the release. If you have a custom
    step adding extra files to a release, you can add these files to the `:overlays`
    field so they are also considered on further commands, such as tar/zip. Each entry
    in overlays is the relative path to the release root of each file
  * `:steps` - a list of functions that receive the release and returns a release.
    Must also contain the atom `:assemble` which is the internal assembling step.
    May also contain the atom `:tar` to create a tarball of the release.

# `copy_app`

```elixir
@spec copy_app(t(), application()) :: boolean()
```

Copies the given application specification into the release.

It assumes the application exists in the release.

# `copy_ebin`

```elixir
@spec copy_ebin(t(), Path.t(), Path.t()) :: boolean()
```

Copies the ebin directory at `source` to `target`
respecting release options such a `:strip_beams`.

# `copy_erts`

```elixir
@spec copy_erts(t()) :: boolean()
```

Copies ERTS if the release is configured to do so.

Returns `true` if the release was copied, `false` otherwise.

# `make_boot_script`

```elixir
@spec make_boot_script(t(), Path.t(), [{application(), mode()}], [String.t()]) ::
  :ok | {:error, String.t()}
```

Makes boot scripts.

It receives a path to the boot file, without extension, such as
`releases/0.1.0/start` and this command will write `start.rel`,
`start.boot`, and `start.script` to the given path, returning
`{:ok, rel_path}` or `{:error, message}`.

The boot script uses the RELEASE_LIB environment variable, which must
be accordingly set with `--boot-var` and point to the release lib dir.

# `make_cookie`

```elixir
@spec make_cookie(t(), Path.t()) :: :ok
```

Copies the cookie to the given path.

If a cookie option was given, we compare it with
the contents of the file (if any), and ask the user
if they want to override.

If there is no option, we generate a random one
the first time.

# `make_start_erl`

```elixir
@spec make_start_erl(t(), Path.t()) :: :ok
```

Makes the start_erl.data file with the
ERTS version and release versions.

# `make_sys_config`

```elixir
@spec make_sys_config(t(), sys_config(), Config.Provider.config_path()) ::
  :ok | {:error, String.t()}
```

Makes the `sys.config` structure.

If there are config providers, then a value is injected into
the `:elixir` application configuration in `sys_config` to be
read during boot and trigger the providers.

It uses the following release options to customize its behavior:

  * `:reboot_system_after_config`
  * `:start_distribution_during_config`
  * `:prune_runtime_sys_config_after_boot`

In case there are no config providers, it doesn't change `sys_config`.

# `rel_templates_path`

```elixir
@spec rel_templates_path(t(), Path.t()) :: binary()
```

Finds a template path for the release.

# `strip_beam`

```elixir
@spec strip_beam(binary(), strip_beam_opts()) ::
  {:ok, binary()} | {:error, :beam_lib, term()}
```

Strips a beam file for a release.

This keeps only significant chunks necessary for the VM operation,
discarding documentation, debug info, compile information and others.

The exact chunks that are kept are not documented and may change in
future versions.

## Options

  * `:keep` - a list of additional chunk names (as strings) to keep in the
    stripped BEAM file beyond those required by Erlang/Elixir

  * `:compress` - when `true`, the resulting BEAM file will be compressed
    using gzip. Defaults to `false`

## Examples

    # Strip with default options
    Mix.Release.strip_beam(beam_binary)

    # Keep additional chunks and compress
    Mix.Release.strip_beam(beam_binary, keep: ["Docs", "ChunkName"], compress: true)

---

*Consult [api-reference.md](api-reference.md) for complete listing*
