Hex v0.20.0 mix hex.publish View Source

Publishes a new version of the package.

mix hex.publish

The current authenticated user will be the package owner. Only package owners can publish the package, new owners can be added with the mix hex.owner task.

Packages and documentation sizes are limited to 8mb compressed, and 64mb uncompressed.

Publishing documentation

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.

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 built and published automatically. To publish a package without documentation run mix hex.publish package or to only publish documentation run mix hex.publish docs.

Reverting a package

A new package can be reverted or updated within 24 hours of it's initial publish, a new version of an existing package can be reverted or updated within one hour. Documentation have limitations on when it can be updated

To update the package simply run the mix hex.publish task again. To revert run mix hex.publish --revert VERSION or to only revert the documentaiton run mix hex.publish docs --revert VERSION.

Command line options

  • --revert VERSION - Revert given version, if the last version is reverted the package is removed
  • --organization ORGANIZATION - Set this for private packages belonging to an organization
  • --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

Configuration

  • :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

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"}
  ]
end

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.