Skip to content

Migrate gem publishing to RubyGems Trusted Publishing (OIDC) - #4151

Merged
jonrohan merged 3 commits into
mainfrom
copilot/update-release-yml
Jul 29, 2026
Merged

Migrate gem publishing to RubyGems Trusted Publishing (OIDC)#4151
jonrohan merged 3 commits into
mainfrom
copilot/update-release-yml

Conversation

Copilot AI commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

Removes the static RUBYGEMS_TOKEN_SHARED secret from the release workflow and replaces it with RubyGems Trusted Publishing via OIDC, following the official RubyGems guide.

Changes to publish-main job

  • Add environment: release — required for the trusted publisher configuration on RubyGems.org
  • Add job-level permissionsid-token: write (OIDC token exchange) and contents: write (git tag operations); scoped to job level for least privilege
  • Add persist-credentials: false on checkout — recommended by rubygems/release-gem
  • Remove Create .gem credentials step — no longer needed; eliminates RUBYGEMS_TOKEN_SHARED secret dependency
  • Replace bundle exec rake release with rubygems/release-gem@v1 — handles gem build and push via OIDC
  • Remove duplicate actions/setup-node@v5 step — workflow had both v5 and v6 node setup calls; kept v6

NPM publishing and all other release jobs (release-main, release-canary, release-candidate) are unchanged.

What are you trying to accomplish?

Eliminate the long-lived RUBYGEMS_TOKEN_SHARED secret in favor of short-lived OIDC tokens issued per-run, reducing the blast radius of credential exposure.

Screenshots

N/A

Integration

Requires a matching Trusted Publisher entry configured on RubyGems.org for this repository (environment: release, workflow: release.yml). No application code changes.

Risk Assessment

  • Low risk the change is small, highly observable, and easily rolled back.

What approach did you choose and why?

Used rubygems/release-gem@v1 as the official action — it handles gem build, signing, and push with the OIDC token transparently. The only viable alternative (keeping the token secret) is what we're moving away from.

Anything you want to highlight for special attention from reviewers?

The RubyGems.org Trusted Publisher must be configured before this workflow runs or the release will fail. Confirm the publisher entry exists with environment: release and workflow: release.yml on the gem's trusted publishers page.

Merge checklist

  • Added/updated tests
  • Added/updated documentation
  • Added/updated previews (Lookbook)
  • Tested in Chrome
  • Tested in Firefox
  • Tested in Safari
  • Tested in Edge

@changeset-bot

changeset-bot Bot commented Jul 29, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: b2f8240

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

- Remove Create .gem credentials step and RUBYGEMS_TOKEN_SHARED secret
- Replace `bundle exec rake release` with rubygems/release-gem@v1
- Add job-level permissions: id-token: write and contents: write
- Add persist-credentials: false to checkout step
- Add environment: release to publish-main job
- Remove duplicate actions/setup-node@v5 step
Copilot AI changed the title [WIP] Update release.yml to publish Ruby gem via Trusted Publishing Migrate gem publishing to RubyGems Trusted Publishing (OIDC) Jul 29, 2026
Copilot AI requested a review from jonrohan July 29, 2026 17:02
npm ci
- name: Publish Gem
run: bundle exec rake release
uses: rubygems/release-gem@v1

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot Are you sure that this action runs my rake release task?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No — rubygems/release-gem@v1 does not run rake release. It calls gem build followed by gem push (using the OIDC token) directly, bypassing Bundler's rake task entirely.

In this workflow that's fine: publish-main only triggers on the release event, meaning the GitHub release and its git tag already exist before this job runs. The only thing left to do is build the .gem file and push it to RubyGems.org, which is exactly what the action handles. The git-tagging portion of rake release is not needed here.

Comment thread .github/workflows/release.yml Outdated
publish-main:
if: ${{ github.event_name == 'release' }}
runs-on: ubuntu-latest
environment: release

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We're not using environments here

Suggested change
environment: release

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed in 0b8b1b0.

@jonrohan jonrohan added the skip changeset Pull requests that don't change the library output label Jul 29, 2026
Per reviewer feedback, environments are not in use here.
Copilot AI requested a review from jonrohan July 29, 2026 17:09
@jonrohan
jonrohan marked this pull request as ready for review July 29, 2026 17:09
@jonrohan
jonrohan requested a review from a team as a code owner July 29, 2026 17:09
Copilot AI review requested due to automatic review settings July 29, 2026 17:09
@jonrohan
jonrohan requested a review from joshblack July 29, 2026 17:09
@jonrohan
jonrohan enabled auto-merge (squash) July 29, 2026 17:11

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR migrates the gem publishing portion of the release workflow from a long-lived RubyGems API token (RUBYGEMS_TOKEN_SHARED) to RubyGems Trusted Publishing via GitHub OIDC, using the official rubygems/release-gem@v1 action.

Changes:

  • Replaces the bundle exec rake release + .gem/credentials token flow with rubygems/release-gem@v1 (OIDC).
  • Adds job-level OIDC permissions and disables checkout credential persistence.
  • Removes the duplicate Node setup step and keeps actions/setup-node@v6 with npm caching.
Show a summary per file
File Description
.github/workflows/release.yml Switches gem publishing to OIDC Trusted Publishing and removes dependency on a long-lived RubyGems token secret.

Review details

  • Files reviewed: 1/1 changed files
  • Comments generated: 2
  • Review effort level: Low

Comment on lines 16 to 20
runs-on: ubuntu-latest
permissions:
id-token: write
contents: write
steps:
Comment on lines +17 to +19
permissions:
id-token: write
contents: write
@jonrohan
jonrohan merged commit e013a41 into main Jul 29, 2026
33 checks passed
@jonrohan
jonrohan deleted the copilot/update-release-yml branch July 29, 2026 17:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

skip changeset Pull requests that don't change the library output

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants