Create a RubyGem 97: Update Bundle Before Performing Releases
Channel: Stateless Code
Date: 2023-03-04

We are nearing the end of our development for the maintenance releases for our gem. One of the final things to get in the habit of doing before a release is to review our dependencies and look for opportunities to upgrade them. 

It's possible that dependency upgrades could contain breaking changes, so it's important to start with a clean working directory in Git. If things go south, we can always do a `git reset --hard HEAD`. The more likely situation is that you would have a subset of gems that need to be reverted. You can downgrade the offending gems explicitly or add more pessimistic version constraints. Then you can re-run your bundle commands.

We look through all the dependencies in our Gemfile and gemspec and check RubyGems.org to see if there are newer versions available for them. Most of them do have newer versions available, so we make the updates to our gemspec so that the latest version is captured.

After that we run `bundle update` to update all of our dependencies to the latest version allowed by our constraints.

After updating our bundle we get a little confused about an issue that occurred with the debug gem the last time we updated a bundle. After a couple minutes chasing our tails, we realize that the issue came up in our NerdDice.com Rails 7 project and debug isn't a dependency at all for this project.

We run our RSpec specs and everything looks good. 

Back in video number 93, we updated RuboCop to enable new cops by default. We updated RuboCop in our bundle update, so we expect that there might be new violations to resolve. There are a lot of new violations (95), but they're all about preferring be to eq when making an expectation about a Boolean. We agree with the new standard and can autocorrect all of them.

We push to the remote and our GitHub actions pass on the first try. (Yay!)

This video covers:
00:00:12 Introduction
00:01:05 Look at Gemfile and gemspec, see whether there are new versions of gems available, and make updates
00:05:00 Review the changes made to the gemspec
00:05:22 Check out new branch and run `bundle update`
00:05:51 Try to find out what happened with the debug gem. Eventually realize that the issue was in the Rails project and not this one
00:08:27 Re-run bundle update and run RSpec
00:09:20 Run rubocop and auto-correct the new violations, preferring be over eq for Boolean expectations
00:11:30 Review changes
00:12:43 Commit, push, watch builds.
00:15:32 Pull request, prune some old branches, close issue

#ruby #rubygems #codecast #screencast #NerdDice #DnD #roleplaying #softwaredevelopment #github #opensource #dice #tlm #dependencies

See other related StatelessCode videos:
- Update Bundle to Clear Dependabot Alerts and Troubleshoot Build Dependency Failures (the debug gem issue I got confused with) https://youtu.be/rMlolATu73U
- Create a RubyGem 93: Refactor RuboCop to Enable New Cops by Default for the Gem https://youtu.be/wyZTKXMx8lg

Resources that we relied upon for this solution:
- RubyGems https://rubygems.org/

This video is CC0 - No rights reserved. (YouTube doesn't allow this option when publishing.) All code is released under the UNLICENSE.  Stateless Code denies the concept of "intellectual property". Copying is not stealing.