Debuginfo

思考とアウトプット

Millaで呼吸をするようにgithubでperl モジュールを開発しcpanにアップする

Module::Setupを使ってモジュール書くぞ、と思ってた矢先に CPAN モジュールの開発についての最近の風潮という@tokuhirom氏のブログのエントリを読みました^^;;

minillaでもよかったのですが、全体像がわからなかったので今回は@miyagawaさんの秀逸なscreencastを参考にmillaを使ってみることにしました。

基本的にscreencastそのままやればいいのです。

依存関係が沢山あって時間がかかるのでscreencastを見てる裏でcpanm Dist::Millaを走らせましょう

$ cpanm Dist::Milla 

githubにpushするためにApp::phを使います。(Rubyistの人はhubも使えるようです。)

$ cpanm App::ph

phはssh keyを利用してpushします。RSA keyを登録していない人はhttps://help.github.com/articles/generating-ssh-keysを参考に登録しておきましょう。

次にmilla setupで基本情報を入力。

$ milla setup
What's your name? YOUR_NAME
What's your email address? YOUR_EMAIL
Who, by default, holds the copyright on your code?  [YOUR_NAME]: 
What license will you use by default (Perl_5, BSD, etc.)?  [Perl_5]: 
Do you want to enter your PAUSE account details?  [y/N]: y
What is your PAUSE id?  [SHOHEIK]: shoheik
What is your PAUSE password? xxxxx

milla new YOUR::MODULEでテンプレートディレクトリを作成する。今回は作ろうとしてるモジュールのGraph::D3を指定。

$ milla new Graph::D3
[DZ] making target dir /Users/kamesho/Dropbox/git/Graph-D3
[DZ] writing files to /Users/kamesho/Dropbox/git/Graph-D3
[Git::Init] Initializing a new git repository in /Users/kamesho/Dropbox/git/Graph-D3
[Milla::FirstBuild] Running the initial build & clean
fatal: bad default revision 'HEAD'
[@Milla/NameFromDirectory] guessing your distribution name is Graph-D3
[DZ] beginning to build Graph-D3
[DZ] guessing dist's main_module is lib/Graph/D3.pm
[@Milla/LicenseFromModule] guessing from lib/Graph/D3.pm, License is Software::License::Perl_5
[@Milla/LicenseFromModule] Copyright 2013- Shohei Kameda <shoheik@cpan.org>
[@Milla/VersionFromModule] dist version 0.01 (from lib/Graph/D3.pm)
[@Milla/ExtraTests] rewriting release test xt/release/pod-syntax.t
[@Milla/Prereqs::FromCPANfile] Parsing 'cpanfile' to extract prereqs
[DZ] extracting distribution abstract from lib/Graph/D3.pm  
[@Milla/GithubMeta] A remote named 'origin' was specified, but does not appear to exist.
[@Milla/GithubMeta] skipping meta.resources.repository creation
[DZ] writing Graph-D3 in Graph-D3-0.01
[@Milla/CopyFilesFromBuild] Copied Graph-D3-0.01/META.json to ./META.json
[@Milla/CopyFilesFromBuild] Copied Graph-D3-0.01/Build.PL to ./Build.PL
[@Milla/NameFromDirectory] guessing your distribution name is Graph-D3
[DZ] clean: removing Graph-D3-0.01
[DZ] dist minted in ./Graph-D3

そうすると、下記のようなファイルがModule名のディレクトリに作成されます。

> tree Graph-D3
Graph-D3
├── Build.PL
├── Changes
├── META.json
├── README.md
├── cpanfile
├── dist.ini
├── lib
│   └── Graph
│       └── D3.pm
└── t
    └── basic.t

ここでgit statusするとcommit前のファイルが見れます。まずinitilal releaseをコミットする。

$ git status  # you would see the list of the new files
$ git commit -m ‘initial import via Milla’

phコマンドでremoteレポジトリを作ります。(自動的にファイルがpushされます)

$ ph import
user: shoheik
pass: ********
Can I import /Users/kamesho/Dropbox/git/Graph-D3 to Graph-D3 in github? [y/N] y

ここでガシガシ開発して.pm/.tを書きます。

$ git add .
$ git commit -m ‘added D3.pm and updated the test’

そしてリリース! “Do you want to continue the release process”でYを指定するとgitとcpanにアップロードされます。

$ milla release
....
Do you want to continue the release process? [Y/n]: Y
[@Milla/UploadToCPAN] registering upload with PAUSE web server
[@Milla/UploadToCPAN] POSTing upload for Graph-D3-0.01.tar.gz to https://   pause.perl.org/pause/authenquery
[@Milla/UploadToCPAN] PAUSE add message sent ok [200]
[@Milla/CopyFilesFromRelease] Copied Graph-D3-0.01/lib/Graph/D3.pm to lib/Graph/D3.pm
[@Milla/Git::Commit] Committed Build.PL Changes META.json README.md
[@Milla/Git::Tag] Tagged 0.01
[@Milla/Git::Push] pushing to origin

FAKE_RELEASEのフラグを立てるとgitのみにプッシュされcpanにはアップロードされなくなります。

$ FAKE_RELEASE=1 milla release # only updates to git

milla cleanでできたファイルを消去。

$ milla clean
[DZ] clean: removing .build
[DZ] clean: removing Graph-D3-0.01
[DZ] clean: removing Graph-D3-0.01.tar.gz

次に変更を加えてmilla releaseするとChangelogがアップデートされてないといわれます。

$ vim lib/Graph/D3.pm # edit some
$ git add . ; git commit -m ‘minor change on doc’
$ milla release 
...
[@Milla/CheckChangesHasContent] Checking Changes
[@Milla/CheckChangesHasContent] Changes has no content for 0.02
...

なので{{$NEXT}}の次の行に8スペースをあけてChangeを書きます。

{{$NEXT}}
        - Update doc to see more neet&tidy.

でreleaseをpush.

$ FAKE_RELEASE=1 milla release 

簡単ですね。簡単すぎますね。本当に呼吸をするようにモジュールがかけそうです。Milla Rocks!!