LoginSignup
8
8

More than 5 years have passed since last update.

rebar3でhexにライブラリを公開する

Posted at

rebar3でhexにライブラリを公開する

rebar3はhexに登録されたライブラリを使用したり, hexにpublishすることができます.

導入

hexのトップページにも書かれていますが, 以下の記載を追加ないしはファイルを作成します.

~/.config/rebar3/rebar.config
{plugins, [rebar3_hex]}.

その後, 以下のコマンドを実行し, hex pluginが使えるようになったことを確認しましょう.

$ rebar3 plugins list
===> Fetching jsx ({pkg,<<"jsx">>,<<"2.6.1">>})
===> Fetching ssl_verify_hostname ({pkg,<<"ssl_verify_hostname">>,
                                           <<"1.0.5">>})
===> Fetching rebar3_hex ({pkg,<<"rebar3_hex">>,<<"0.8.0">>})
===> Compiling ssl_verify_hostname
===> Compiling jsx
===> Compiling rebar3_hex
--- Global plugins ---
rebar3_hex

これで, hex pluginが利用できるようになりました.

ユーザー登録をする

ライブラリを公開する為には, まずユーザー登録をする必要がある.
既にmixでhexを利用していて, ユーザー登録を済ませている場合は同じconfigファイルを参照する為, 登録は不要になる.

## user確認
$ rebar3 hex user whoami

## user登録
$ rebar3 hex user register
Username: ([])> 
Email: ([])> 
Password:
Password (confirm):
Registering...
Generating API key...
You are required to confirm your email to access your account, a confirmation email has been sent to XXXXX@XXX.XXX

メールが届くので, 記載のリンクに飛ぶと登録が完了する.

ライブラリを公開する

ライブラリを公開する為にはいくつかの修正を加える必要があるかもしれません.

src/bbmustache.app.src
{application,bbmustache,
             [{description,"Binary pattern match Based Mustache template engine for Erlang/OTP"},
              {vsn,"1.0.3"},
              {registered,[]},
              {applications,[kernel,stdlib]},
              {contributors,["Hinagiku Soranoba"]},
              {licenses,["MIT"]},
              {links,[{"GitHub","https://github.com/soranoba/bbmustache"}]},
              {env,[]}]}.

これは bbmustache のapp.srcだが, vsnを変更し, contributors, licenses, linksを追加した.
vsnhexのバージョン規則に則ってmajour.minor.patchでバージョンを記載する必要がある.
また, application名が既に使われてしまっている場合は変更する必要がある.

以上の準備ができたら, 公開をしよう.

$ rebar3 hex publish
Publishing bbmustache 1.0.0
  Dependencies:

  Excluded dependencies (not part of the Hex package):

  Included files:
    src/bbmustache.app.src
    src/bbmustache.erl
    rebar.config
    rebar.lock
    README.md
    LICENSE
Proceed? ("Y")>

更新は以下のコマンドを使用すると良い

$ rebar3 hex cut
Select semver increment or other (Current 1.0.0):
1) patch
2) minor
3) major
4) other
[1-4] > 1
Publishing bbmustache 1.0.1
  Dependencies:

  Excluded dependencies (not part of the Hex package):

  Included files:
    src/bbmustache.app.src
    src/bbmustache.erl
    rebar.config
    rebar.lock
    README.md
    LICENSE
Proceed? ("Y")> 

このコマンドを実行した後で, .app.srcが更新されるのgit commitはその後で実行するようにすると良いだろう.
また, 表示されるバージョンがおかしい場合は rebar3 updateを実行すると直るはずです.

最後に

他のコマンドについては rebar3のドキュメント に記載があるので, 「publishの権限を他の人に与えたい」時など, より詳しいことについてはこちらを参照して欲しい.

従来のURLを指定するやり方でも困ることはないかと思いますが, 折角なのでhexに公開していきましょうw


余談ですが, ドキュメントもpublishできますがdoc/index.htmlをpublishするようでedownだとREADME.mdで何か良い方法を知っている方がいましたら, 是非ご教授ください.
(githubのドキュメントとしてはmarkdownの方が便利なので中々捨てがたいのです...)

8
8
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
8
8