Shopify / Shopify/worldwide

Set up RubyGems Trusted Publishing

Open
#559 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Ruby
Stars
97
Forks
17
Avg merge
13h 33m
Merged PRs (30d)
11

Description

Problem

RubyGems releases currently run bundle exec rake release in ShipIt and depend on a long lived RubyGems credential. This makes releases depend on credential provisioning and rotation outside the repository.

RubyGems Trusted Publishing exchanges a GitHub Actions OIDC identity for a short lived token that can publish only the configured gem. Moving the publish step to GitHub Actions removes the stored RubyGems credential while retaining Bundler's existing release task.

RubyGems guide: https://guides.rubygems.org/trusted-publishing/

Proposed implementation

1. Add a release workflow

Add .github/workflows/release.yml with:

  • A manual workflow_dispatch trigger, so merging a version preparation PR does not publish automatically.
  • A single release job on ubuntu-latest.
  • Job permissions contents: write and id-token: write. The first permits rake release to push the version tag, and the second permits the OIDC exchange with RubyGems.org.
  • The GitHub environment release.
  • actions/checkout with persist-credentials: false.
  • ruby/setup-ruby with Bundler caching.
  • rubygems/release-gem, which configures temporary Trusted Publishing credentials and runs the existing bundle exec rake release task.
  • Commit pinned action references, consistent with the existing workflows in this repository.

Use the current rubygems/release-gem release when implementing. As of this plan, that is v1.4.0 at 052cc82692552de3ef2b81fd670e41d13cba8092.

A manual trigger most closely preserves the current explicit release operation. It also avoids a second tag driven workflow because bundle exec rake release already builds the gem, creates and pushes the version tag, and publishes the gem.

2. Protect the GitHub release environment

Create the release environment in Shopify/worldwide and apply deployment protection that matches the current release ownership, such as required reviewers and restrictions to the default branch. The environment name in GitHub must exactly match the workflow and RubyGems configuration.

3. Register the Trusted Publisher on RubyGems.org

An owner of the existing worldwide gem must create this Trusted Publisher:

Field Value
Gem worldwide
Repository owner Shopify
Repository name worldwide
Workflow filename release.yml
Environment release
Reusable workflow repository Leave blank

The gem is currently owned through Shopify's RubyGems account, so this step must be performed by someone with access to that owner account. Repository access alone cannot configure it.

4. Validate and retire the old path

For the next prepared release:

  1. Dispatch the Release workflow from the version commit on main.
  2. Confirm the workflow creates and pushes the expected v<version> tag.
  3. Confirm the same version appears on https://rubygems.org/gems/worldwide and can be installed.
  4. Confirm no repository RubyGems API secret was needed.
  5. After the successful release, disable the ShipIt RubyGems release path and remove its long lived RubyGems credential. Keep ShipIt available as a fallback until this validation succeeds.

Acceptance criteria

  • .github/workflows/release.yml publishes worldwide through rubygems/release-gem.
  • The release job has only the required GitHub permissions and uses the protected release environment.
  • worldwide has a RubyGems Trusted Publisher for Shopify/worldwide, release.yml, and release.
  • A release successfully creates the version tag and publishes the gem without a stored RubyGems API key.
  • The previous ShipIt publish path and its RubyGems credential are retired after validation.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reviewing the existing GitHub Actions workflows and the current bundle exec rake release path. Add and validate .github/workflows/release.yml with the specified permissions, pinned actions, and release environment, then coordinate Trusted Publisher setup and release validation with the gem owner. Done means a version tag and gem release succeed without a stored RubyGems credential and the old ShipIt path is retired.

Written by the indexing model from the issue text.

Assessment

Tech stack
github-actions, ruby
Domain
ci-cd, devops, release
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Clearly specified
Newbie friendliness
52/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.