XUtils

rebar3_hex

Hex.pm plugin for rebar3.


Setup

Add to your global rebar3 config in ~/.config/rebar3/rebar.config:

{plugins, [rebar3_hex]}.

Alternatively, you can add to your project’s rebar3 config in project plugins :

{project_plugins, [rebar3_hex]}.

NOTE : Be sure not to add rebar3_hex to the plugins section within a projects rebar3 config as this will become a dependency for others downloading your package from hex.pm

Authenticating User

If you already have a user for hex.pm run:

$ rebar3 hex user auth

Note that this will ask for your hex.pm username and password, as well as a password for encrypting your api token that has write permissions to the repository. When publishing a package you will have to give this password to decrypt the token in order to publish.

See the docs for more information.

Building

The build provider is very useful for seeing exactly what would be published using either the publish or cut task without any chance of actually publishing the package or docs. Tarballs for the package and docs are written to _build/<profile>/lib/your_app/hex/ by default.

$ rebar3 hex build

See the docs for more information.

Publishing

Two providers are available for publishing packages, publish and cut

By default publish builds and pushes your package and docs to a repository. See the docs for more information.

$ rebar3 hex publish

cut is available to provide some additional functionality around versioning and git tags. See the docs for more information.

$ rebar3 hex cut

In either case, both providers will display the details of what is being published (what files, the version, dependencies) and ask if it should continue, so be sure to read the output carefully and make sure it is publishing what you expected.

Managing package owners

Owners can be added, removed, and listed for packages you are an owner of with the hex owner command. Packages can also be transfered to other registered users on hexpm as well.

$ rebar3 hex owner [add | remove | list | transfer] <package> <email>

See the docs for more information.

Retiring packages

Packages can be flagged as retired on hexpm via the retire provider :

$ rebar3 hex retire PACKAGE VERSION REASON --message

They can also be unretired in case a mistake was made :

$ rebar3 hex retire PACKAGE VERSION --unretire

See the docs for more information.

Read-Only Repo Key for CI

If you have a private organization or other private repository it is recommended that you use a repo specific auth token for reading from the repository in CI. To generate a token:

$ rebar3 hex organization auth hexpm:myrepo
Successfully authenticated to hexpm:myrepo

Now you can generate a key to use in CI for your organization

$ rebar3 hex organization key hexpm:myrepo generate
abc123

Then in CI use whatever method is available for setting an environment variable to the token and add this call at the beginning of your CI runs to add the token to your rebar3 hex config. Below we’ll use the environment REPO_KEY as an example.

$ rebar3 hex organization auth hexpm:myrepo --key $REPO_KEY

Searching hexpm

A search provider is available to search packages across hex.pm as a convenience.

$ rebar3 hex search

Articles

  • coming soon...