DEV: Publish to rubygems on tag push (#422)

DEV: Publish to rubygems on tag push (#422)

Whenever a new tag (e.g. v1.9.26) is pushed and the tests pass, the workflow will automatically create a new release on rubygems.

diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index 1fd8bb1..73c77ce 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -5,6 +5,8 @@ on:
   push:
     branches:
       - master
+    tags:
+      - v*
 
 jobs:
   build:
@@ -37,3 +39,16 @@ jobs:
 
       - name: RSpec
         run: bundle exec rspec
+
+  publish:
+    if: contains(github.ref, 'refs/tags/v')
+    needs: build
+    runs-on: ubuntu-latest
+
+    steps:
+      - uses: actions/checkout@v2
+
+      - name: Release Gem
+        uses: cadwallion/publish-rubygems-action@5dfdb61
+        env:
+          RUBYGEMS_API_KEY: ${{secrets.RUBYGEMS_API_KEY}}

GitHub sha: c664f13b

2 Likes

This is really cool!

1 Like