<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="pt-BR">
  <generator uri="https://bridgetownrb.com/" version="2.2.2">Bridgetown</generator>
  <link href="https://blog.albertorocha.me/pt/feed.xml" rel="self" type="application/atom+xml" />
  <link href="https://blog.albertorocha.me/pt/" rel="alternate" type="text/html" hreflang="pt" />
  <updated>2026-11-29T00:25:12+00:00</updated>
  <id>https://blog.albertorocha.me/pt/feed.xml</id>
  <title type="html">Reflections &amp;amp; Refactors</title>
  <subtitle>Um diário de aventuras sobre software, ofício e IA.</subtitle>
  <author>
    <name>Alberto Rocha</name>
  </author>
    <entry>
      <title type="html">Por que eu não fiz o meu blog do zero</title>
      <link href="https://blog.albertorocha.me/pt/posts/revamping-the-blog" rel="alternate" type="text/html" title="Por que eu não fiz o meu blog do zero" />
      <published>2026-11-28T00:00:00+00:00</published>
      <updated>2026-11-28T00:00:00+00:00</updated>
      <id>repo://posts.collection/_posts/2026-11-28-revamping-the-blog.pt.md</id>
      <content type="html" xml:base="https://blog.albertorocha.me/pt/posts/revamping-the-blog">&lt;p&gt;Já havia um bom tempo que eu queria atualizar o &lt;a href=&quot;https://blog.albertorocha.me&quot; target=&quot;_blank&quot;&gt;meu blog&lt;/a&gt;, mas nunca tinha tempo. Ele era um site &lt;a href=&quot;https://jekyllrb.com&quot; target=&quot;_blank&quot;&gt;Jekyll&lt;/a&gt; hospedado no &lt;a href=&quot;https://pages.github.com&quot; target=&quot;_blank&quot;&gt;GitHub Pages&lt;/a&gt;, com o tema &lt;a href=&quot;https://github.com/nielsenramon/chalk&quot; target=&quot;_blank&quot;&gt;Chalk&lt;/a&gt;, e estava parado desde 2024. Nesse meio tempo eu não parei de escrever: comecei a publicar no &lt;a href=&quot;https://albertogr.substack.com&quot; target=&quot;_blank&quot;&gt;Substack&lt;/a&gt;, primeiro alguns ensaios sobre IA, depois uma série sobre Ruby que ainda não terminei. Pra só escrever, o Substack já bastava. Então por que voltar a mexer num blog?&lt;/p&gt;

&lt;p&gt;Neste texto eu não quero falar só das tecnologias que escolhi, e sim de como cheguei nelas. A conversa que tive com a IA no caminho me fez repensar as minhas prioridades, e acho que isso vale pra além de um blog.&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;https://www.ruby-lang.org/pt/&quot; target=&quot;_blank&quot;&gt;Ruby&lt;/a&gt; sempre foi a minha linguagem favorita. Mesmo hoje, quando a IA escreve boa parte do código, ela continua muito relevante pra mim pela facilidade de leitura e de expressão. E acredito que também tenha um certo valor sentimental. Então, quando decidi atualizar o blog, a única certeza era essa: seria em Ruby.&lt;/p&gt;

&lt;p&gt;A partir daí a tentação apareceu rápido. Por que não fazer um blog do zero? Talvez em Ruby puro, talvez em &lt;a href=&quot;https://rubyonrails.org&quot; target=&quot;_blank&quot;&gt;Rails&lt;/a&gt; (o meu levaria mais de &lt;a href=&quot;https://rubyonrails.org/2005/7/8/new-rails-movie-with-sound-and-sugar&quot; target=&quot;_blank&quot;&gt;15 minutos&lt;/a&gt; pra fazer). Como engenheiro, ter uma aplicação real pra praticar é muito interessante, e eu sempre gostei de pet projects. Ao mesmo tempo que eu teria uma plataforma pra escrever, teria um projeto pra brincar e fazer experimentos. E com IA, construir do zero nunca foi tão barato. Parecia o cenário ideal, não?&lt;/p&gt;

&lt;h2 id=&quot;a-conversa&quot;&gt;A conversa&lt;/h2&gt;

&lt;p&gt;Levei a dúvida pra IA, e o que aconteceu foi curioso: a cada coisa que eu contava, a recomendação mudava. Quando a pergunta era só se o Jekyll ainda valia a pena, a sugestão foi atualizar e seguir com ele. Quando contei que gostava de Ruby e queria programar o blog em Ruby, a sugestão virou o &lt;a href=&quot;https://www.bridgetownrb.com&quot; target=&quot;_blank&quot;&gt;Bridgetown&lt;/a&gt;, um gerador que nasceu como fork do Jekyll e deixa escrever templates, componentes e configuração em Ruby. Quando eu mesmo puxei a conversa pra fazer do zero, porque como engenheiro queria o blog como algo mais que um lugar pra escrever, ela concordou que era a opção mais coerente.&lt;/p&gt;

&lt;p&gt;Repare que nenhuma opção nova apareceu nesse meio tempo. Quem estava mudando era eu, conforme explicava melhor o que queria.&lt;/p&gt;

&lt;p&gt;No meio disso vieram as perguntas que me fizeram parar. Eu queria um lugar pra escrever ou um playground? O que significava, pra mim, ser “mais que um lugar pra escrever”? E veio também um alerta: o risco de fazer do zero era o blog virar o projeto e os posts pararem de sair. Concordei na hora.&lt;/p&gt;

&lt;h2 id=&quot;o-que-eu-queria-de-verdade&quot;&gt;O que eu queria de verdade&lt;/h2&gt;

&lt;p&gt;Construir o blog do zero não era o meu objetivo. O que eu queria era voltar a ter um lugar só meu, e o quanto antes. Um endereço que é meu, onde os textos técnicos de anos atrás e os do Substack ficam juntos, com o código à mão pra mexer quando der vontade.&lt;/p&gt;

&lt;p&gt;E ser meu não quer dizer ser feito por mim. O tempo que eu tenho pro blog é curto, e prefiro usar esse tempo pra escrever, não pra manter um gerador de sites. Mesmo com a ajuda da IA, ainda precisamos tomar várias decisões. No caso de um blog do zero, seria escrever tudo o que já existe em outras plataformas: feed, sitemap, paginação, tags, as informações que aparecem quando alguém compartilha um link. O que faz o blog ser meu é o domínio, os textos e poder mudar o que eu quiser.&lt;/p&gt;

&lt;p&gt;Isso também não quer dizer largar o Substack. É lá que estão os leitores e a newsletter, e os mesmos textos vão estar nos dois lugares, mas a casa é o blog. Existe até um nome pra isso na comunidade IndieWeb: &lt;a href=&quot;https://indieweb.org/POSSE&quot; target=&quot;_blank&quot;&gt;POSSE&lt;/a&gt;, de &lt;em&gt;Publish on your Own Site, Syndicate Elsewhere&lt;/em&gt;, ou seja, publicar no seu próprio site e distribuir pros outros lugares a partir dele.&lt;/p&gt;

&lt;p&gt;A vontade de ter um projeto pra brincar também não era falsa. As duas coisas eram verdade, e a decisão foi a ordem entre elas: primeiro o lugar, e o projeto caseiro fica pra quando fizer sentido.&lt;/p&gt;

&lt;p&gt;Com as necessidades claras, as escolhas quase se fizeram sozinhas. Fiquei com o Bridgetown, porque com ele o código do blog é Ruby e eu não preciso manter tudo sozinho, e os posts continuam sendo arquivos Markdown que vão pra qualquer lugar se um dia eu quiser trocar. Mantive o visual do Chalk, porque eu gostava dele, e a regra foi só trocar o site quando o novo estivesse igual ao antigo, com todos os links de anos atrás funcionando. E saí do GitHub Pages pro &lt;a href=&quot;https://developers.cloudflare.com/workers/static-assets/&quot; target=&quot;_blank&quot;&gt;Cloudflare Workers&lt;/a&gt;, que também é gratuito e tem um recurso de preview muito útil pra blogs: cada mudança ganha um link, e com o mesmo link eu vejo o post tanto no desktop quanto no celular antes de publicar.&lt;/p&gt;

