Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Automated Releases to RubyGems.org using Travis-CI.org

417 views

Published on

A description of a toolset and flow to do automated releases of an open source repo from github to rubygems.org using Travis, Jeweler, and CodeClimate.

Published in: Technology
  • Be the first to comment

  • Be the first to like this

Automated Releases to RubyGems.org using Travis-CI.org

  1. 1. AUTOMATED RELEASES TO RUBYGEMS USING TRAVISCI By Francis Luong (Franco)
  2. 2. @FRANCISLUONG (FRANCO) ➤ Infrastructure developer 
 for salesforce.com ➤ Core Focus: 
 Software for Networks ➤ Previous Team: Ruby 
 (but not Rails)
  3. 3. SHOW OF HANDS Published a Gem? Used Travis?
  4. 4. MY MOTIVATION Publish my first Ruby Gem - Honor TCL/Expect
  5. 5. I’m Lazy Free Servers/Services Are Amazing!
  6. 6. LET’S BEGIN!
  7. 7. INGREDIENTS ➤ RubyGems Account ➤ Travis-CI.org Account ➤ hooked up to your Github account via OAuth ➤ Github Ruby repo ➤ that you own (or for an Org) ➤ must be Public
  8. 8. STEP 1: CURL YOUR RUBYGEMS API KEY ~/.gem/credentials
  9. 9. STEP 1: RUBYGEMS API KEY ➤ Inputs: ➤ USERNAME: your rubygems username ➤ curl prompts you for password ➤ curl -u ${USERNAME} https://rubygems.org/api/ v1/api_key.yaml > ~/.gem/credentials ➤ chmod 0600 ~/.gem/credentials
  10. 10. STEP 2: GET TRAVIS WORKING https://docs.travis-ci.com/user/getting-started/
  11. 11. .TRAVIS.YML - BASIC VERSION language: ruby
 rvm:
 - 2.2.0
 - 2.0.0 install:
 - bundle install script:
 - uname -s
 - rake test
  12. 12. PRO TIP: USE THE TRAVIS GEM TO ADD RUBYGEMS DEPLOY $ travis setup rubygems [-—force] Gem name: |expect-behaviors| Release only tagged commits? |yes| Release only from francisluong/expect-behaviors? |yes| Encrypt API key? |yes| $ This uses the rubygems.org key from Step 1 and encrypts it.
  13. 13. .TRAVIS.YML - NOW WITH DEPLOY SECTION language: ruby
 rvm:
 - 2.2.0
 - 2.0.0 deploy:
 provider: rubygems
 api_key:
 secure: VThxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
 gem: expect-behaviors
 on:
 tags: true
 repo: francisluong/expect-behaviors install:
 - bundle install script:
 - uname -s
 - rake test
  14. 14. ADD YOUR REPO TO TRAVIS IF YOU HAVEN’T ALREADY
  15. 15. DEMO: BUMP, GEMSPEC, AND TAG https://travis-ci.org/francisluong/expect-behaviors https://github.com/francisluong/expect-behaviors/releases
  16. 16. STEP 3: USE JEWELER OR JUWELIER Bump Version and Generate Gemspec via Rake Tasks "Juwelier" is pronounced "you-ve-LEER"
  17. 17. “GemSpec files are a pain in the bottom! -Franco
  18. 18. JEWELER: RAKE TO FULLY GENERATE GEMSPEC FILE require 'jeweler'
 
 Jeweler::Tasks.new do |gem|
 # gem is a Gem::Specification... # see http://guides.rubygems.org/specification-reference/ # for more options
 gem.name = "expect-behaviors"
 gem.homepage = "http://github.com/francisluong/expect- behaviors"
 gem.license = "MIT"
 gem.summary = %Q{Ruby Mixin to add Expect Behaviors}
 gem.description = %Q{Ruby Mixin to add Expect Behaviors to SSH/Serial/Telnet controllers}
 gem.email = “XXXXXXXXXX@YYYYYYYYYY.com”
 gem.authors = ["Francis Luong (Franco)"]
 # dependencies defined in Gemfile
 end
 Jeweler::RubygemsDotOrgTasks.new
  19. 19. JEWELER ➤ Note: It’s in maintenance-only, so prefer Juwelier for new projects. Same maintainer. ➤ Bump Version ➤ rake version:bump:patch ➤ rake version:bump:minor ➤ rake version:bump:major ➤ Generate Gemspec file ➤ rake gemspec
  20. 20. DEVELOPMENT AND RELEASE FLOW :)
  21. 21. BRANCH -> PR -> MERGE - AS PER USUAL
  22. 22. 2 STEPS TO RELEASE ➤ Preconditions: Master is in a good state for release 1. Commit a Version Bump and Gemspec. Push. 2. Create a Release Tag on Github 
 
 
 Travis responds to this by attempting a test/build/ deploy after testing
  23. 23. BONUS: CODE CLIMATE Coverage and Quality
  24. 24. CODECLIMATE IS ALSO FREE FOR OPEN-SOURCE ➤ You can sign up using your Github login ➤ And then just add your repo
  25. 25. THE CODE CLIMATE REPO TOKEN IS HARD TO FIND
  26. 26. BUT ONCE YOU KNOW WHERE IT IS…
  27. 27. YOU CAN ALSO ADD THIS TO YOUR TRAVIS YAML language: ruby
 rvm:
 - 2.2.0
 - 2.0.0 deploy:
 provider: rubygems
 api_key:
 secure: VThxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
 gem: expect-behaviors
 on:
 tags: true
 repo: francisluong/expect-behaviors install:
 - bundle install script:
 - uname -s
 - rake test addons:
 code_climate:
 repo_token: da6828XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
  28. 28. THEN ADD MORE BUTTONS TO YOUR README.MD
  29. 29. DEMO WRAP UP!
  30. 30. QUESTIONS
  31. 31. THANK YOU! @francisluong
  32. 32. RESOURCES ➤ http://www.francisluong.com/blog-network-automation/ 2016/3/13/travis-ruby-gems ➤ https://rubygems.org/gems/expect-behaviors ➤ https://travis-ci.org/francisluong/expect-behaviors ➤ https://github.com/francisluong/expect-behaviors/releases ➤ Jeweler and Juwelier ➤ https://github.com/technicalpickles/jeweler ➤ https://github.com/flajann2/juwelier ➤ https://codeclimate.com/github/francisluong/expect- behaviors

×