Repository navigation
Fix automated RubyGems publishing - #179
Merged
Merged
Conversation
The publish workflow has never successfully released a gem. The one run
that fired (tag v8.0.1) died in `release:guard_clean` with "There are
files that need to be committed first", and the version was pushed by
hand instead.
Two independent things made the checkout dirty:
* `Gemfile.lock` records the gem's own version in its PATH section. It
said 8.0.0 while version.rb said 8.0.1, so `bundle install` in CI
rewrote it. This would have recurred on every release.
* `bundler-cache: true` writes `vendor/bundle` (not ignored) and
rewrites the tracked `.bundle/config`.
The v8.0.1 tag also pointed at a commit where version.rb still said
8.0.0, so even a clean tree would have published the wrong version.
Trusted publishing is already configured on rubygems.org and worked in
that run, so no credential changes are needed. The unused
RUBYGEMS_API_KEY repo secret can be deleted.
Changes:
* publish.yml installs to the system gem dir instead of using
bundler-cache, pins ruby 3.4 (was resolving to 4.0.5), fetches full
history so source_control_push sees the existing tag, and adds
guards for tag/version mismatch and a dirty tree.
* bin/release.sh replaces the manual `gem build && gem push` path with
a bump-commit-tag script that keeps version.rb and Gemfile.lock in
lockstep.
* The gemspec was shipping bin/release.sh as an installed executable
onto users' PATH. Ship no executables, and drop non-runtime files
from the package (28 files -> 19).
* Gemfile source http -> https; Gemfile.lock resynced to 8.0.1.
* Bump actions/checkout v4 -> v7 (v4 runs on deprecated Node 20) and
add the github-actions ecosystem to dependabot, which was
bundler-only and let checkout fall three majors behind.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
The publish workflow has never successfully released a gem. Only one run has ever fired — tag
v8.0.1, 2026-06-19 — and it died inrelease:guard_clean:8.0.1 was then published by hand three minutes later.
Two independent things dirtied the checkout:
Gemfile.lockrecords the gem's own version in itsPATHsection. It saidjanus-ar (8.0.0)whileversion.rbsaid8.0.1, sobundle installin CI rewrote it. This would recur on every release, since the lock has to be bumped alongsideversion.rb.bundler-cache: truewritesvendor/bundle(not gitignored) and rewrites the tracked.bundle/config.Separately, the
v8.0.1tag points at a commit whereversion.rbstill said8.0.0— so even a clean tree would have published the wrong version.Trusted publishing is already set up correctly.
rubygems/configure-rubygems-credentialscompleted and exported the OIDC token in that run; the job only failed afterwards. No credential work is needed, and the unusedRUBYGEMS_API_KEYrepo secret (created 2024) can be deleted.What changed
.github/workflows/publish.yml— plainbundle installinstead ofbundler-cacheso nothing is written into the working tree;ruby-version: '3.4'instead ofruby(was resolving to 4.0.5);fetch-depth: 0sorelease:source_control_pushsees the tag as already created; two guard steps that fail with a readable message on tag/version mismatch or a dirty tree, rather than the crypticguard_cleanerror.bin/release.sh— wasgem build && gem push, i.e. the manual path that bypassed CI entirely. Now validates the version, rewritesversion.rb, regeneratesGemfile.lock, commits and tags — keeping the two in lockstep so cause Bump rake from 13.1.0 to 13.2.1 #1 can't come back.janus-ar.gemspec— the gem was shippingbin/release.shas an installed executable onto users'PATH(spec.executables == ["release.sh"]). Now[], andspec.filesdropsbin/ spec/ assets/ gemfiles/ .github/and dotfiles (28 files → 19).Gemfile—http://rubygems.org→https.Gemfile.lockresynced to 8.0.1.actions/checkoutv4 → v7 (v4 runs on deprecated Node 20 — visible as a warning in the failed run) and dependabot now coversgithub-actions, which was bundler-only and let checkout fall three majors behind..gitignore—/pkg/,/vendor/.README.md— release process documented.Verification
rubocop --parallelclean; all three YAML files parse.bundle exec rake buildproducesjanus-ar-8.0.1.gem;bundle installleaves the tree clean.bin/release.shtested end-to-end in a scratch repo: rejects malformed versions, rejects existing tags, handles pre-release suffixes (8.2.0.rc1).rspecnot run locally (needs MySQL with the replica/primary users) — CI covers it, and no library code is touched.Note / open question
Nothing gates publishing on tests: CI runs on
mainand PRs but not on tag pushes, sopublish.ymlwill ship a gem regardless of whether the suite is green at that commit. In practice tags are cut from an already-testedmain. Happy to add anrspecstep (plus the MySQL service block) to the publish job, or require the CI run on the tagged SHA to have passed, if you'd rather it were enforced.Next release
🤖 Generated with Claude Code