Hex v0.19.0 mix hex.publish View Source

Publishes a new version of your package and its documentation.

mix hex.publish package

If it is a new package being published it will be created and the user specified in username will be the package owner. Only package owners can publish.

A published version can be amended or reverted with --revert up to one hour after its publication. Older packages can not be reverted.

mix hex.publish docs

The documentation will be accessible at https://hexdocs.pm/my_package/1.0.0, https://hexdocs.pm/my_package will always redirect to the latest published version.

Documentation will be generated by running the mix docs task. ex_doc provides this task by default, but any library can be used. Or an alias can be used to extend the documentation generation. The expected result of the task is the generated documentation located in the doc/ directory with an index.html file.

Note that if you want to publish a new version of your package and its documentation in one step, you can use the following shorthand:

mix hex.publish

Command line options

  • --revert VERSION - Revert given version, if the last version is reverted the package is removed
  • --organization ORGANIZATION - The organization the package belongs to
  • --yes - Publishes the package without any confirmation prompts
  • --dry-run - Builds package and performs local checks without publishing, use mix hex.build --unpack to inspect package contents before publishing


  • :app - Package name (required).
  • :version - Package version (required).
  • :deps - List of package dependencies (see Dependencies below).
  • :description - Short description of the project.
  • :package - Hex specific configuration (see Package configuration below).


Dependencies are defined in mix's dependency format. But instead of using :git or :path as the SCM :package is used.

defp deps() do
    {:ecto, "~> 0.1.0"},
    {:postgrex, "~> 0.3.0"},
    {:cowboy, github: "extend/cowboy"}

As can be seen Hex package dependencies works alongside git dependencies. Important to note is that non-Hex dependencies will not be used during dependency resolution and neither will they be listed as dependencies of the package.

Package configuration

Additional metadata of the package can optionally be defined, but it is very recommended to do so.

  • :name - Set this if the package name is not the same as the application name.
  • :organization - Set this if you are publishing to an organization instead of the default public hex.pm.
  • :files - List of files and directories to include in the package, can include wildcards. Defaults to ["lib", "priv", "mix.exs", "README*", "readme*", "LICENSE*", "license*", "CHANGELOG*", "changelog*", "src"].
  • :licenses - List of licenses used by the package.
  • :links - Map of links relevant to the package.
  • :build_tools - List of build tools that can build the package. Hex will try to automatically detect the build tools, it will do this based on the files in the package. If a "rebar" or "rebar.config" file is present Hex will mark it as able to build with rebar. This detection can be overridden by setting this field.