&lt;p&gt;Só depois que a base estava de pé é que vieram as novidades: um nome novo, um visual com cara de livro, uma versão em português. Mas isso fica pra outro texto.&lt;/p&gt;

&lt;h2 id=&quot;pra-além-do-blog&quot;&gt;Pra além do blog&lt;/h2&gt;

&lt;p&gt;Nada disso é novidade, e é algo em que eu acredito muito. Gosto da imagem de subir nos ombros de gigantes: frameworks e bibliotecas são isso pra mim, anos de decisões, correções e casos estranhos que muita gente já resolveu. Com IA, tem quem diga que dá pra gerar tudo e dispensar frameworks e bibliotecas. Eu continuo achando que eles são necessários. O que mudou é que construir do zero ficou muito mais fácil, e isso é uma tentação. Fica fácil sair construindo antes de saber direito do que precisamos. A IA responde o que perguntamos, e a qualidade da escolha depende de quão bem a necessidade está definida.&lt;/p&gt;

&lt;p&gt;E isso não vale só pra projeto pessoal. Times inteiros podem cair na mesma armadilha: com IA, começar algo novo parece rápido, e a conta da manutenção só chega depois. Antes de escolher uma tecnologia, vale parar, definir o que se precisa de verdade e deixar isso guiar a escolha.&lt;/p&gt;

&lt;p&gt;Quanto ao blog, um dia essa decisão pode mudar e talvez eu faça a minha própria plataforma. Essa possibilidade sempre vai existir.&lt;/p&gt;</content>
      <author>
        <name>Alberto Rocha</name>
      </author>
        <category term="ai" />
        <category term="ruby" />
        <category term="bridgetown" />
    </entry>
    <entry>
      <title type="html">Publicando gems Ruby com GitHub Actions</title>
      <link href="https://blog.albertorocha.me/pt/posts/publishing-ruby-gems-with-github-actions" rel="alternate" type="text/html" title="Publicando gems Ruby com GitHub Actions" />
      <published>2024-09-01T00:00:00+00:00</published>
      <updated>2026-11-28T00:00:00+00:00</updated>
      <id>repo://posts.collection/_posts/2024-09-01-publishing-ruby-gems-with-github-actions.pt.md</id>
      <content type="html" xml:base="https://blog.albertorocha.me/pt/posts/publishing-ruby-gems-with-github-actions">&lt;p&gt;Neste post, vou mostrar como usar o GitHub Actions pra automatizar a publicação de gems sempre que uma nova versão é criada.&lt;/p&gt;

&lt;h3 id=&quot;criação-e-publicação-de-gems&quot;&gt;Criação e publicação de gems&lt;/h3&gt;

&lt;p&gt;Em Ruby, bibliotecas de código são chamadas de gems. Elas podem ser encontradas e instaladas a partir de um repositório público chamado &lt;a href=&quot;https://rubygems.org/&quot; target=&quot;_blank&quot;&gt;RubyGems&lt;/a&gt;, o principal serviço de hospedagem e gestão de gems da comunidade Ruby.&lt;/p&gt;

&lt;p&gt;Pra criar uma nova gem, você pode usar o comando &lt;code class=&quot;highlighter-rouge&quot;&gt;bundle gem&lt;/code&gt;, que vem com a gem &lt;code class=&quot;highlighter-rouge&quot;&gt;bundler&lt;/code&gt;.&lt;/p&gt;

&lt;div class=&quot;language-shell highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;bundle gem my_gem
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Esse comando gera os arquivos e diretórios necessários pra gem.&lt;/p&gt;

&lt;div class=&quot;language-shell highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;my_gem
├── Gemfile
├── README.md
├── Rakefile
├── lib
│   ├── my_gem
│   │   └── version.rb
│   └── my_gem.rb
├── my_gem.gemspec
└── spec
    ├── my_gem_spec.rb
    └── spec_helper.rb
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Quando a gem estiver pronta, é só rodar o &lt;code class=&quot;highlighter-rouge&quot;&gt;gem build&lt;/code&gt;, que cria um arquivo &lt;code class=&quot;highlighter-rouge&quot;&gt;.gem&lt;/code&gt; pronto pra ser publicado no RubyGems.&lt;/p&gt;

