Skip to content

Commit 6bce923

Browse files
jathaydeclaude
andcommitted
fix(release): bypass rubygems/release-gem to avoid bundler/securerandom clash
Both prior v1.0.0 publish attempts (workflow runs 25679243892 and 25679904207) failed with: You have already activated securerandom 0.2.2, but your Gemfile requires securerandom 0.4.1. Diagnosis: `rubygems/release-gem` calls `bundle exec rake release` internally, with an attestation-patch loaded via RUBYOPT. That patch (or something it requires) loads securerandom *before* bundler resolves the Gemfile. Ruby 3.2.11 ships securerandom 0.2.2 as a default gem, which gets activated. Bundler then tries to resolve to the newer securerandom that a transitive dep wants and hits the activated-spec conflict. Setting `bundler: latest` (PR #18) didn't help — same failure on bundler 4.0.11. The conflict is a Ruby-runtime / default-gem issue, not a bundler version issue. Fix: do the build + push directly. Replace `rubygems/release-gem` with `rubygems/configure-rubygems-credentials` (does the OIDC handshake + writes ~/.gem/credentials), then `gem build` + `gem push`. No `bundle exec` on the push path means no default-gem activation, no conflict. We lose the SLSA attestation that `release-gem` would have added — worth picking back up later when the underlying tooling is less fragile. For 1.0.0 the gem just needs to be on RubyGems. Reverts the `bundler: latest` from PR #18 since it's no longer needed (and pinning bundler when we don't need to is gratuitous). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 9c313c3 commit 6bce923

1 file changed

Lines changed: 18 additions & 13 deletions

File tree

.github/workflows/release.yml

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -52,12 +52,6 @@ jobs:
5252
uses: ruby/setup-ruby@c4e5b1316158f92e3d49443a9d58b31d25ac0f8f # v1 branch head as of 2026-05-11
5353
with:
5454
ruby-version: "3.2"
55-
# Ruby 3.2.11 ships with bundler 2.4.19, which doesn't handle
56-
# the `securerandom` default-gem conflict that surfaces when a
57-
# transitive dep requires a newer securerandom than the one
58-
# the stdlib ships. `bundler: latest` resolves it (>= 2.5).
59-
# The v1.0.0 first-publish run caught this — see PR #18.
60-
bundler: latest
6155
bundler-cache: true
6256

6357
# Belt-and-braces: refuse to publish a tag whose version doesn't
@@ -84,10 +78,21 @@ jobs:
8478
- name: Run the test suite
8579
run: bundle exec rspec
8680

87-
# Official RubyGems trusted-publisher action. Exchanges the
88-
# GitHub OIDC token for a short-lived RubyGems API key, builds
89-
# the gem, and pushes. Action infers the gemspec from the repo
90-
# root and only pushes if rubygems.org accepts the OIDC claim
91-
# against a registered (or pending) trusted publisher.
92-
- name: Build and push to RubyGems.org
93-
uses: rubygems/release-gem@6317d8d1f7e28c24d28f6eff169ea854948bd9f7 # v1.2.0
81+
# Two-step publish — exchange the GitHub OIDC token for a
82+
# short-lived RubyGems API key, then `gem build` + `gem push`
83+
# directly. We don't use rubygems/release-gem (the "all in one"
84+
# wrapper) because it invokes `bundle exec rake release` under
85+
# an attestation-patch RUBYOPT, which activates the stdlib's
86+
# securerandom default gem before bundler resolves and conflicts
87+
# with any transitive dep that wants a newer securerandom — what
88+
# tanked the v1.0.0 first-publish attempts (workflow runs
89+
# 25679243892 and 25679904207). The direct approach avoids
90+
# bundler entirely on the push path.
91+
- name: Configure RubyGems trusted-publisher credentials
92+
uses: rubygems/configure-rubygems-credentials@762a4b77c3300434bb57c7ce80b20e36231927aa # v2.0.0
93+
94+
- name: Build gem
95+
run: gem build guardrails.gemspec
96+
97+
- name: Push to RubyGems.org
98+
run: gem push guardrails-*.gem

0 commit comments

Comments
 (0)