Skip to content

ci: publish to RubyGems with trusted publishing - #160

Closed
czj wants to merge 1 commit into
mdp:mainfrom
czj:ci/rubygems-trusted-publishing
Closed

czj wants to merge 1 commit into
mdp:mainfrom
czj:ci/rubygems-trusted-publishing

Conversation

@czj

@czj czj commented Oct 29, 2026

Copy link
Copy Markdown

The v6.3.1 backfill (#156) stopped at gem push: the API key belongs to an MFA-protected account, so RubyGems asked for a WebAuthn confirmation nobody could give from CI, and the step expired after five minutes (run 40903368260).

This switches the publish job to trusted publishing: rubygems/configure-rubygems-credentials exchanges the job's OIDC token for a short-lived API key, which gem push picks up from GEM_HOST_API_KEY without a second factor. The job gets id-token: write next to the contents: write that gh release upload already needed. Build, push and the GitHub release steps are unchanged.

It needs a trusted publisher on rubygems.org before the next run (rotp → Trusted publishers: repository mdp/rotp, workflow release.yaml, no environment); until then the credentials step fails before anything is pushed. The RUBYGEMS_AUTH_TOKEN secret can be removed afterwards.

gem push with an API key stops at the WebAuthn prompt of an
MFA-protected account, so the v6.3.1 backfill expired. A trusted
publisher exchanges the workflow's OIDC token for a short-lived key
that RubyGems accepts without a second factor.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@mdp

mdp commented Oct 29, 2026

Copy link
Copy Markdown
Owner

Thanks @czj — this is exactly the right fix and a very clear write-up of the MFA/WebAuthn cause. Great minds 🙂

It's superseded by #158, which landed a few minutes before this opened and is now proven end to end. #158 does the same core change (id-token: write + rubygems/configure-rubygems-credentials before gem push) plus a few extras:

  • googleapis/release-please-action, and dropped the invalid package-name/version-file action inputs
  • release-type/version-file in release-please-config.json, so release PRs finally bump lib/rotp/version.rb (they hadn't since 6.3.0 — that's why the stale 6.3.1 release PR never bumped it)
  • a job timeout-minutes so an auth failure fails fast instead of hanging through the 5-minute WebAuthn expiry, and a guard so a manual dispatch only publishes when a tag is supplied

With your trusted-publisher setup in place it worked first try: the backfill published rotp 6.3.1, and merging the 6.4.0 release PR published rotp 6.4.0 through the same pipeline.

Closing as superseded — thank you for getting to it so quickly.

@mdp mdp closed this Oct 29, 2026
@czj
czj deleted the ci/rubygems-trusted-publishing branch October 29, 2026 17:42
@czj

czj commented Oct 29, 2026

Copy link
Copy Markdown
Author

Thank you for the awesome work on this gem !

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.

2 participants