Question: I'd like to write a package for Ruby and make it available as a gem.  

What are the tools, steps and pitfalls ?  

Are there any good tutorials, screencasts, etc., which helped you learning how to do it ?

Answer: 
[Rubygems.org's Guides](http://guides.rubygems.org/) is one of the best resources for writing your own gem.

If you're using [Bundler](http://gembundler.com/) in your app, you might want to look at Ryan Bigg's guide to [Developing a RubyGem using Bundler](https://github.com/radar/guides/blob/master/gem-development.md) and the [Railscast on creating gems with Bundler](http://railscasts.com/episodes/245-new-gem-with-bundler).

If you're interested in tools to help you write gems:

* [Jeweler](https://github.com/technicalpickles/jeweler) - Opinionated tool for creating and managing Rubygem projects. There's also a [Gemcutter and Jeweler Railscast](http://railscasts.com/episodes/183-gemcutter-jeweler).
* [Hoe](https://github.com/seattlerb/hoe) - From the guys at seattlrb.
* [gem-this](http://github.com/lazyatom/gem-this) adds a bunch of helpful rake tasks.

Some tutorials/guides:

* [Creating Your First Gem](http://rubysource.com/creating-your-first-gem/)
* [Using bundler and rvm to build a rubygem](http://rails-bestpractices.com/blog/posts/8-using-bundler-and-rvm-to-build-a-rubygem) - Using bundler and rvm to create a gem
* [Gem Packaging: Best Practices](http://weblog.rubyonrails.org/2009/9/1/gem-packaging-best-practices)
* [Ruby Gem Recipe](http://royw.wordpress.com/2010/06/07/ruby-gem-recipe/) - Intro guide to creating a gem using bundler and jeweler
* [How to build a ruby gem and host it on gemcutter](http://buzaz.com/index.php/2010/01/03/how-to-build-a-ruby-gem/) - tutorial using echoe and gemcutter
* [The Truth About Gemspecs](http://blog.101ideas.cz/post/353002256/the-truth-about-gemspecs) - goes over gemspecs and tips for dealing with them
* [Packaging with RubyGems](http://www.owengriffin.com/?p=63) - a quickstart guide for Jeweler
* [gem that - James Adam](http://effectif.com/ruby/manor/gem-this) - reviews tools that help build gems (hoe, newgem, echoe, gemhub, jeweler, gem this)
* [Using Gemcutter's Api from the Commandline](http://tagaholic.me/2010/02/03/using-gemcutters-api-from-the-commandline.html)
* [New Gem with Bundler – Sample Rakefile](http://pablocantero.com/blog/2011/01/02/new-gem-with-bundler-sample-rakefile/) - Useful rakefile for deploying and publishing a gem
* [Let's Write a Gem](http://rakeroutes.com/blog/lets-write-a-gem-part-one/)
* [How To Build A Ruby Gem With Bundler, Test-Driven Development, Travis CI And Coveralls, Oh My!](http://coding.smashingmagazine.com/2014/04/08/how-to-build-ruby-gem-with-bundler-travis-ci-coveralls/)
You need not start writing a gem, just write some code, write some tests, use it however you want, and once you are happy with it, use [gem this](http://github.com/lazyatom/gem-this) to generate the relevant Rakefile.

It helps if you stick to the approaches other gems take (have a lib directory, avoid naming files in ways that could clash with other gems, write some tests if you can, have a readme), but it's not necessary.

Once you have something you want to share, put it on [github](http://github.com) and push it to [gemcutter](http://gemcutter.org).

Don't over think it, don't use hoe or other overkill tools, have fun, don't to anything I wouldn't do.