/gem-build-and-release-action

Build and publish a Ruby Gem to rubygems.org

Primary LanguageShellMIT LicenseMIT

ActionsToolbox logo
Github Build Status License Created
Release Released Commits since release

Overview

This action works by executing the following commands:

  • bundle install
  • gem build --output=latest-release.gem
  • gem push latest-release.gem

Assuming PUBLISH is set to true which is the default.

We create and publish the gems this way for a few very specific reasons:

  • We want to minimise the permissions that need to be given to the action.
  • We do not want the action to make any changes to the existing repository.
  • We want the action to only execute the minimum steps required to build and publish a gem.

There are many other gems available that work with rake release if this is your preferred method. The 2 that we recommend are below:

Our action is closely based on publish rubygems action.

Publish

name: Publish Gem

on:
  push:
    tags:
      - 'v[0-9].[0-9]+.[0-9]+'
      - '!v[0-9].[0-9]+.[0-9]+rc[0-9]+'

jobs:
  build:
    runs-on: ubuntu-latest

    steps:
      - uses: actions/checkout@v4

      - name: Release Gem
        uses: ActionsToolbox/gem-build-and-release-action@master
        env:
          RUBYGEMS_API_KEY: ${{secrets.RUBYGEMS_API_KEY}}

Build but Don't Publish

name: Test Publish Gem

on:
  push:
    tags:
      - 'v[0-9].[0-9]+.[0-9]+rc[0-9]+'

jobs:
  build:
    runs-on: ubuntu-latest

    steps:
      - uses: actions/checkout@v4

      - name: Release Gem
        uses: ActionsToolbox/gem-build-and-release-action@master
        env:
          RUBYGEMS_API_KEY: ${{secrets.RUBYGEMS_API_KEY}}
          PUBLISH: false