Skip to content

ci: publish the gem via RubyGems trusted publishing - #2

Merged
Halvanhelv merged 1 commit into
mainfrom
ci/trusted-publishing
Sep 7, 2026
Merged

Halvanhelv merged 1 commit into
mainfrom
ci/trusted-publishing

Conversation

@Halvanhelv

Copy link
Copy Markdown
Owner

Summary

Releasing currently means building the gem locally and pushing it with a personal API key. The account's MFA level is UI and API, so every push also needs a manual OTP — which is what blocked the 1.1.0 release.

This publishes from GitHub Actions instead. rubygems/release-gem mints an OIDC token that RubyGems exchanges for a short-lived scoped credential: no API key stored anywhere, no OTP.

How it works

  • Triggers on a published GitHub release (plus workflow_dispatch for manual runs).
  • Runs bundle exec rspec first, so a red build cannot reach RubyGems.
  • rubygems/release-gem@v1 runs bundle exec rake release. At release-published time the tag already exists, and bundler's release:source_control_push task is a no-op when already_tagged? is true — so it only builds and pushes the gem.
  • id-token: write mints the OIDC token; contents: write covers the tag push on the workflow_dispatch path where the tag does not exist yet.

Setup required before this works

On RubyGems.org → Settings → Pending Trusted Publishers → Add, register:

field value
Repository owner Halvanhelv
Repository name deepl_diff
Workflow filename release.yml
Environment leave blank

Test plan

Once the trusted publisher is registered, re-run the workflow against the existing v1.1.0 release (Actions → Release → Run workflow, or re-publish the release). It should build pkg/deepl_diff-1.1.0.gem and push it without any credential prompt.

https://claude.ai/code/session_01Pda49PcgziFVnibkKKjXRE

Releasing meant building the gem locally and pushing it with a personal
API key, which the account's "UI and API" MFA level turns into a manual
OTP prompt on every release.

Publish from GitHub Actions instead. `rubygems/release-gem` mints an
OIDC token that RubyGems exchanges for a short-lived scoped credential,
so no API key is stored anywhere and no OTP is needed.

The workflow triggers on a published GitHub release. The tag already
exists at that point, and bundler's release task skips tagging when
`already_tagged?` is true, so it only builds and pushes. The suite runs
first so a red build cannot reach RubyGems.

Requires a trusted publisher for Halvanhelv/deepl_diff with workflow
filename release.yml to be registered on RubyGems.org.
@Halvanhelv
Halvanhelv merged commit 76bcb2a into main Sep 7, 2026
5 checks passed
@Halvanhelv
Halvanhelv deleted the ci/trusted-publishing branch September 7, 2026 14:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant