<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Andrew Mason</title>
    <description>The latest articles on DEV Community by Andrew Mason (@andrewmcodes).</description>
    <link>https://dev.to/andrewmcodes</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F131437%2F1e22c4f2-df3d-41e6-8970-c4d9a63f15c2.png</url>
      <title>DEV Community: Andrew Mason</title>
      <link>https://dev.to/andrewmcodes</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/andrewmcodes"/>
    <language>en</language>
    <item>
      <title>How to install Ruby on Rails 6.1 with asdf on macOS Big Sur</title>
      <dc:creator>Andrew Mason</dc:creator>
      <pubDate>Thu, 25 Feb 2021 12:53:28 +0000</pubDate>
      <link>https://dev.to/andrewmcodes/how-to-install-ruby-on-rails-6-1-with-asdf-on-macos-big-sur-31c3</link>
      <guid>https://dev.to/andrewmcodes/how-to-install-ruby-on-rails-6-1-with-asdf-on-macos-big-sur-31c3</guid>
      <description>&lt;p&gt;Ruby and Ruby on Rails have an outdated reputation of being difficult to set up, and some jump on this point to push their full stack JavaScript fantasies. In 2021, however, this doesn’t have to be an issue with the correct tool. &lt;/p&gt;

&lt;p&gt;In this tutorial, we will set up Ruby on Rails 6.1 with Ruby 3, a PostgreSQL database, and Webpacker via Node on a clean install of macOS Big Sur without any pain thanks to &lt;a href="https://asdf-vm.com/#/"&gt;asdf&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 1 - Install Homebrew
&lt;/h2&gt;

&lt;blockquote&gt;
&lt;p&gt;The Missing Package Manager for macOS (or Linux)&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Install &lt;a href="https://brew.sh/"&gt;Homebrew&lt;/a&gt; and update your &lt;code&gt;$PATH&lt;/code&gt;. Take a look at the &lt;a href="https://docs.brew.sh/"&gt;official documentation&lt;/a&gt; if you run into issues.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;/bin/bash &lt;span class="nt"&gt;-c&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="si"&gt;$(&lt;/span&gt;curl &lt;span class="nt"&gt;-fsSL&lt;/span&gt; https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh&lt;span class="si"&gt;)&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;
&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s1"&gt;'export PATH="/usr/local/sbin:$PATH"'&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&amp;gt;&lt;/span&gt; ~/.zshrc
&lt;span class="nb"&gt;source&lt;/span&gt; ~/.zshrc &lt;span class="c"&gt;# If you see weird behavior, restart your terminal&lt;/span&gt;
brew doctor
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If everything is set up correctly, &lt;code&gt;brew doctor&lt;/code&gt; will return &lt;code&gt;Your system is ready to brew.&lt;/code&gt;. Address issues if there are any as they may cause issues down the road. You may also want to set up &lt;a href="https://docs.brew.sh/Shell-Completion#configuring-completions-in-zsh"&gt;Homebrew's shell-completion&lt;/a&gt; at this time.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 2 - Install asdf
&lt;/h2&gt;

&lt;blockquote&gt;
&lt;p&gt;Manage multiple runtime versions with a single CLI tool&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Install &lt;a href="https://asdf-vm.com/"&gt;asdf&lt;/a&gt; as well as some necessary dependencies and update your &lt;code&gt;~/.zshrc&lt;/code&gt;. If you'd like to install asdf through a different method, check out &lt;a href="https://asdf-vm.com/#/core-manage-asdf"&gt;the official documentation&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;We are also going to create a &lt;code&gt;.asdfrc&lt;/code&gt; file and &lt;a href="https://asdf-vm.com/#/core-configuration?id=homeasdfrc"&gt;enable &lt;code&gt;legacy_version_file&lt;/code&gt;&lt;/a&gt;, which will allow us to get version info from files like &lt;code&gt;.ruby-version&lt;/code&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;brew &lt;span class="nb"&gt;install &lt;/span&gt;coreutils curl git gpg gawk zsh yarn asdf
&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="nt"&gt;-e&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="se"&gt;\n&lt;/span&gt;&lt;span class="s2"&gt;. &lt;/span&gt;&lt;span class="si"&gt;$(&lt;/span&gt;brew &lt;span class="nt"&gt;--prefix&lt;/span&gt; asdf&lt;span class="si"&gt;)&lt;/span&gt;&lt;span class="s2"&gt;/asdf.sh"&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&amp;gt;&lt;/span&gt; ~/.zshrc
&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s1"&gt;'legacy_version_file = yes'&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&amp;gt;&lt;/span&gt; ~/.asdfrc
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Restart your terminal.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 3 - Install Ruby
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;asdf plugin add ruby
asdf &lt;span class="nb"&gt;install &lt;/span&gt;ruby 3.0.0
asdf global ruby 3.0.0
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://github.com/asdf-vm/asdf-ruby"&gt;Documentation&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 4 - Install Node
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;asdf plugin add nodejs
bash &lt;span class="nt"&gt;-c&lt;/span&gt; &lt;span class="s1"&gt;'`${ASDF_DATA_DIR:=$HOME/`.asdf}/plugins/nodejs/bin/import-release-team-keyring'&lt;/span&gt;
asdf &lt;span class="nb"&gt;install &lt;/span&gt;nodejs 14.16.0
asdf global nodejs 14.16.0
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://github.com/asdf-vm/asdf-nodejs"&gt;Documentation&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 5 - Install Postgres
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;asdf plugin add postgres
asdf install postgres 13.2
asdf global postgres 13.2
$HOME/.asdf/installs/postgres/13.2/bin/pg_ctl -D $HOME/.asdf/installs/postgres/13.2/data -l logfile start
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://github.com/smashedtoatoms/asdf-postgres"&gt;Documentation&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;🔥 You can &lt;a href="https://gist.github.com/jbranchaud/3cda6be6e1dc69c6f55435a387018dac"&gt;add this handy function to your &lt;code&gt;~/.zshrc&lt;/code&gt;&lt;/a&gt; from &lt;a href="https://twitter.com/jbrancha"&gt;Josh Branchaud&lt;/a&gt; to make switching postgres versions easier.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 6 - Create Ruby on Rails app
&lt;/h2&gt;

&lt;p&gt;To make sure everything's correct, let's create a new Rails app with a postgres database:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;gem &lt;span class="nb"&gt;install &lt;/span&gt;bundler rails
rails new asdf_demo &lt;span class="nt"&gt;-d&lt;/span&gt; postgresql
&lt;span class="nb"&gt;cd &lt;/span&gt;asdf_demo
bin/rails db:prepare
bin/rails s
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Open &lt;code&gt;localhost:3000&lt;/code&gt; in your browser and you should see the Rails welcome screen. 🥳&lt;/p&gt;

&lt;h2&gt;
  
  
  Summary
&lt;/h2&gt;

&lt;p&gt;In the end, this was all we needed to get a Rails app running on a clean install of macOS Big Sur:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;/bin/bash &lt;span class="nt"&gt;-c&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="si"&gt;$(&lt;/span&gt;curl &lt;span class="nt"&gt;-fsSL&lt;/span&gt; https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh&lt;span class="si"&gt;)&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;
&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s1"&gt;'export PATH="/usr/local/sbin:$PATH"'&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&amp;gt;&lt;/span&gt; ~/.zshrc
&lt;span class="nb"&gt;source&lt;/span&gt; ~/.zshrc
brew doctor
brew &lt;span class="nb"&gt;install &lt;/span&gt;coreutils curl git gpg gawk zsh yarn asdf
&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="nt"&gt;-e&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="se"&gt;\n&lt;/span&gt;&lt;span class="s2"&gt;. &lt;/span&gt;&lt;span class="si"&gt;$(&lt;/span&gt;brew &lt;span class="nt"&gt;--prefix&lt;/span&gt; asdf&lt;span class="si"&gt;)&lt;/span&gt;&lt;span class="s2"&gt;/asdf.sh"&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&amp;gt;&lt;/span&gt; ~/.zshrc
&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s1"&gt;'legacy_version_file = yes'&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&amp;gt;&lt;/span&gt; ~/.asdfrc
&lt;span class="c"&gt;# ⚠️ Restart your terminal ⚠️&lt;/span&gt;
asdf plugin add ruby
asdf &lt;span class="nb"&gt;install &lt;/span&gt;ruby 3.0.0
asdf global ruby 3.0.0
asdf plugin add nodejs
bash &lt;span class="nt"&gt;-c&lt;/span&gt; &lt;span class="s1"&gt;'`${ASDF_DATA_DIR:=$HOME/`.asdf}/plugins/nodejs/bin/import-release-team-keyring'&lt;/span&gt;
asdf &lt;span class="nb"&gt;install &lt;/span&gt;nodejs 14.16.0
asdf global nodejs 14.16.0
asdf plugin add postgres
asdf &lt;span class="nb"&gt;install &lt;/span&gt;postgres 13.2
asdf global postgres 13.2
&lt;span class="nv"&gt;$HOME&lt;/span&gt;/.asdf/installs/postgres/13.2/bin/pg_ctl &lt;span class="nt"&gt;-D&lt;/span&gt; &lt;span class="nv"&gt;$HOME&lt;/span&gt;/.asdf/installs/postgres/13.2/data &lt;span class="nt"&gt;-l&lt;/span&gt; logfile start
&lt;span class="c"&gt;# ⚠️ Restart your terminal ⚠️&lt;/span&gt;
gem &lt;span class="nb"&gt;install &lt;/span&gt;bundler rails
rails new asdf_demo &lt;span class="nt"&gt;-d&lt;/span&gt; postgresql
&lt;span class="nb"&gt;cd &lt;/span&gt;asdf_demo
bin/rails db:prepare
bin/rails s
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;blockquote&gt;
&lt;p&gt;I am sure there are ways to improve this and I would love to hear any optimizations you come up with!&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;It doesn't have to end here though! Checkout &lt;a href="https://asdf-vm.com/#/plugins-all?id=plugin-list"&gt;asdf's plugin list&lt;/a&gt; for all available plugins. &lt;a href="https://github.com/smashedtoatoms/asdf-redis"&gt;Redis&lt;/a&gt;, &lt;a href="https://github.com/asdf-community/asdf-elasticsearch"&gt;Elasticsearch&lt;/a&gt;, and &lt;a href="https://github.com/mangalakader/asdf-imagemagick"&gt;ImageMagick&lt;/a&gt; can all be managed through asdf. &lt;/p&gt;

&lt;p&gt;Hopefully this tutorial will help you get up and running with a Ruby on Rails 6.1 development environment lightning fast and pain free. 🚀&lt;/p&gt;

&lt;p&gt;Happy coding!&lt;/p&gt;

</description>
      <category>ruby</category>
      <category>rails</category>
      <category>tutorial</category>
      <category>beginners</category>
    </item>
    <item>
      <title>Automating Ruby Gem Releases with GitHub Actions</title>
      <dc:creator>Andrew Mason</dc:creator>
      <pubDate>Sat, 20 Feb 2021 02:13:43 +0000</pubDate>
      <link>https://dev.to/andrewmcodes/automating-ruby-gem-releases-with-github-actions-1m1c</link>
      <guid>https://dev.to/andrewmcodes/automating-ruby-gem-releases-with-github-actions-1m1c</guid>
      <description>&lt;p&gt;Whether you are a gem maintaining machine or new to the world of authoring gems, this tutorial is for you. Adhereing to SemVer and keeping an updated changelog are both important components in well maintained open source, but they are also a pain at times. This tutorial will walk you through a simple way to create a release process that automates the small, but important, parts of maintaining a Ruby gem.&lt;/p&gt;

&lt;h2&gt;
  
  
  Release Please
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://github.com/google-github-actions/release-please-action"&gt;Release Please Action&lt;/a&gt; is a GitHub action created by Google to automate releases with &lt;a href="https://www.conventionalcommits.org/en/v1.0.0/"&gt;Conventional Commit Messages&lt;/a&gt;. As you merge PR's into your main branch, the action will create/update a new release branch that automatically adds your commits to a changelog and bumps the version according to your commits. When you're ready to release your changes, merging the PR will cause a new GitHub release to be created and released. We can even automate publishing to package registries like &lt;a href="https://rubygems.org"&gt;RubyGems&lt;/a&gt;!&lt;/p&gt;

&lt;h2&gt;
  
  
  Conventional Commits
&lt;/h2&gt;

&lt;p&gt;This article will assume you are familiar with &lt;a href="(https://www.conventionalcommits.org/en/v1.0.0/)"&gt;Conventional Commits&lt;/a&gt;. Here is a brief overview of the important prefixes, pulled from &lt;a href="https://github.com/google-github-actions/release-please-action#whats-a-release-pr"&gt;the action's README&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The most important prefixes you should have in mind are:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;fix&lt;/code&gt;: which represents bug fixes, and correlates to a SemVer patch.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;feat&lt;/code&gt;: which represents a new feature, and correlates to a SemVer minor.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;feat!&lt;/code&gt;:, or &lt;code&gt;fix!:&lt;/code&gt;, &lt;code&gt;refactor!:&lt;/code&gt;, etc., which represent a breaking change (indicated by the !) and will result in a SemVer major.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;I've considered doing a longer article about how I use conventional commit messages in my workflow, so let me know if you'd be interested in that.&lt;/p&gt;

&lt;h2&gt;
  
  
  Testing it out
&lt;/h2&gt;

&lt;p&gt;I'm going to create a new gem to demo this action's functionality:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;bundler gem release-please-demo &lt;span class="nt"&gt;--test&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;rspec &lt;span class="nt"&gt;--ci&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;github
&lt;span class="nb"&gt;cd &lt;/span&gt;release-please-demo
bundle &lt;span class="nb"&gt;install&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;blockquote&gt;
&lt;p&gt;Skip to the bottom if you'd just like to see the result!&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Next we will need to update our gemspec if we want to publish the gem. I'm not going to go over this right now, but if you're curious to learn more about how to setup a Ruby gem specification, I suggest &lt;a href="https://piotrmurach.com/articles/writing-a-ruby-gem-specification/"&gt;checking out this great article by Piotr Murach&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;This is what my &lt;code&gt;release-please-demo.gemspec&lt;/code&gt; looks like:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight ruby"&gt;&lt;code&gt;&lt;span class="c1"&gt;# frozen_string_literal: true&lt;/span&gt;

&lt;span class="nb"&gt;require_relative&lt;/span&gt; &lt;span class="s2"&gt;"lib/release/please/demo/version"&lt;/span&gt;

&lt;span class="no"&gt;Gem&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="no"&gt;Specification&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;new&lt;/span&gt; &lt;span class="k"&gt;do&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt;&lt;span class="n"&gt;spec&lt;/span&gt;&lt;span class="o"&gt;|&lt;/span&gt;
  &lt;span class="n"&gt;spec&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;name&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"release-please-demo"&lt;/span&gt;
  &lt;span class="n"&gt;spec&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;version&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="no"&gt;Release&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="no"&gt;Please&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="no"&gt;Demo&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="no"&gt;VERSION&lt;/span&gt;
  &lt;span class="n"&gt;spec&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;authors&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"Andrew Mason"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
  &lt;span class="n"&gt;spec&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;email&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"andrewmcodes@protonmail.com"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
  &lt;span class="n"&gt;spec&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;summary&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"Demo of release-please."&lt;/span&gt;
  &lt;span class="n"&gt;spec&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;description&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"A demo gem showing how to use release-please to automatically version gems."&lt;/span&gt;
  &lt;span class="n"&gt;spec&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;homepage&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"https://github.com/andrewmcodes/release-please-demo"&lt;/span&gt;
  &lt;span class="n"&gt;spec&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;license&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"MIT"&lt;/span&gt;
  &lt;span class="n"&gt;spec&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;required_ruby_version&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="no"&gt;Gem&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="no"&gt;Requirement&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;new&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"&amp;gt;= 2.4.0"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
  &lt;span class="n"&gt;spec&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;metadata&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="s2"&gt;"bug_tracker_uri"&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="si"&gt;#{&lt;/span&gt;&lt;span class="n"&gt;spec&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;homepage&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;/issues"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="s2"&gt;"changelog_uri"&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="si"&gt;#{&lt;/span&gt;&lt;span class="n"&gt;spec&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;homepage&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;/blob/main/CHANGELOG.md"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="s2"&gt;"documentation_uri"&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;spec&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;homepage&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;to_s&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="s2"&gt;"homepage_uri"&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;spec&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;homepage&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;to_s&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="s2"&gt;"source_code_uri"&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;spec&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;homepage&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;to_s&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;

  &lt;span class="n"&gt;spec&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;files&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="no"&gt;Dir&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;chdir&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="no"&gt;File&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;expand_path&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;__dir__&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt; &lt;span class="k"&gt;do&lt;/span&gt;
    &lt;span class="sb"&gt;`git ls-files -z`&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;split&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="se"&gt;\x0&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nf"&gt;reject&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt;&lt;span class="n"&gt;f&lt;/span&gt;&lt;span class="o"&gt;|&lt;/span&gt; &lt;span class="n"&gt;f&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;match&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sr"&gt;%r{&lt;/span&gt;&lt;span class="se"&gt;\A&lt;/span&gt;&lt;span class="sr"&gt;(?:test|spec|features)/}&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="k"&gt;end&lt;/span&gt;
  &lt;span class="n"&gt;spec&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;bindir&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"exe"&lt;/span&gt;
  &lt;span class="n"&gt;spec&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;executables&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;spec&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;files&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;grep&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sr"&gt;%r{&lt;/span&gt;&lt;span class="se"&gt;\A&lt;/span&gt;&lt;span class="sr"&gt;exe/}&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt;&lt;span class="n"&gt;f&lt;/span&gt;&lt;span class="o"&gt;|&lt;/span&gt; &lt;span class="no"&gt;File&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;basename&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;f&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="n"&gt;spec&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;require_paths&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"lib"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
&lt;span class="k"&gt;end&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Since the purpose of this article is to focus on the release cycle, we are just going to use the gem that Bundler scaffolded without any code changes. If you were building you own gem, this is the part where you would add functionality to the gem.&lt;/p&gt;

&lt;h2&gt;
  
  
  Setting up the action
&lt;/h2&gt;

&lt;p&gt;Let's build our release action:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;touch&lt;/span&gt; .github/workflows/release.yml
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Open this in your code editor of choice.&lt;/p&gt;

&lt;p&gt;First we are going to set the name of the action, and when it should run. We only want this action to run when something is merged into the default branch, or a release branch depending on your workflow. I name my default branch main, so every time code gems pushed to main, we will run this action.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="c1"&gt;# .github/workflows/release.yml&lt;/span&gt;

&lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;release&lt;/span&gt;

&lt;span class="na"&gt;on&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;push&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;branches&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
      &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s"&gt;main&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Next we need to setup a job for the &lt;a href="https://github.com/google-github-actions/release-please-action"&gt;Release Please Action&lt;/a&gt;. Option descriptions are annotated with comments, but please &lt;a href="https://github.com/google-github-actions/release-please-action#configuration"&gt;view the official configuration documentation&lt;/a&gt; to learn more.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="na"&gt;jobs&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;release-please&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;runs-on&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;ubuntu-latest&lt;/span&gt;
    &lt;span class="na"&gt;steps&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
      &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;uses&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;GoogleCloudPlatform/release-please-action@v2&lt;/span&gt;
        &lt;span class="na"&gt;id&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;release&lt;/span&gt;
        &lt;span class="na"&gt;with&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
          &lt;span class="c1"&gt;# The release type&lt;/span&gt;
          &lt;span class="na"&gt;release-type&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;ruby&lt;/span&gt;
          &lt;span class="c1"&gt;# A name for the artifact releases are being created for&lt;/span&gt;
          &lt;span class="c1"&gt;# which is the name of our gem&lt;/span&gt;
          &lt;span class="na"&gt;package-name&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;release-please-demo&lt;/span&gt;
          &lt;span class="c1"&gt;# Should breaking changes before 1.0.0 produce minor bumps?&lt;/span&gt;
          &lt;span class="na"&gt;bump-minor-pre-major&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="no"&gt;true&lt;/span&gt;
          &lt;span class="c1"&gt;# Path to our version file to increment&lt;/span&gt;
          &lt;span class="na"&gt;version-file&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="s"&gt;lib/release/please/demo/version.rb"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;We are going to do some more cool things in a second but lets go ahead and see what this produces. Create a new GitHub repo, commit everything, and push it up. As a note, Bundler adds a failing test condition by default when you scaffold the gem, so if you added the &lt;code&gt;--ci=github&lt;/code&gt; flag when you created the gem, the generated &lt;code&gt;.github/workflows/main.yml&lt;/code&gt; action will fail unless you remove the failing test. I'll let you debug that on your own for now.&lt;/p&gt;

&lt;p&gt;The release action will run once you push your changes to the main branch. Your initial run output should look like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Run GoogleCloudPlatform/release-please-action@v2
✖ No merged release PR found
✖ Unable to build candidate
✔ found 4 commits since beginning of time
✖ no user facing commits found since beginning of time
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This output says:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;A merged release PR was not found, which we will talk about in a moment&lt;/li&gt;
&lt;li&gt;There is no build candidate&lt;/li&gt;
&lt;li&gt;There were 4 commits found in the repo&lt;/li&gt;
&lt;li&gt;None of those commits were user facing, aka they weren't features or bug fixes&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Just for reference - this is the output of &lt;code&gt;git log --one-line&lt;/code&gt; so you can see my four commits:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;9a4d62b &lt;span class="o"&gt;(&lt;/span&gt;HEAD -&amp;gt; main, origin/main&lt;span class="o"&gt;)&lt;/span&gt; build: add release action &lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="c"&gt;#1)&lt;/span&gt;
1b0bcd4 chore: bundle &lt;span class="nb"&gt;install
&lt;/span&gt;7a30c6d chore: update gemspec
c793bca chore: initial commit
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;As we can see, none were features or fixes, so the action did not create a release PR.&lt;/p&gt;

&lt;h2&gt;
  
  
  Creating a release
&lt;/h2&gt;

&lt;p&gt;I'm going to cheat and an empty commit for a feature:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git commit &lt;span class="nt"&gt;--allow-empty&lt;/span&gt; &lt;span class="nt"&gt;-m&lt;/span&gt; &lt;span class="s2"&gt;"feat: add a feature"&lt;/span&gt;
git push &lt;span class="nt"&gt;-u&lt;/span&gt; origin main
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Our release action should run and this time find a user facing commit and open a new release PR. The PR will increment the version number and create a new, or edit an existing, Changelog.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--ub4VGYgY--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/2mxv0klralttr9hmlsip.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--ub4VGYgY--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/2mxv0klralttr9hmlsip.png" alt="Generated release pr"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Note: For a gem without prior releases, I wasn't able to find a way to prevent a full point release. You &lt;em&gt;could&lt;/em&gt; get around this by editing the release PR to match the inital version number you'd like before merging. This is not an issue with projects with prior releases.&lt;/p&gt;

&lt;h2&gt;
  
  
  Publish to RubyGems
&lt;/h2&gt;

&lt;p&gt;Our current setup is great if we just want to automate changelog creation and versioning, but we would still have to publish the gem ourselves after the release was created. Fortunately, we can hook into our existing workflow to automate publishing as well!&lt;/p&gt;

&lt;p&gt;You may have noticed we gave our first step an id of &lt;code&gt;release&lt;/code&gt;. By doing this, we can check the output of that step in other steps and act accordingly.&lt;/p&gt;

&lt;h3&gt;
  
  
  Setup Steps
&lt;/h3&gt;

&lt;p&gt;If the output of our release step is &lt;code&gt;release_created&lt;/code&gt;, we will checkout the repo, install Ruby, and run &lt;code&gt;bundle install&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="na"&gt;jobs&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;release-please&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;runs-on&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;ubuntu-latest&lt;/span&gt;
    &lt;span class="na"&gt;steps&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
      &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;uses&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;GoogleCloudPlatform/release-please-action@v2&lt;/span&gt;
        &lt;span class="na"&gt;id&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;release&lt;/span&gt;
        &lt;span class="na"&gt;with&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
          &lt;span class="na"&gt;release-type&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;ruby&lt;/span&gt;
          &lt;span class="na"&gt;package-name&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;release-please-demo&lt;/span&gt;
          &lt;span class="na"&gt;bump-minor-pre-major&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="no"&gt;true&lt;/span&gt;
          &lt;span class="na"&gt;version-file&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="s"&gt;lib/release/please/demo/version.rb"&lt;/span&gt;
      &lt;span class="c1"&gt;# Checkout code if release was created&lt;/span&gt;
      &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;uses&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;actions/checkout@v2&lt;/span&gt;
        &lt;span class="na"&gt;if&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;${{ steps.release.outputs.release_created }}&lt;/span&gt;
      &lt;span class="c1"&gt;# Setup ruby if a release was created&lt;/span&gt;
      &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;uses&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;ruby/setup-ruby@v1&lt;/span&gt;
        &lt;span class="na"&gt;with&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
          &lt;span class="na"&gt;ruby-version&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;3.0.0&lt;/span&gt;
        &lt;span class="na"&gt;if&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;${{ steps.release.outputs.release_created }}&lt;/span&gt;
      &lt;span class="c1"&gt;# Bundle install&lt;/span&gt;
      &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;run&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;bundle install&lt;/span&gt;
        &lt;span class="na"&gt;if&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;${{ steps.release.outputs.release_created }}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Publish Step
&lt;/h3&gt;

&lt;p&gt;If a release was created, we will setup gem credentials, build the gem, and push it to RubyGems.&lt;/p&gt;

&lt;p&gt;You will &lt;strong&gt;need&lt;/strong&gt; to &lt;a href="https://guides.rubygems.org/api-key-scopes/"&gt;get an API token from RubyGems&lt;/a&gt; and &lt;a href="https://docs.github.com/en/actions/reference/encrypted-secrets#creating-encrypted-secrets-for-an-environment"&gt;add it to your repository secrets&lt;/a&gt;. I named mine &lt;code&gt;RUBYGEMS_AUTH_TOKEN&lt;/code&gt; but you can set the name to whatever you'd like.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;publish gem&lt;/span&gt;
  &lt;span class="na"&gt;run&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="pi"&gt;|&lt;/span&gt;
    &lt;span class="s"&gt;mkdir -p $HOME/.gem&lt;/span&gt;
    &lt;span class="s"&gt;touch $HOME/.gem/credentials&lt;/span&gt;
    &lt;span class="s"&gt;chmod 0600 $HOME/.gem/credentials&lt;/span&gt;
    &lt;span class="s"&gt;printf -- "---\n:rubygems_api_key: ${GEM_HOST_API_KEY}\n" &amp;gt; $HOME/.gem/credentials&lt;/span&gt;
    &lt;span class="s"&gt;gem build *.gemspec&lt;/span&gt;
    &lt;span class="s"&gt;gem push *.gem&lt;/span&gt;
  &lt;span class="na"&gt;env&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="c1"&gt;# Make sure to update the secret name&lt;/span&gt;
    &lt;span class="c1"&gt;# if yours isn't named RUBYGEMS_AUTH_TOKEN&lt;/span&gt;
    &lt;span class="na"&gt;GEM_HOST_API_KEY&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="s"&gt;${{secrets.RUBYGEMS_AUTH_TOKEN}}"&lt;/span&gt;
  &lt;span class="na"&gt;if&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;${{ steps.release.outputs.release_created }}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Note: I got this code straight from &lt;a href="https://docs.github.com/en/actions/guides/building-and-testing-ruby#publishing-gems"&gt;GitHub's action documentation&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Release and Publish
