rebar3でhexにライブラリを公開する
rebar3はhexに登録されたライブラリを使用したり, hexにpublishすることができます.
導入
hexのトップページにも書かれていますが, 以下の記載を追加ないしはファイルを作成します.
{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 [email protected]
メールが届くので, 記載のリンクに飛ぶと登録が完了する.
ライブラリを公開する
ライブラリを公開する為にはいくつかの修正を加える必要があるかもしれません.
{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
を追加した.
vsn
はhex
のバージョン規則に則って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の方が便利なので中々捨てがたいのです...)