Centos6でgemパッケージを作ってrubygems.orgで公開してみた
ちょっとRubyスクリプトを共有したくて、gemパッケージの作り方を調べたのでメモ。
# git --version ←バージョン確認# yum erase git# yum update perl# yum install subversion-perl# yum install perl-YAML# wget http://pkgs.repoforge.org/git/perl-Git-1.7.11.3-1.el6.rfx.x86_64.rpm# wget http://pkgs.repoforge.org/git/git-1.7.11.3-1.el6.rfx.x86_64.rpm# rpm -Uvh perl-Git-1.7.11.3-1.el6.rfx.x86_64.rpm git-1.7.11.3-1.el6.rfx.x86_64.rpm
$ gem install bundler ← Redmine(Rails)の環境を作る時に入れてあった
$ bundle gem yggdrasil ← yggdrasilディレクトリが出来て雛形が作られる
$ cd yggdrasil$ vi yggdrasil.gemspec ← TODOが書かれている箇所等適当に変更
$ vi lib/yggdrasil/version.rb ← リリースする前にバージョンを変える
$ midir bin
$ vi bin/yggdrasil ← 実行コマンドを作るときはbinの下にコマンドを作る
$ cat bin/yggdrasil ← まずはHello Worldでお試し
#!/usr/bin/env ruby
puts 'Hello World!'
$ git add .
$ git commit -a -m 'initial commit' ← コミットしないとパッケージに含められないみたい
$ rake build ← これでpkg/yggdrasil-0.0.0.gem が作られる
# gem install ~/yggdrasil/pkg/yggdrasil-0.0.0.gem ← gemインストールの動作確認
# yggdrasil ← インストールされたコマンドの動作確認
Hello World!
● githubでのコード管理# gem uninstall yggdrasil ← 消しておく
$ git remote add origin https://github.com/tkusukawa/yggdrasil.git ← 作ったリポを指定
$ git push -u origin master ← ここでgithubのID/PWを聞かれます
$ rake release ← githubのID/PWの後、下記のように失敗するyggdrasil 0.0.0 built to pkg/yggdrasil-0.0.0.gemTagged v0.0.0Username for 'https://github.com': tkusukawaPassword for 'https://tkusukawa@github.com':Username for 'https://github.com': tkusukawaPassword for 'https://tkusukawa@github.com':Pushed git commits and tagsUntagged v0.0.0 due to errorrake aborted!Your rubygems.org credentials aren't set. Run `gem push` to set them.Tasks: TOP => release(See full trace by running task with --trace)$ gem push ← エラーに従ってやってみるが、これもエラーになるEnter your RubyGems.org credentials.Don't have an account yet? Create one at http://rubygems.org/sign_upEmail: t.kusukawa@gmail.comPassword:Pushing gem to https://rubygems.org...Signed in.ERROR: While executing gem ... (Gem::CommandLineError)Please specify a gem name on the command line (e.g. gem build GEMNAME)$ rake release ← もう一回やってみたらうまく行った。yggdrasil 0.0.0 built to pkg/yggdrasil-0.0.0.gemTagged v0.0.0Username for 'https://github.com': tkusukawaPassword for 'https://tkusukawa@github.com':Username for 'https://github.com': tkusukawaPassword for 'https://tkusukawa@github.com':Pushed git commits and tagsPushed yggdrasil 0.0.0 to rubygems.org
# gem install yggdrasil# yggdrasil# gem uninstall yggdrasil
| 固定リンク
この記事へのコメントは終了しました。

コメント