&lt;/h2&gt;

&lt;p&gt;Our final action:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="c1"&gt;# .github/workflows/release.yml&lt;/span&gt;

&lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;release&lt;/span&gt;

&lt;span class="na"&gt;on&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;push&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;branches&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
      &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s"&gt;main&lt;/span&gt;

&lt;span class="na"&gt;jobs&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;release-please&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;runs-on&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;ubuntu-latest&lt;/span&gt;
    &lt;span class="na"&gt;steps&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
      &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;uses&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;GoogleCloudPlatform/release-please-action@v2&lt;/span&gt;
        &lt;span class="na"&gt;id&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;release&lt;/span&gt;
        &lt;span class="na"&gt;with&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
          &lt;span class="na"&gt;release-type&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;ruby&lt;/span&gt;
          &lt;span class="na"&gt;package-name&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;release-please-demo&lt;/span&gt;
          &lt;span class="na"&gt;bump-minor-pre-major&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="no"&gt;true&lt;/span&gt;
          &lt;span class="na"&gt;version-file&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="s"&gt;lib/release/please/demo/version.rb"&lt;/span&gt;
      &lt;span class="c1"&gt;# Checkout code if release was created&lt;/span&gt;
      &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;uses&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;actions/checkout@v2&lt;/span&gt;
        &lt;span class="na"&gt;if&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;${{ steps.release.outputs.release_created }}&lt;/span&gt;
      &lt;span class="c1"&gt;# Setup ruby if a release was created&lt;/span&gt;
      &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;uses&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;ruby/setup-ruby@v1&lt;/span&gt;
        &lt;span class="na"&gt;with&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
          &lt;span class="na"&gt;ruby-version&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;3.0.0&lt;/span&gt;
        &lt;span class="na"&gt;if&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;${{ steps.release.outputs.release_created }}&lt;/span&gt;
      &lt;span class="c1"&gt;# Bundle install&lt;/span&gt;
      &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;run&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;bundle install&lt;/span&gt;
        &lt;span class="na"&gt;if&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;${{ steps.release.outputs.release_created }}&lt;/span&gt;
      &lt;span class="c1"&gt;# Publish&lt;/span&gt;
      &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;publish gem&lt;/span&gt;
        &lt;span class="na"&gt;run&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="pi"&gt;|&lt;/span&gt;
          &lt;span class="s"&gt;mkdir -p $HOME/.gem&lt;/span&gt;
          &lt;span class="s"&gt;touch $HOME/.gem/credentials&lt;/span&gt;
          &lt;span class="s"&gt;chmod 0600 $HOME/.gem/credentials&lt;/span&gt;
          &lt;span class="s"&gt;printf -- "---\n:rubygems_api_key: ${GEM_HOST_API_KEY}\n" &amp;gt; $HOME/.gem/credentials&lt;/span&gt;
          &lt;span class="s"&gt;gem build *.gemspec&lt;/span&gt;
          &lt;span class="s"&gt;gem push *.gem&lt;/span&gt;
        &lt;span class="na"&gt;env&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
          &lt;span class="c1"&gt;# Make sure to update the secret name&lt;/span&gt;
          &lt;span class="c1"&gt;# if yours isn't named RUBYGEMS_AUTH_TOKEN&lt;/span&gt;
          &lt;span class="na"&gt;GEM_HOST_API_KEY&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="s"&gt;${{secrets.RUBYGEMS_AUTH_TOKEN}}"&lt;/span&gt;
        &lt;span class="na"&gt;if&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;${{ steps.release.outputs.release_created }}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Commit, push this code, and wait for your release PR to be updated by our action bot. Once the release PR has been updated, merge the PR into your main branch.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--1FR40RhC--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/mtfi99frqpq9qr5odfnx.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--1FR40RhC--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/mtfi99frqpq9qr5odfnx.png" alt="Release action success"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Once our release action runs, assuming it succeeds, you should see a new release in GitHub! One great feature of this action is that it will build the release notes from our changelog entries. 🚀&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--WUaYnWft--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/km4thpr1h49gauu2uvic.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--WUaYnWft--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/km4thpr1h49gauu2uvic.png" alt="New GitHub Release"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;If we check RubyGems, we should see our new gem has been published and is ready to share!&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--Zd9XwMKh--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/w7se9cw67cfp3xrdz8jw.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--Zd9XwMKh--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/w7se9cw67cfp3xrdz8jw.png" alt="RubyGems"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Final Thoughts
&lt;/h2&gt;

&lt;p&gt;If you followed the tutorial and don't intend to use your new gem, you should consider yanking it to allow others to use the name in the future.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;gem yank release-please-demo &lt;span class="nt"&gt;-v&lt;/span&gt; 1.0.0
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;One great aspect of the action is that you can use it with other languages or simply a &lt;code&gt;.txt&lt;/code&gt; file, allowing you to create consistent pattern across all of your open source. You could enhance the workflow by adding in checks to run the tests before releases and also adding a linter to ensure conventional commits are used. With this workflow, you'll be able to easily make new releases without pulling down the code and never have to try and remember how you release a project again.&lt;/p&gt;

&lt;p&gt;Give it a try and tell me what you think!&lt;/p&gt;

</description>
      <category>ruby</category>
      <category>tutorial</category>
      <category>actions</category>
      <category>gem</category>
    </item>
    <item>
      <title>Redesigning my website</title>
      <dc:creator>Andrew Mason</dc:creator>
      <pubDate>Wed, 17 Feb 2021 04:14:32 +0000</pubDate>
      <link>https://dev.to/andrewmcodes/redesigning-my-website-4lli</link>
      <guid>https://dev.to/andrewmcodes/redesigning-my-website-4lli</guid>
      <description>&lt;p&gt;My personal website - &lt;a href="https://andrewm.codes/"&gt;andrewm.codes&lt;/a&gt; has gone through many iterations over the years. Some may view my constant tinkering as a waste of time, and it probably is, but I've come to realize that I really enjoy using it as a playground to test new technologies and new ideas. The problem with this approach though is that it continually became an excuse for not writing actual content. With this iteration of the site, I decided to put content creation first and tinkering second.&lt;/p&gt;

&lt;h2&gt;
  
  
  History
&lt;/h2&gt;

&lt;p&gt;My site has existed on multiple domains using various technologies since 2016. I won't bore you with all of the details but here is a short list of &lt;em&gt;some&lt;/em&gt; of the tech I've used to build other versions:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Plain HTML &amp;amp; CSS&lt;/li&gt;
&lt;li&gt;&lt;a href="https://nuxtjs.org/"&gt;Nuxt&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.gatsbyjs.com"&gt;Gatsby&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.stackbit.com"&gt;Stackbit&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.bridgetownrb.com"&gt;Bridgetown&lt;/a&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Planning
&lt;/h2&gt;

&lt;p&gt;One of the reasons most of my other sites ended up being unmaintainable or not having certain features that I wanted was simply due to a lack of planning. This time I wanted things to be different.&lt;/p&gt;

&lt;h3&gt;
  
  
  Choosing a Framework
&lt;/h3&gt;

&lt;p&gt;As a Rubyist, I had always struggled to wrap my brain around JavaScript static site generators because of what I viewed as unnecessary complexity and dependency hell; however, I continued to use them over something like &lt;a href="https://jekyllrb.com"&gt;Jekyll&lt;/a&gt; because I wanted to use more modern tools like &lt;a href="https://tailwindcss.com"&gt;Tailwind CSS&lt;/a&gt; and build my views with components.&lt;/p&gt;

&lt;p&gt;Enter &lt;a href="https://www.bridgetownrb.com"&gt;Bridgetown&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;I'm not going to go over what Bridgetown is right now, but the key features it had that I wanted were Ruby, markdown, components, ability to use modern JS tooling easily, API for content generation, and easily customizable. I definitely encourage you to give it a look if you're considering a site redesign.&lt;/p&gt;

&lt;h3&gt;
  
  
  Setting Priorities
&lt;/h3&gt;

&lt;p&gt;I sat down and chose a few things I really cared about when it came to the content and architecture of the site:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Owning my content&lt;/li&gt;
&lt;li&gt;Ability to publish content remotely&lt;/li&gt;
&lt;li&gt;Great developer experience&lt;/li&gt;
&lt;li&gt;Scriptable&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;While I didn't follow this 100% of the time, my general goal was to only work on things in service to these main goals. &lt;/p&gt;

&lt;p&gt;Data design is something I will discuss below but I wanted to call out the fact I should have spent more time settling on the shape of the data and exactly what content I wanted before diving straight into building with fake data. What I failed to recognize at first is that the data structure for your static site is just as important as for your webapp, and careful upfront design can save lots of time and headache.&lt;/p&gt;

&lt;h2&gt;
  
  
  The Stack
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Framework: &lt;a href="https://www.bridgetownrb.com"&gt;Bridgetown&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Template Language: &lt;a href="https://www.bridgetownrb.com/docs/erb-and-beyond"&gt;ERB&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Frontend Build Tool: &lt;a href="https://www.snowpack.dev"&gt;Snowpack&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;CSS: &lt;a href="https://tailwindcss.com"&gt;Tailwind CSS&lt;/a&gt; w/ Darkmode!&lt;/li&gt;
&lt;li&gt;JavaScript Sprinkles: &lt;a href="https://stimulus.hotwire.dev"&gt;Stimulus&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Performance: &lt;a href="https://turbo.hotwire.dev"&gt;Turbo&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Image Management: &lt;a href="https://cloudinary.com/"&gt;Cloudinary&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Hosting: &lt;a href="https://vercel.com"&gt;Vercel&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Analytics: &lt;a href="https://plausible.io"&gt;Plausible&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Content Creation Workflow
&lt;/h2&gt;

&lt;p&gt;Bridgetown gives you access to &lt;a href="https://www.bridgetownrb.com/docs/plugins#http-requests-and-the-document-builder"&gt;powerful ways to dynamically build pages and date&lt;/a&gt; so regardless of where the data comes from, implementation is pretty straight forward especially since you can leverage gems of your choosing.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Warning: overkill solution ahead&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;All of the site data, except for blog articles, are saved in a &lt;a href="https://strapi.io/"&gt;Strapi headless CMS&lt;/a&gt; self-hosted on &lt;a href="https://heroku.com"&gt;Heroku&lt;/a&gt; backed by a PostgreSQL database. A bit of work to get up and running but it offers me:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Robust REST Api with automically generated Swagger docs&lt;/li&gt;
&lt;li&gt;GraphQL endpoint with API methods&lt;/li&gt;
&lt;li&gt;Media file management with automatic Cloudinary uploads&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Ultimately this is one piece I may replace in the future but its an easy way to get up and running fast with a headless CMS and allow you to own the data. This was the only option I found that gave me all the features I wanted out of the box. I tried several data sources including Forestry, DatoCMS, Sanity, Netlify CMS, Airtable, Notion, and Google Sheets, but ultimately the fact Strapi can use Postgres as a datastore is what sold it. This gives me infinite power of the data including from my via &lt;a href="https://www.sqlprostudio.com"&gt;SQLPro Studio&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;With Strapi in place, I wrote a little Ruby (that needs to be refactored) to dump the records from specified API endpoints into datafiles. When the site builds, I reference these datafiles to build the collection views and dynamically generate content pages (like &lt;a href="https://andrewm.codes/about/"&gt;about&lt;/a&gt;).&lt;/p&gt;

&lt;p&gt;As for blog articles, they can be stored in Strapi as well, but I elected to just use &lt;a href="https://dev.to/andrewmcodes"&gt;DEV&lt;/a&gt; as the primary source for articles, dumped to a datafile using the &lt;a href="https://docs.dev.to/api/"&gt;DEV API&lt;/a&gt; and a little Ruby. When the site builds, Bridgetown uses that datafile to generate the posts.&lt;/p&gt;

&lt;p&gt;Notes were one thing that I originally built into the site but I decided to pull them all out after discovering &lt;a href="https://marketplace.visualstudio.com/items?itemName=vsls-contrib.gistfs"&gt;Gistpad&lt;/a&gt;. I plan to do a more detailed post about my workflow with this incredible extension in the future but the simple version is I use Gistpad's wiki feature to easily author notes in VS Code that sync to a GitHub repo. When I'm on my phone, I use &lt;a href="https://gitjournal.io/"&gt;GitJournal&lt;/a&gt; to by hooking it up to my repo.&lt;/p&gt;

&lt;h2&gt;
  
  
  What's Next
&lt;/h2&gt;

&lt;p&gt;There are a few more features I want to add that didn't stop me from shipping:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Update some of my old posts to work better with the new layout&lt;/li&gt;
&lt;li&gt;WebMentions integration&lt;/li&gt;
&lt;li&gt;Dynamic social share images&lt;/li&gt;
&lt;li&gt;More automations via iPhone Shortcuts and GitHub Actions&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Takeaways
&lt;/h2&gt;

&lt;p&gt;If I had to do it over again I would spend the time upfront to carefully choose the underlying data structure instead of jumping in head first. I consider myself to be a tool builder but an incredible amount of time was wasted by trying to lean solely on third-party services. Once I leaned back into my natrual tendency to build tools, I was able to solve most of my issues with a few lines of Ruby.&lt;/p&gt;

&lt;p&gt;At the end of the day though, I'm thrilled with the way it's turned out on the front and backend. More importantly tweaking my site will no longer get in the way of publishing content.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://andrewm.codes"&gt;Check it out and leave me your feedback!&lt;/a&gt;&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>bridgetown</category>
      <category>ruby</category>
      <category>strapi</category>
    </item>
    <item>
      <title>Webpacker 6: Image Asset Guide</title>
      <dc:creator>Andrew Mason</dc:creator>
      <pubDate>Thu, 24 Dec 2020 22:55:39 +0000</pubDate>
      <link>https://dev.to/andrewmcodes/webpacker-6-image-asset-guide-42hn</link>
      <guid>https://dev.to/andrewmcodes/webpacker-6-image-asset-guide-42hn</guid>
      <description>&lt;p&gt;In order to use your images and SVG files with Webpacker 6, you need to put them in the correct place and import them into your context.&lt;/p&gt;

&lt;h2&gt;
  
  
  Install
&lt;/h2&gt;

&lt;p&gt;We should be good here.&lt;/p&gt;

&lt;h2&gt;
  
  
  Usage
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Add Assets
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;mkdir&lt;/span&gt; &lt;span class="nt"&gt;-p&lt;/span&gt; app/javascript/media/images
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Require Context
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight diff"&gt;&lt;code&gt;&lt;span class="err"&gt;//&lt;/span&gt; app/javascript/packs/application.js
&lt;span class="gi"&gt;+
+ function importAll(r) {
+  r.keys().forEach(r);
+ }
+ // Add relevant file extensions as needed below.
+ // I'm sure there is a better way :shrug:
+ importAll(require.context('../media/images/', true, /\.(svg|jpg)$/));
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Verify
&lt;/h2&gt;

&lt;blockquote&gt;
&lt;p&gt;Note: Restart the dev server for good luck!&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Add an SVG and PNG into &lt;code&gt;app/javascript/media/images&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;In one of your views, add two image tags:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight erb"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;img&lt;/span&gt; &lt;span class="na"&gt;src=&lt;/span&gt;&lt;span class="s"&gt;"&lt;/span&gt;&lt;span class="cp"&gt;&amp;lt;%=&lt;/span&gt; &lt;span class="n"&gt;asset_pack_path&lt;/span&gt; &lt;span class="s1"&gt;'media/images/icon.svg'&lt;/span&gt; &lt;span class="cp"&gt;%&amp;gt;&lt;/span&gt;&lt;span class="s"&gt;"&lt;/span&gt; &lt;span class="nt"&gt;/&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;img&lt;/span&gt; &lt;span class="na"&gt;src=&lt;/span&gt;&lt;span class="s"&gt;"&lt;/span&gt;&lt;span class="cp"&gt;&amp;lt;%=&lt;/span&gt; &lt;span class="n"&gt;asset_pack_path&lt;/span&gt; &lt;span class="s1"&gt;'media/images/surf.jpg'&lt;/span&gt; &lt;span class="cp"&gt;%&amp;gt;&lt;/span&gt;&lt;span class="s"&gt;"&lt;/span&gt; &lt;span class="nt"&gt;/&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Reload your browser and you should see your images.&lt;/p&gt;

&lt;p&gt;Note that &lt;code&gt;&amp;lt;%= asset_pack_path 'media/images/icon.svg' %&amp;gt;&lt;/code&gt; only returns a string, so if you would rather inline your SVG files you will need to refer to the &lt;a href="https://webpack.js.org/guides/asset-modules/#inlining-assets"&gt;Webpack Asset Modules documentation&lt;/a&gt; and merge your changes into your Webpack context, as explained in &lt;a href="https://github.com/rails/webpacker#webpack-configuration"&gt;these Webpacker docs&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>rails</category>
      <category>webpacker</category>
      <category>tutorial</category>
      <category>svg</category>
    </item>
    <item>
      <title>Webpacker 6: Troubleshooting Guide</title>
      <dc:creator>Andrew Mason</dc:creator>
      <pubDate>Thu, 24 Dec 2020 16:12:01 +0000</pubDate>
      <link>https://dev.to/andrewmcodes/webpacker-6-troubleshooting-guide-pdl</link>
      <guid>https://dev.to/andrewmcodes/webpacker-6-troubleshooting-guide-pdl</guid>
      <description>&lt;p&gt;A (growing) collection of tools and techniques for debugging your Webpack(er) setup. &lt;/p&gt;

&lt;p&gt;I highly recommend reading the &lt;a href="https://survivejs.com/webpack/foreword/"&gt;SurviveJS - Webpack 5 ebook for a real deep dive!&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Locating the Issue
&lt;/h2&gt;

&lt;p&gt;Use the network tab in your browser to view the CSS that’s being sent to the browser for clues.&lt;/p&gt;

&lt;h2&gt;
  
  
  Cached Styles
&lt;/h2&gt;

&lt;p&gt;If you update your styles but your UI does not change and there are no errors, it’s likely browser caching.&lt;/p&gt;

