0
0

More than 3 years have passed since last update.

gemをリリースしてみる

Posted at

Rubyのgemをリリースしてみる。正確には、前回2009年にリリースしているので、11年ぶりの再リリースとなる。gemのリリース方法は、以下を参考にした。
参考:https://qiita.com/9sako6/items/72994b8b1c00af4e61fe

1. 以前リリースしたものを取得する

以前リリースしたものは、以下にある。つまり、現時点でも gem install cutepとすると使える。

RubyForge消滅に伴い、ホームページが消えているし、ソースコードも見られなくなっている。GitHubで再リリースする。自分のところに元ファイルはあるが、gemと同じものからスタートすることにした。以下より、ソースコードを取得する。

.gemという拡張子をzipに変更し、解凍。そうすると、data.tar.gzとmetadata.gzが出てくる。これを解凍すると、ソースが見られる。

2. bundleを使う

% gem install bundler
% cd ~/dev
% bundle gem cutep -t
Creating gem 'cutep'...
Do you want to license your code permissively under the MIT license?
This means that any other developer or company will be legally allowed to use your code for free as long as they admit you created it. You can read more about the MIT license at https://choosealicense.com/licenses/mit. y/(n): y
MIT License enabled in config
Do you want to include a code of conduct in gems you generate?
Codes of conduct can increase contributions to your project by contributors who prefer collaborative, safe spaces. You can read more about the code of conduct at contributor-covenant.org. Having a code of conduct means agreeing to the responsibility of enforcing it, so be sure that you are prepared to do that. Be sure that your email address is specified as a contact in the generated code of conduct so that people know who to contact in case of a violation. For suggestions about how to enforce codes of conduct, see https://bit.ly/coc-enforcement. y/(n): y
Code of conduct enabled in config
      create  cutep/Gemfile
      create  cutep/lib/cutep.rb
      create  cutep/lib/cutep/version.rb
      create  cutep/cutep.gemspec
      create  cutep/Rakefile
      create  cutep/README.md
      create  cutep/bin/console
      create  cutep/bin/setup
      create  cutep/.gitignore
      create  cutep/.travis.yml
      create  cutep/.rspec
      create  cutep/spec/spec_helper.rb
      create  cutep/spec/cutep_spec.rb
      create  cutep/LICENSE.txt
      create  cutep/CODE_OF_CONDUCT.md
Initializing git repo in /Users/eto/dev/Day22_cutep/cutep
Gem 'cutep' was successfully created. For more information on making a RubyGem visit https://bundler.io/guides/creating_gem.html
% cd cutep

3. ソースを修正する

  • 上記1の解凍してできたソースを、上記2のbundlerで作成した雛型に合わせるようにする。versionは1.1.0にする。
  • ここで、gem名がcutepで、実際の名前がqpという食い違いがあるため、多少変更する必要があった。 % git commit -m "Adapt the old version 1.0.0 files." % git push origin master として、githubにupする。

4. テスト

% bundle exec rake spec

5. gemspecを用意する

おおよそ下記のページ通りだったが、
参考:https://qiita.com/9sako6/items/72994b8b1c00af4e61fe

以下のように、rubygemsを明示的に指定する必要があった。変更されたのだろうか。
spec.metadata["allowed_push_host"] = "https://rubygems.org/"

6. RubyGems.orgのAPIキーを取得する

以前作成したRubyGems.orgアカウントがあるため、それと接続する。

% curl -u eto https://rubygems.org/api/v1/api_key.yaml > ~/.gem/credentials; chmod 0600 ~/.gem/credentials

パスワードを聞かれたら、rubygems.orgのパスワードを入力する。

7. gemを公開する

% git push --set-upstream origin master
% rake release

以下のように、1.1.0が公開された。
https://rubygems.org/gems/cutep

done!

0
0
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
0
0