&lt;div class=&quot;language-shell highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;gem build my_gem.gemspec
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Depois de gerar a gem, é só publicar no RubyGems com o comando &lt;code class=&quot;highlighter-rouge&quot;&gt;gem push&lt;/code&gt;.&lt;/p&gt;

&lt;div class=&quot;language-shell highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;gem push my_gem-0.1.0.gem
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Obs.: é preciso ter uma conta no RubyGems e estar autenticado pra publicar gems.&lt;/p&gt;

&lt;h3 id=&quot;github-actions&quot;&gt;GitHub Actions&lt;/h3&gt;

&lt;p&gt;Assim como outras ferramentas de CI/CD, o GitHub Actions permite automatizar tarefas como testes, lint e deploys. A configuração fica em arquivos YAML que definem quais processos serão executados, disparados por eventos específicos, como um commit em determinada branch.&lt;/p&gt;

&lt;p&gt;O exemplo abaixo mostra um workflow simples do GitHub Actions que roda os testes de uma aplicação Ruby sempre que um novo commit é enviado pra branch &lt;code class=&quot;highlighter-rouge&quot;&gt;main&lt;/code&gt;:&lt;/p&gt;

&lt;div class=&quot;language-yaml highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;na&quot;&gt;name&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;RSpec tests&lt;/span&gt;

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

&lt;span class=&quot;na&quot;&gt;jobs&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
  &lt;span class=&quot;na&quot;&gt;test&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
    &lt;span class=&quot;na&quot;&gt;runs-on&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;ubuntu-latest&lt;/span&gt;

    &lt;span class=&quot;na&quot;&gt;steps&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
    &lt;span class=&quot;pi&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;name&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;Checkout code&lt;/span&gt;
      &lt;span class=&quot;na&quot;&gt;uses&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;actions/checkout@v2&lt;/span&gt;

    &lt;span class=&quot;pi&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;name&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;Set up Ruby&lt;/span&gt;
      &lt;span class=&quot;na&quot;&gt;uses&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;actions/setup-ruby@v1&lt;/span&gt;
      &lt;span class=&quot;na&quot;&gt;with&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
        &lt;span class=&quot;na&quot;&gt;ruby-version&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;&#39;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;3.4&#39;&lt;/span&gt;

    &lt;span class=&quot;pi&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;name&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;Install dependencies&lt;/span&gt;
      &lt;span class=&quot;na&quot;&gt;run&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;bundle install&lt;/span&gt;

    &lt;span class=&quot;pi&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;name&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;Run tests&lt;/span&gt;
      &lt;span class=&quot;na&quot;&gt;run&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;bundle exec rspec&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h3 id=&quot;versionamento-de-gems-e-manutenção-do-changelog&quot;&gt;Versionamento de gems e manutenção do changelog&lt;/h3&gt;

&lt;p&gt;Quando estamos satisfeitos com o código da gem e queremos lançar uma nova versão, precisamos seguir algumas práticas pra garantir que a gem fique corretamente versionada e documentada.&lt;/p&gt;

&lt;p&gt;Vamos usar como exemplo a gem &lt;a href=&quot;https://github.com/betogrun/lean-microsoft-graph&quot; target=&quot;_blank&quot;&gt;lean-microsoft-graph&lt;/a&gt;, em que uma nova funcionalidade foi adicionada e algumas dependências foram atualizadas neste &lt;a href=&quot;https://github.com/betogrun/lean-microsoft-graph/pull/58&quot; target=&quot;_blank&quot;&gt;Pull Request&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Depois do merge do código, podemos criar um novo Pull Request alterando o número da versão e atualizando o arquivo &lt;code class=&quot;highlighter-rouge&quot;&gt;CHANGELOG.md&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Antes de continuar, vale mencionar as diretrizes do &lt;a href=&quot;https://semver.org/lang/pt-BR/&quot; target=&quot;_blank&quot;&gt;Versionamento Semântico&lt;/a&gt;, que seguem o formato &lt;code class=&quot;highlighter-rouge&quot;&gt;MAJOR.MINOR.PATCH&lt;/code&gt;.&lt;/p&gt;

&lt;h6 id=&quot;o-número-da-versão-é-incrementado-de-acordo-com-o-tipo-de-mudança&quot;&gt;O número da versão é incrementado de acordo com o tipo de mudança:&lt;/h6&gt;
&lt;ul&gt;
  &lt;li&gt;&lt;strong&gt;Major&lt;/strong&gt;: pra mudanças incompatíveis na API&lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;Minor&lt;/strong&gt;: pra novas funcionalidades compatíveis com versões anteriores&lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;Patch&lt;/strong&gt;: pra correções de bugs compatíveis com versões anteriores&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;O arquivo de versão fica em &lt;code class=&quot;highlighter-rouge&quot;&gt;lib/lean/microsoft/graph/version.rb&lt;/code&gt;. Uma funcionalidade nova sem quebra de compatibilidade pede um bump de minor, o que daria &lt;code class=&quot;highlighter-rouge&quot;&gt;0.4.0&lt;/code&gt;; esta versão saiu como patch, &lt;code class=&quot;highlighter-rouge&quot;&gt;0.3.4&lt;/code&gt;, e é essa que vamos usar daqui pra frente.&lt;/p&gt;

&lt;div class=&quot;language-ruby highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;k&quot;&gt;module&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;LeanMicrosoftGraph&lt;/span&gt;
  &lt;span class=&quot;no&quot;&gt;VERSION&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;0.3.4&quot;&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;end&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Agora precisamos atualizar o arquivo &lt;code class=&quot;highlighter-rouge&quot;&gt;CHANGELOG.md&lt;/code&gt; com as mudanças da nova versão.&lt;/p&gt;

&lt;div class=&quot;language-markdown highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;gh&quot;&gt;# Changelog&lt;/span&gt;

&lt;span class=&quot;c&quot;&gt;&amp;lt;!-- Additional logs omitted for brevity. --&amp;gt;&lt;/span&gt;

&lt;span class=&quot;gu&quot;&gt;## [0.3.4] - 2024-08-30&lt;/span&gt;

&lt;span class=&quot;gu&quot;&gt;### Added&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;
-&lt;/span&gt; Ability to retrieve users by id with &lt;span class=&quot;sb&quot;&gt;`client.users.get_by_id(&#39;id&#39;)`&lt;/span&gt;.

&lt;span class=&quot;gu&quot;&gt;### Changed&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;
-&lt;/span&gt; Upgrade dependencies: faraday, mocha and minitest.

&lt;span class=&quot;c&quot;&gt;&amp;lt;!-- Additional logs omitted for brevity. --&amp;gt;&lt;/span&gt;

&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;ss&quot;&gt;0.3.4&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]:&lt;/span&gt; &lt;span class=&quot;sx&quot;&gt;https://github.com/betogrun/lean-microsoft-graph/releases/tag/v0.3.4&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Dê uma olhada no site &lt;a href=&quot;https://keepachangelog.com/pt-BR/&quot; target=&quot;_blank&quot;&gt;Keep a Changelog&lt;/a&gt; pra saber mais sobre como documentar as mudanças no arquivo &lt;code class=&quot;highlighter-rouge&quot;&gt;CHANGELOG.md&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;A essa altura, já daria pra gerar e publicar a gem manualmente, mas a ideia é automatizar esse processo com o GitHub Actions.&lt;/p&gt;

&lt;h3 id=&quot;configuração-do-github-actions-pra-publicar-gems&quot;&gt;Configuração do GitHub Actions pra publicar gems&lt;/h3&gt;

&lt;p&gt;Pra automatizar o processo, precisamos criar um workflow do GitHub, que é um arquivo YAML no diretório .github/workflows. Se ele ainda não existir, dá pra criar o arquivo manualmente ou deixar o GitHub gerar um inicial. No caso da gem &lt;a href=&quot;https://github.com/betogrun/lean-microsoft-graph&quot; target=&quot;_blank&quot;&gt;lean-microsoft-graph&lt;/a&gt;, já havia um arquivo ruby.yml responsável por rodar os testes unitários, como mostra este &lt;a href=&quot;https://github.com/betogrun/lean-microsoft-graph/pull/19/files&quot; target=&quot;_blank&quot;&gt;Pull Request&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;O GitHub Actions vai precisar de um token de autenticação pra publicar a gem no RubyGems. Esse token deve ser guardado nos secrets do repositório e passado ao workflow como variável de ambiente. O token pode ser obtido no site do RubyGems.&lt;/p&gt;

&lt;h6 id=&quot;siga-estes-passos-pra-adicionar-o-token-aos-secrets-do-repositório&quot;&gt;Siga estes passos pra adicionar o token aos secrets do repositório:&lt;/h6&gt;
&lt;ol&gt;
  &lt;li&gt;Abra &lt;code class=&quot;highlighter-rouge&quot;&gt;Settings&lt;/code&gt; no repositório.&lt;/li&gt;
  &lt;li&gt;Navegue até &lt;code class=&quot;highlighter-rouge&quot;&gt;Secrets and variables&lt;/code&gt; e clique em &lt;code class=&quot;highlighter-rouge&quot;&gt;Actions&lt;/code&gt;.&lt;/li&gt;
  &lt;li&gt;Clique em &lt;code class=&quot;highlighter-rouge&quot;&gt;New repository secret&lt;/code&gt;.&lt;/li&gt;
  &lt;li&gt;Dê ao secret o nome RUBYGEMS_AUTH_TOKEN, cole o token obtido e clique em &lt;code class=&quot;highlighter-rouge&quot;&gt;Add Secret&lt;/code&gt;.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Agora precisamos adicionar ao arquivo YAML um novo job com os steps de publicação.
Também daria pra fazer isso em um workflow separado, mas aqui vamos usar o arquivo que já existe.&lt;/p&gt;

&lt;p&gt;O novo job se chama &lt;code class=&quot;highlighter-rouge&quot;&gt;publish&lt;/code&gt;:&lt;/p&gt;

&lt;div class=&quot;language-yaml highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;na&quot;&gt;jobs&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
  &lt;span class=&quot;na&quot;&gt;publish&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
    &lt;span class=&quot;na&quot;&gt;needs&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;test&lt;/span&gt;
    &lt;span class=&quot;na&quot;&gt;runs-on&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;ubuntu-latest&lt;/span&gt;
    &lt;span class=&quot;na&quot;&gt;if&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;startsWith(github.ref, &#39;refs/tags/v&#39;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h6 id=&quot;no-exemplo-acima-nós&quot;&gt;No exemplo acima, nós:&lt;/h6&gt;
&lt;ul&gt;
  &lt;li&gt;Adicionamos a palavra-chave &lt;code class=&quot;highlighter-rouge&quot;&gt;needs&lt;/code&gt; pra indicar que o job de publicação deve esperar o job de testes terminar com sucesso antes de rodar. Isso cria uma dependência que garante que os testes sejam executados primeiro.&lt;/li&gt;
  &lt;li&gt;Definimos o ambiente em que o job vai rodar. Neste exemplo, o job roda na versão mais recente do Ubuntu.&lt;/li&gt;
  &lt;li&gt;Incluímos uma condição no job pra garantir que ele só rode quando uma nova tag que comece com &lt;code class=&quot;highlighter-rouge&quot;&gt;v&lt;/code&gt; for criada, indicando o lançamento de uma versão.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Agora precisamos do step que prepara o ambiente. Neste exemplo, configuramos o Ruby e escolhemos a versão:&lt;/p&gt;

&lt;div class=&quot;language-yaml highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;  &lt;span class=&quot;na&quot;&gt;steps&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
    &lt;span class=&quot;pi&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;uses&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;actions/checkout@v3&lt;/span&gt;  &lt;span class=&quot;c1&quot;&gt;# Check out the repository code&lt;/span&gt;

    &lt;span class=&quot;pi&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;name&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;Set up Ruby&lt;/span&gt;
      &lt;span class=&quot;na&quot;&gt;uses&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;ruby/setup-ruby@v1&lt;/span&gt;
      &lt;span class=&quot;na&quot;&gt;with&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
        &lt;span class=&quot;na&quot;&gt;ruby-version&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;&#39;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;3.4&#39;&lt;/span&gt;  &lt;span class=&quot;c1&quot;&gt;# Specify the Ruby version to use&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Falta o step que gera e publica a gem.&lt;br /&gt;
Primeiro, criamos o diretório &lt;code class=&quot;highlighter-rouge&quot;&gt;.gem&lt;/code&gt; e o arquivo de credenciais. Depois, definimos as permissões do arquivo e gravamos nele o token de autenticação.&lt;/p&gt;

&lt;div class=&quot;language-yaml highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;    &lt;span class=&quot;pi&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;name&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;Publish to RubyGems&lt;/span&gt;
      &lt;span class=&quot;na&quot;&gt;run&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;pi&quot;&gt;|&lt;/span&gt;
        &lt;span class=&quot;s&quot;&gt;mkdir -p $HOME/.gem&lt;/span&gt;
        &lt;span class=&quot;s&quot;&gt;touch $HOME/.gem/credentials&lt;/span&gt;
        &lt;span class=&quot;s&quot;&gt;chmod 0600 $HOME/.gem/credentials&lt;/span&gt;
        &lt;span class=&quot;s&quot;&gt;printf -- &quot;---\n:rubygems_api_key: ${GEM_HOST_API_KEY}\n&quot; &amp;gt; $HOME/.gem/credentials&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Em seguida, geramos a gem e enviamos pro RubyGems:&lt;/p&gt;

&lt;div class=&quot;language-yaml highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;        &lt;span class=&quot;s&quot;&gt;gem build *.gemspec&lt;/span&gt;
        &lt;span class=&quot;s&quot;&gt;gem push *.gem&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Não dá pra esquecer a palavra-chave &lt;code class=&quot;highlighter-rouge&quot;&gt;env&lt;/code&gt;, que pega o token de autenticação do RubyGems nos secrets do repositório:&lt;/p&gt;

&lt;div class=&quot;language-yaml highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;      &lt;span class=&quot;na&quot;&gt;env&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
        &lt;span class=&quot;na&quot;&gt;GEM_HOST_API_KEY&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;${{ secrets.RUBYGEMS_AUTH_TOKEN  }}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;O job completo de publicação da gem deve ficar assim:&lt;/p&gt;

&lt;div class=&quot;language-yaml highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;na&quot;&gt;publish&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
    &lt;span class=&quot;na&quot;&gt;needs&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;test&lt;/span&gt;
    &lt;span class=&quot;na&quot;&gt;runs-on&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;ubuntu-latest&lt;/span&gt;
    &lt;span class=&quot;na&quot;&gt;if&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;startsWith(github.ref, &#39;refs/tags/v&#39;)&lt;/span&gt;
    &lt;span class=&quot;na&quot;&gt;steps&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
      &lt;span class=&quot;pi&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;uses&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;actions/checkout@v3&lt;/span&gt;
      &lt;span class=&quot;pi&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;name&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;Set up Ruby&lt;/span&gt;
        &lt;span class=&quot;na&quot;&gt;uses&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;ruby/setup-ruby@v1&lt;/span&gt;
        &lt;span class=&quot;na&quot;&gt;with&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
          &lt;span class=&quot;na&quot;&gt;ruby-version&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;&#39;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;3.4&#39;&lt;/span&gt;
      &lt;span class=&quot;pi&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;name&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;Publish to RubyGems&lt;/span&gt;
        &lt;span class=&quot;na&quot;&gt;run&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;pi&quot;&gt;|&lt;/span&gt;
          &lt;span class=&quot;s&quot;&gt;mkdir -p $HOME/.gem&lt;/span&gt;
          &lt;span class=&quot;s&quot;&gt;touch $HOME/.gem/credentials&lt;/span&gt;
          &lt;span class=&quot;s&quot;&gt;chmod 0600 $HOME/.gem/credentials&lt;/span&gt;
          &lt;span class=&quot;s&quot;&gt;printf -- &quot;---\n:rubygems_api_key: ${GEM_HOST_API_KEY}\n&quot; &amp;gt; $HOME/.gem/credentials&lt;/span&gt;
          &lt;span class=&quot;s&quot;&gt;gem build *.gemspec&lt;/span&gt;
          &lt;span class=&quot;s&quot;&gt;gem push *.gem&lt;/span&gt;
        &lt;span class=&quot;na&quot;&gt;env&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
          &lt;span class=&quot;na&quot;&gt;GEM_HOST_API_KEY&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;${{ secrets.RUBYGEMS_AUTH_TOKEN  }}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h3 id=&quot;automação-da-publicação-com-a-criação-de-tags&quot;&gt;Automação da publicação com a criação de tags&lt;/h3&gt;

&lt;p&gt;Por fim, depois do merge do &lt;a href=&quot;https://github.com/betogrun/lean-microsoft-graph/pull/60&quot; target=&quot;_blank&quot;&gt;Pull Request&lt;/a&gt; que atualiza a versão da gem e o changelog, o próximo passo é criar a tag da nova versão com o seguinte comando:&lt;/p&gt;

&lt;div class=&quot;language-shell highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;git tag &lt;span class=&quot;nt&quot;&gt;-a&lt;/span&gt; v0.3.4 &lt;span class=&quot;nt&quot;&gt;-m&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;Version 0.3.4&quot;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;A flag &lt;code class=&quot;highlighter-rouge&quot;&gt;-a&lt;/code&gt; cria uma tag anotada, e a flag &lt;code class=&quot;highlighter-rouge&quot;&gt;-m&lt;/code&gt; adiciona uma mensagem à tag. As duas são opcionais.&lt;/p&gt;

&lt;p&gt;Depois disso, precisamos enviar a tag pro repositório remoto no GitHub:&lt;/p&gt;

&lt;div class=&quot;language-shell highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;git push origin v0.3.4
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Depois que a tag é enviada, o workflow do GitHub Actions é disparado, e a gem é gerada e publicada no RubyGems.&lt;/p&gt;

&lt;p&gt;O resultado do workflow pode ser conferido na aba Actions do repositório.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/images/post_2024_8_30/github-actions.png&quot; alt=&quot;Workflow do GitHub Actions&quot; class=&quot;zooming&quot; /&gt;&lt;/p&gt;

&lt;p&gt;A nova versão da gem fica disponível no RubyGems, e as mudanças aparecem na &lt;a href=&quot;https://rubygems.org/gems/lean-microsoft-graph&quot; target=&quot;_blank&quot;&gt;página da gem&lt;/a&gt;.&lt;/p&gt;

&lt;h3 id=&quot;conclusão&quot;&gt;Conclusão&lt;/h3&gt;

&lt;p&gt;Este post mostrou como automatizar a publicação de gems Ruby com o GitHub Actions e também passou pelas boas práticas de versionamento e de manutenção do changelog.&lt;br /&gt;
Fique à vontade pra contar como você usa o GitHub Actions nos seus workflows e como prefere versionar e publicar gems.&lt;/p&gt;

&lt;h3 id=&quot;referências&quot;&gt;Referências&lt;/h3&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;a href=&quot;https://rubygems.org/&quot; target=&quot;_blank&quot;&gt;RubyGems&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://docs.github.com/pt/actions&quot; target=&quot;_blank&quot;&gt;GitHub Actions&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://semver.org/lang/pt-BR/&quot; target=&quot;_blank&quot;&gt;Versionamento Semântico&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://keepachangelog.com/pt-BR/&quot; target=&quot;_blank&quot;&gt;Keep a Changelog&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;</content>
      <author>
        <name>Alberto Rocha</name>
      </author>
        <category term="automation" />
        <category term="ruby" />
        <category term="git" />
        <category term="github" />
    </entry>
</feed>