&lt;p&gt;Hard reload after clearing your cache and you should see your changes.&lt;/p&gt;

&lt;p&gt;To avoid these errors, import your styles into your JS pack vs. using &lt;code&gt;style-loader&lt;/code&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Tools
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Dashboards
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://github.com/FormidableLabs/webpack-dashboard"&gt;Webpack-Dashboard&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>rails</category>
      <category>webpacker</category>
      <category>tutorial</category>
      <category>debugging</category>
    </item>
    <item>
      <title>Webpacker 6: Tailwind CSS 2.0 Integration</title>
      <dc:creator>Andrew Mason</dc:creator>
      <pubDate>Thu, 24 Dec 2020 16:11:42 +0000</pubDate>
      <link>https://dev.to/andrewmcodes/webpacker-6-tailwind-css-2-0-integration-3oe6</link>
      <guid>https://dev.to/andrewmcodes/webpacker-6-tailwind-css-2-0-integration-3oe6</guid>
      <description>&lt;p&gt;In order to add Tailwind CSS 2.0 to your Rails 6 + Webpacker 6 application, you need PostCSS set up, plus a few additional steps.&lt;/p&gt;

&lt;p&gt;Tailwind CSS has &lt;a href="https://tailwindcss.com/docs/using-with-preprocessors"&gt;detailed documentation on preprocessor usage&lt;/a&gt; so refer to that for further setup.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Note: This section builds on the PostCSS section&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  Install
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;yarn add tailwindcss
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Add Tailwind CSS Config File
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;yarn tailwind init
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Update PostCSS Config
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight diff"&gt;&lt;code&gt;&lt;span class="err"&gt;//&lt;/span&gt; postcss.config.js

module.exports = {
  plugins: [
    require('postcss-import'),
&lt;span class="gi"&gt;+   require('tailwindcss'),
&lt;/span&gt;    require('autoprefixer')
  ]
&lt;span class="err"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Usage
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;You should be able to use the same pack tag that you added for CSS.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Make sure you restart &lt;code&gt;bin/webpack-dev-server&lt;/code&gt; after installing new loaders.&lt;/p&gt;

&lt;h3&gt;
  
  
  Style Loader Example
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight diff"&gt;&lt;code&gt;&lt;span class="gd"&gt;&amp;lt;%# app/views/layouts/application.html.erb %&amp;gt;
&lt;/span&gt;
+ &amp;lt;%= stylesheet_packs_with_chunks_tag 'application', media: 'all', 'data-turbolinks-track': 'reload' %&amp;gt;
&lt;span class="gd"&gt;&amp;lt;%= javascript_packs_with_chunks_tag 'application', 'data-turbolinks-track': 'reload' %&amp;gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Extract Example
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight diff"&gt;&lt;code&gt;&lt;span class="gd"&gt;&amp;lt;%# app/views/layouts/application.html.erb %&amp;gt;
&lt;/span&gt;
&amp;lt;%= javascript_packs_with_chunks_tag 'application', 'data-turbolinks-track': 'reload' %&amp;gt;
&lt;span class="gi"&gt;+ &amp;lt;%= stylesheet_pack_tag 'application', media: 'all', 'data-turbolinks-track': 'reload' %&amp;gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight diff"&gt;&lt;code&gt;&lt;span class="err"&gt;//&lt;/span&gt; app/javascript/packs/application.js

+ import "./application.css"
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Verify
&lt;/h2&gt;

&lt;blockquote&gt;
&lt;p&gt;Note: Make sure you restart the dev server!&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Let’s create a new PostCSS file:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;touch &lt;/span&gt;app/javascript/stylesheets/base.css
&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"@import 'tailwindcss/base';"&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&amp;gt;&lt;/span&gt; app/javascript/stylesheets/base.css
&lt;span class="nb"&gt;touch &lt;/span&gt;app/javascript/stylesheets/utilities.css
&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"@import 'tailwindcss/utilities';"&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&amp;gt;&lt;/span&gt; app/javascript/stylesheets/utilities.css
&lt;span class="nb"&gt;touch &lt;/span&gt;app/javascript/stylesheets/components.css
&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"@import 'tailwindcss/components';"&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&amp;gt;&lt;/span&gt; app/javascript/stylesheets/components.css
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Next, add some CSS:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight diff"&gt;&lt;code&gt;&lt;span class="err"&gt;/*&lt;/span&gt; app/javascript/stylesheets/base.css */

@import "tailwindcss/base";

+ h1 {
&lt;span class="gi"&gt;+   font-size: 2.2em;
+   color: #2563eb;
+ }
+
+ p {
+   font-size: 1.2em;
+ }
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Lastly, update &lt;code&gt;application.css&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="c"&gt;/* app/javascript/packs/application.css */&lt;/span&gt;

&lt;span class="k"&gt;@import&lt;/span&gt; &lt;span class="s1"&gt;"../stylesheets/base.css"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;@import&lt;/span&gt; &lt;span class="s1"&gt;"../stylesheets/components.css"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;@import&lt;/span&gt; &lt;span class="s1"&gt;"../stylesheets/utilities.css"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Reload your browser and your styles should be applied now with Tailwind CSS, and the Webpacker loader error should be gone.&lt;/p&gt;

</description>
      <category>rails</category>
      <category>webpacker</category>
      <category>tailwindcss</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>Webpacker 6: SCSS/Sass Loaders</title>
      <dc:creator>Andrew Mason</dc:creator>
      <pubDate>Thu, 24 Dec 2020 16:11:26 +0000</pubDate>
      <link>https://dev.to/andrewmcodes/webpacker-6-scss-sass-loaders-37p3</link>
      <guid>https://dev.to/andrewmcodes/webpacker-6-scss-sass-loaders-37p3</guid>
      <description>&lt;p&gt;In order to process &lt;code&gt;.scss&lt;/code&gt; and &lt;code&gt;.sass&lt;/code&gt; files with Webpacker 6, you need to add &lt;a href="https://webpack.js.org/loaders/sass-loader/"&gt;sass-loader and sass&lt;/a&gt;.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Note: This section builds on the &lt;a href="https://andrewm.codes/blog/webpacker-6-css-loaders/"&gt;CSS section&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  Install
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;yarn add sass-loader sass
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Usage
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;You should be able to use the same pack tag that you added for CSS.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Make sure you restart &lt;code&gt;bin/webpack-dev-server&lt;/code&gt; after installing new loaders.&lt;/p&gt;

&lt;h3&gt;
  
  
  Style Loader Example
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight diff"&gt;&lt;code&gt;&lt;span class="gd"&gt;&amp;lt;%# app/views/layouts/application.html.erb %&amp;gt;
&lt;/span&gt;
+ &amp;lt;%= stylesheet_packs_with_chunks_tag 'application', media: 'all', 'data-turbolinks-track': 'reload' %&amp;gt;
&lt;span class="gd"&gt;&amp;lt;%= javascript_packs_with_chunks_tag 'application', 'data-turbolinks-track': 'reload' %&amp;gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Extract Example
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight diff"&gt;&lt;code&gt;&lt;span class="gd"&gt;&amp;lt;%# app/views/layouts/application.html.erb %&amp;gt;
&lt;/span&gt;
&amp;lt;%= javascript_packs_with_chunks_tag 'application', 'data-turbolinks-track': 'reload' %&amp;gt;
&lt;span class="gi"&gt;+ &amp;lt;%= stylesheet_pack_tag 'application', media: 'all', 'data-turbolinks-track': 'reload' %&amp;gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight diff"&gt;&lt;code&gt;&lt;span class="err"&gt;//&lt;/span&gt; app/javascript/packs/application.js

+ import "./application.scss"
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Verify
&lt;/h2&gt;

&lt;blockquote&gt;
&lt;p&gt;Note: Make sure you restart the dev server!&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Let’s create a new SCSS file:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;touch &lt;/span&gt;app/javascript/packs/application.scss
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Next, add some SCSS:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="c"&gt;/* app/javascript/packs/application.scss */&lt;/span&gt;

&lt;span class="err"&gt;$&lt;/span&gt;&lt;span class="nt"&gt;body-background&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="nf"&gt;#fafafa&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
&lt;span class="err"&gt;$&lt;/span&gt;&lt;span class="nt"&gt;body-color&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="err"&gt;#444&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;

&lt;span class="nt"&gt;body&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;background&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="err"&gt;$&lt;/span&gt;&lt;span class="n"&gt;body-background&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="err"&gt;$&lt;/span&gt;&lt;span class="n"&gt;body-color&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;font-family&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;sans-serif&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nt"&gt;h1&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt;
&lt;span class="nt"&gt;nav&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt;
&lt;span class="nt"&gt;footer&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;text-align&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;center&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nt"&gt;main&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;margin&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;4rem&lt;/span&gt; &lt;span class="nb"&gt;auto&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;max-width&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;60rem&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Reload your browser and your styles should be applied now, and the Webpacker loader error should be gone.&lt;/p&gt;

</description>
      <category>rails</category>
      <category>webpacker</category>
      <category>tutorial</category>
      <category>sass</category>
    </item>
    <item>
      <title>Webpacker 6: PostCSS Loaders</title>
      <dc:creator>Andrew Mason</dc:creator>
      <pubDate>Thu, 24 Dec 2020 16:11:06 +0000</pubDate>
      <link>https://dev.to/andrewmcodes/webpacker-6-postcss-loaders-4ajd</link>
      <guid>https://dev.to/andrewmcodes/webpacker-6-postcss-loaders-4ajd</guid>
      <description>&lt;p&gt;In order to process &lt;code&gt;.pcss&lt;/code&gt; files with Webpacker 6, you need to add &lt;a href="https://webpack.js.org/loaders/postcss-loader/"&gt;postcss-loader&lt;/a&gt;. I am also going to add PostCSS 8 support.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Note: This section builds on the CSS section&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  Install
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;yarn add postcss-loader postcss@latest autoprefixer@latest postcss-import@latest
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Add PostCSS Config File
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;touch &lt;/span&gt;postcss.config.js
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;// postcss.config.js

module.exports &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
  plugins: &lt;span class="o"&gt;[&lt;/span&gt;
    require&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'postcss-import'&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;,
    require&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'autoprefixer'&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;
  &lt;span class="o"&gt;]&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Usage
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;You should be able to use the same pack tag that you added for CSS.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Make sure you restart &lt;code&gt;bin/webpack-dev-server&lt;/code&gt; after installing new loaders.&lt;/p&gt;

&lt;h3&gt;
  
  
  Style Loader Example
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight diff"&gt;&lt;code&gt;&lt;span class="gd"&gt;&amp;lt;%# app/views/layouts/application.html.erb %&amp;gt;
&lt;/span&gt;
+ &amp;lt;%= stylesheet_packs_with_chunks_tag 'application', media: 'all', 'data-turbolinks-track': 'reload' %&amp;gt;
&lt;span class="gd"&gt;&amp;lt;%= javascript_packs_with_chunks_tag 'application', 'data-turbolinks-track': 'reload' %&amp;gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Extract Example
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight diff"&gt;&lt;code&gt;&lt;span class="gd"&gt;&amp;lt;%# app/views/layouts/application.html.erb %&amp;gt;
&lt;/span&gt;
&amp;lt;%= javascript_packs_with_chunks_tag 'application', 'data-turbolinks-track': 'reload' %&amp;gt;
&lt;span class="gi"&gt;+ &amp;lt;%= stylesheet_pack_tag 'application', media: 'all', 'data-turbolinks-track': 'reload' %&amp;gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight diff"&gt;&lt;code&gt;&lt;span class="err"&gt;//&lt;/span&gt; app/javascript/packs/application.js

+ import "./application.css"
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Verify
&lt;/h2&gt;

&lt;blockquote&gt;
&lt;p&gt;Note: Make sure you restart the dev server!&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Let’s create a new PostCSS file:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;mkdir &lt;/span&gt;app/javascript/stylesheets
&lt;span class="nb"&gt;touch &lt;/span&gt;app/javascript/stylesheets/base.pcss
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Next, add some CSS:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="c"&gt;/* app/javascript/stylesheets/base.pcss */&lt;/span&gt;

&lt;span class="nt"&gt;h1&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;font-size&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;2.2em&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;#2563eb&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nt"&gt;p&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;font-size&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;1.2em&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Lastly, update &lt;code&gt;application.css&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="c"&gt;/* app/javascript/packs/application.css */&lt;/span&gt;

&lt;span class="k"&gt;@import&lt;/span&gt; &lt;span class="s1"&gt;"../stylesheets/base.pcss"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Reload your browser and your styles should be applied now, and the Webpacker loader error should be gone.&lt;/p&gt;

</description>
      <category>rails</category>
      <category>webpacker</category>
      <category>tutorial</category>
      <category>postcss</category>
    </item>
    <item>
      <title>Webpacker 6: CSS Loaders</title>
      <dc:creator>Andrew Mason</dc:creator>
      <pubDate>Thu, 24 Dec 2020 16:10:53 +0000</pubDate>
      <link>https://dev.to/andrewmcodes/webpacker-6-css-loaders-28hb</link>
      <guid>https://dev.to/andrewmcodes/webpacker-6-css-loaders-28hb</guid>
      <description>&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;This page has changed since first posted&lt;/strong&gt;, refer to the changelog at the bottom.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;In order to process &lt;code&gt;.css&lt;/code&gt; files with Webpacker 6, you need to add &lt;a href="(https://webpack.js.org/loaders/css-loader/"&gt;css-loader&lt;/a&gt;, &lt;a href="https://webpack.js.org/loaders/style-loader/"&gt;style-loader&lt;/a&gt;, and &lt;a href="https://github.com/webpack-contrib/mini-css-extract-plugin"&gt;mini-css-extract-plugin&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Install
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;yarn add css-loader style-loader mini-css-extract-plugin
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Usage
&lt;/h2&gt;

&lt;p&gt;Add a &lt;code&gt;stylesheet_packs_with_chunks_tag&lt;/code&gt; or &lt;code&gt;stylesheet_pack_tag&lt;/code&gt; to the document head.&lt;/p&gt;

&lt;p&gt;Make sure you restart &lt;code&gt;bin/webpack-dev-server&lt;/code&gt; after installing new loaders.&lt;/p&gt;

&lt;h3&gt;
  
  
  Style Loader Example
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight diff"&gt;&lt;code&gt;&lt;span class="gd"&gt;&amp;lt;%# app/views/layouts/application.html.erb %&amp;gt;
&lt;/span&gt;
+ &amp;lt;%= stylesheet_packs_with_chunks_tag 'application', media: 'all', 'data-turbolinks-track': 'reload' %&amp;gt;
&lt;span class="gd"&gt;&amp;lt;%= javascript_packs_with_chunks_tag 'application', 'data-turbolinks-track': 'reload' %&amp;gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Extract Example
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight diff"&gt;&lt;code&gt;&lt;span class="gd"&gt;&amp;lt;%# app/views/layouts/application.html.erb %&amp;gt;
&lt;/span&gt;
&amp;lt;%= javascript_packs_with_chunks_tag 'application', 'data-turbolinks-track': 'reload' %&amp;gt;
&lt;span class="gi"&gt;+ &amp;lt;%= stylesheet_pack_tag 'application', media: 'all', 'data-turbolinks-track': 'reload' %&amp;gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight diff"&gt;&lt;code&gt;&lt;span class="err"&gt;//&lt;/span&gt; app/javascript/packs/application.js

+ import "./application.css"
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Verify
&lt;/h2&gt;

&lt;blockquote&gt;
&lt;p&gt;Note: Make sure you restart the dev server!&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Let’s create a new file for our CSS:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight diff"&gt;&lt;code&gt;&lt;span class="p"&gt;touch app/javascript/packs/application.css
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Next, add some CSS:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="c"&gt;/* app/javascript/packs/application.css */&lt;/span&gt;

&lt;span class="nt"&gt;h1&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;font-size&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;2.2em&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;#2563eb&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nt"&gt;p&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;font-size&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;1.2em&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Reload your browser and your styles should be applied now, and the Webpacker loader error should be gone.&lt;/p&gt;

&lt;h2&gt;
  
  
  Changelog
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://github.com/andrewmcodes/andrewm-codes-website/pull/12/commits/6b50b3e1a08236a09cd836c97066ddd4e3b76eed"&gt;chore: add css-minimizer-webpack-plugin&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>rails</category>
      <category>webpacker</category>
      <category>tutorial</category>
      <category>css</category>
    </item>
    <item>
      <title>Webpacker 6: Upgrade Guide</title>
      <dc:creator>Andrew Mason</dc:creator>
      <pubDate>Thu, 24 Dec 2020 16:10:35 +0000</pubDate>
      <link>https://dev.to/andrewmcodes/webpacker-6-upgrade-guide-3p6d</link>
      <guid>https://dev.to/andrewmcodes/webpacker-6-upgrade-guide-3p6d</guid>
      <description>&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;This page has changed since first posted&lt;/strong&gt;, refer to the changelog at the bottom.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;In this article, we will walkthrough how to upgrade to the latest version of &lt;a href="https://github.com/rails/webpacker/releases"&gt;Webpacker&lt;/a&gt;, which is, at the time of writing,  &lt;code&gt;6.0.0.beta.2&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Our upgrade process will begin with updating the Webpacker libraries, then we will update our configs and templates, and end up verifying that our new setup is working.&lt;/p&gt;

&lt;p&gt;Let’s get started!&lt;/p&gt;

&lt;h2&gt;
  
  
  Updating our &lt;code&gt;Gemfile&lt;/code&gt;
&lt;/h2&gt;

&lt;p&gt;Update the gem in your &lt;code&gt;Gemfile&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight diff"&gt;&lt;code&gt;&lt;span class="err"&gt;#&lt;/span&gt; Gemfile

- gem 'webpacker', '~&amp;gt; 5.0'
&lt;span class="gi"&gt;+ gem 'webpacker', '~&amp;gt; 6.0.0.beta.2'
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Next, run &lt;code&gt;bundle install&lt;/code&gt; to install the new gem version. If all goes well, you should see &lt;code&gt;Using webpacker 6.0.0.beta.2 (was 5.2.1)&lt;/code&gt; in the install output.&lt;/p&gt;

&lt;h2&gt;
  
  
  Installing in our Application
&lt;/h2&gt;

&lt;p&gt;Run the installation command, &lt;code&gt;bin/rails webpacker:install&lt;/code&gt;, to generate the required configuration files, as well as update our &lt;code&gt;package.json&lt;/code&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Update Document Head
&lt;/h2&gt;

&lt;p&gt;Lastly, let's update &lt;code&gt;app/views/layouts/application.html.erb&lt;/code&gt;. The docs for Webpacker v6 recommend using the &lt;code&gt;javascript_packs_with_chunks_tag&lt;/code&gt; tag.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight diff"&gt;&lt;code&gt;&lt;span class="gd"&gt;&amp;lt;%# app/views/layouts/application.html.erb %&amp;gt;
&lt;/span&gt;
- &amp;lt;%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track': 'reload' %&amp;gt;
&lt;span class="gd"&gt;- &amp;lt;%= javascript_pack_tag 'application', 'data-turbolinks-track': 'reload' %&amp;gt;
&lt;/span&gt;&lt;span class="gi"&gt;+ &amp;lt;%= javascript_packs_with_chunks_tag 'application', 'data-turbolinks-track': 'reload' %&amp;gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Verify Installation
&lt;/h2&gt;

&lt;p&gt;Run the Rails server (&lt;code&gt;bin/rails s&lt;/code&gt;) and the Webpack Dev Server (&lt;code&gt;bin/webpack-dev-server&lt;/code&gt;) via your preferred method. Two terminal tabs will work or create a &lt;a href="https://devcenter.heroku.com/articles/procfile"&gt;Procfile&lt;/a&gt; and run via &lt;a href="https://github.com/DarthSim/overmind"&gt;overmind&lt;/a&gt; or &lt;a href="https://github.com/ddollar/foreman"&gt;foreman&lt;/a&gt;. The Rails server will also compile your assets if the dev server is not running, but this is much slower vs running separate processes and not recommended.&lt;/p&gt;

&lt;p&gt;Visit &lt;code&gt;http://localhost:3000&lt;/code&gt; in your browser. If all's well, you should see the contents of &lt;code&gt;app/views/pages/home.html.erb&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;We can verify our JavaScript is getting loaded by adding the following to &lt;code&gt;app/javascript/packs/application.js&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// app/javascript/packs/application.js&lt;/span&gt;

&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Hello from Webpacker!&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Open the browser console and reload the page and you should see the message we added:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;Log&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="nx"&gt;Hello&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="nx"&gt;Webpacker&lt;/span&gt;&lt;span class="o"&gt;!&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;application&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mi"&gt;7&lt;/span&gt;&lt;span class="nx"&gt;fbebc85af7886af0a64&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;js&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;line&lt;/span&gt; &lt;span class="mi"&gt;62&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Summary
&lt;/h2&gt;

&lt;p&gt;Congrats! You’re up and running with Webpacker 6!&lt;/p&gt;

&lt;p&gt;Unfortunately you will quickly realize that your upgrade is not finished if you begin developing like you usually would with Webpacker.&lt;/p&gt;

&lt;p&gt;Webpacker 6 requires you to add the &lt;a href="https://webpack.js.org/loaders/"&gt;appropriate Webpack loaders&lt;/a&gt; yourself, which is a breaking change from previous versions.&lt;/p&gt;

&lt;p&gt;We will tackle that &lt;a href="https://andrewm.codes/posts/webpacker-6/css-loaders/"&gt;in the next article!&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Changelog
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://github.com/andrewmcodes/andrewm-codes-website/pull/11"&gt;feat: updates for webpacker v6.0.0.beta.2&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>rails</category>
      <category>ruby</category>
      <category>webpacker</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>Webpacker 6: Tutorial Setup</title>
      <dc:creator>Andrew Mason</dc:creator>
      <pubDate>Thu, 24 Dec 2020 16:10:21 +0000</pubDate>
      <link>https://dev.to/andrewmcodes/webpacker-6-tutorial-setup-281k</link>
      <guid>https://dev.to/andrewmcodes/webpacker-6-tutorial-setup-281k</guid>
      <description>&lt;p&gt;Before we start the upgrade process for Webpacker 6, we are going to create a small demo application for us to work on. &lt;/p&gt;

&lt;p&gt;If you are upgrading an existing app or not using this series as a tutorial, you can skip this step! We will begin the formal upgrade process in the next article.&lt;/p&gt;

&lt;h2&gt;
  
  
  Generate a new Rails app
&lt;/h2&gt;

&lt;p&gt;First we will generate new Ruby on Rails app:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;rails new webpacker_6 &lt;span class="nt"&gt;--skip-sprockets&lt;/span&gt; &lt;span class="nt"&gt;--skip-spring&lt;/span&gt; &lt;span class="nt"&gt;--skip-webpack-install&lt;/span&gt; &lt;span class="nt"&gt;--skip-bundle&lt;/span&gt;
&lt;span class="nb"&gt;cd &lt;/span&gt;webpacker_6
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;--skip-sprockets&lt;/code&gt;: Skip Sprockets files&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;--skip-spring&lt;/code&gt;: Don't install Spring application preloader&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;--skip-bundle&lt;/code&gt;: Don't run bundle install&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;--skip-webpack-install&lt;/code&gt;: Don't run Webpack install&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Setup the Database
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;bin/rails db:prepare
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Turn off asset scaffolding
&lt;/h3&gt;

&lt;p&gt;Prevent Rails from creating asset files when running the generators and scaffolds:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight diff"&gt;&lt;code&gt;&lt;span class="err"&gt;#&lt;/span&gt; config/application.rb

# ...
&lt;span class="p"&gt;module Webpacker6
&lt;/span&gt;  class Application &amp;lt; Rails::Application
    config.load_defaults 6.1
&lt;span class="gi"&gt;+    config.generators do |g|
+      g.assets false
+    end
&lt;/span&gt;  end
&lt;span class="p"&gt;end
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Add Pages Controller
&lt;/h2&gt;

&lt;p&gt;Generate pages controller with a home action:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;bin/rails g controller pages home
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Add Root Route
&lt;/h2&gt;

&lt;p&gt;Set &lt;code&gt;pages#home&lt;/code&gt; as the root route:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight diff"&gt;&lt;code&gt;&lt;span class="err"&gt;#&lt;/span&gt; config/routes.rb

Rails.application.routes.draw do
  get 'pages/home'
&lt;span class="gi"&gt;+  root to: 'pages#home'
&lt;/span&gt;  # For details on the DSL available within this file, see https://guides.rubyonrails.org/routing.html
&lt;span class="p"&gt;end
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;blockquote&gt;
&lt;p&gt;Note: Because we skipped the Webpacker install task, you will get an error if you try to start the application as is. We will fix that in the next article.&lt;/p&gt;
&lt;/blockquote&gt;

</description>
      <category>rails</category>
      <category>ruby</category>
      <category>tutorial</category>
      <category>webpacker</category>
    </item>
    <item>
      <title>gem install mysql2</title>
      <dc:creator>Andrew Mason</dc:creator>
      <pubDate>Fri, 11 Dec 2020 12:20:02 +0000</pubDate>
      <link>https://dev.to/andrewmcodes/gem-install-mysql2-6o1</link>
      <guid>https://dev.to/andrewmcodes/gem-install-mysql2-6o1</guid>
      <description>&lt;p&gt;I've come across this error several times throughout my development career so I figured it was finally time to write it down.&lt;/p&gt;

&lt;h2&gt;
  
  
  Scenario
&lt;/h2&gt;

&lt;p&gt;Whenever I try to install certain versions of the &lt;code&gt;mysql2&lt;/code&gt; gem in a Ruby on Rails application, I get the following error:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Gem::Ext::BuildError: ERROR: Failed to build gem native extension
...
make "DESTDIR="
compiling client.c
compiling infile.c
compiling mysql2_ext.c
compiling result.c
compiling statement.c
linking shared-object mysql2/mysql2.bundle
ld: library not found for -lssl
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [mysql2.bundle] Error 1

make failed, exit code 2

An error occurred while installing mysql2 (0.5.2), and Bundler cannot continue.
Make sure that `gem install mysql2 -v '0.5.2'` succeeds before bundling.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Solution
&lt;/h2&gt;

&lt;p&gt;In order to fix this issue on macOS, first make sure that you have &lt;code&gt;cmake&lt;/code&gt; installed.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;brew &lt;span class="nb"&gt;install &lt;/span&gt;cmake
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then you can install the gem via the following command:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;gem &lt;span class="nb"&gt;install &lt;/span&gt;mysql2 &lt;span class="nt"&gt;-v&lt;/span&gt; &lt;span class="s1"&gt;'0.5.2'&lt;/span&gt; &lt;span class="nt"&gt;--&lt;/span&gt; &lt;span class="nt"&gt;--with-ldflags&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nt"&gt;-L&lt;/span&gt;/usr/local/opt/openssl/lib &lt;span class="nt"&gt;--with-cppflags&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nt"&gt;-I&lt;/span&gt;/usr/local/opt/openssl/include
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Hope this helps save someone some time!&lt;/p&gt;

</description>
      <category>ruby</category>
      <category>rails</category>
      <category>mysql</category>
      <category>gem</category>
    </item>
  </channel>
</rss>
