Skip to content

Adopt ruby-gem-release for gem releases - #1017

Open
numbata wants to merge 8 commits into
ruby-grape:masterfrom
numbata:adopt-ruby-gem-release
Open

numbata wants to merge 8 commits into
ruby-grape:masterfrom
numbata:adopt-ruby-gem-release

Conversation

@numbata

@numbata numbata commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Releasing grape-swagger currently means pushing the gem from a maintainer's machine and then relying on a tag-triggered workflow that only creates the GitHub Release. This change moves the whole release into one manual run of the Release workflow, which publishes the gem through RubyGems Trusted Publishing, updates the changelog, tags the release, and prepares the next version. Changelog headings keep the project's dash date format, so the changelog stays consistent with earlier releases. The GitHub Release body is generated by GitHub until the upstream release tooling can copy it from the changelog.

Root cause

The release steps are split across a local command and a tag-triggered workflow, and nothing checks that they happen in order. Publishing depends on the maintainer's local RubyGems credentials, and the version bump, changelog heading, and tag are done by hand. A missed step leaves the tag, the changelog, the gem, and the GitHub Release out of sync.

What changes

  • A manual Release workflow dispatch publishes the gem. It authenticates with RubyGems Trusted Publishing, so no RubyGems API key is stored in the repository.
  • The same run prepares the changelog heading, tags the release, creates the GitHub Release, and opens the next development version.
  • The old tag-triggered GitHub Release workflow is removed, since the new run creates that release itself.
  • Bundler's local rake release, release:rubygem_push, and release:source_control_push tasks now stop with a message that points to the workflow, so the usual ways of publishing from a laptop are closed.
  • The release tasks load only on Ruby 3.3 and newer. The Ruby 3.1 and 3.2 CI jobs keep installing the bundle.

Drawbacks

  • Releases depend on a third-party reusable workflow, pinned to the commit of dblock/ruby-gem-release v0.9.0. Upgrading it means upgrading the gem and the pin together.
  • Releases are manual only. Nothing publishes when a tag or merge lands.
  • Before the first release, a maintainer must set up the trusted publisher on RubyGems and create a release environment in GitHub.
  • The Actions token must be allowed to push the release commit and tag to master.
  • Until ruby-gem-release ships its unreleased swagger-ui doesn't honor required parameters in optional group #90 and Empty field for group parameters' name with type hash or Array #91, the GitHub Release body is generated by GitHub instead of copied from the changelog section, and the Next section must keep at least one * Your contribution here. line. Both are merged upstream but not in 0.9.0, so they are expected in 0.10.0.
  • The release refuses to run unless the Next changelog section has real notes. This is intended, but it means an empty release cannot be cut.
  • The project now has development dependencies (ruby-gem-release and commonmarker) that require Ruby 3.3 or newer. Contributors on Ruby 3.1 or 3.2 do not get the release tasks.

Alternatives considered

  • Keep rake release and the tag workflow. This is the status quo. It keeps the manual steps and the local credentials that this change removes.
  • Store a RubyGems API key as a repository secret and publish from the existing tag workflow. This works, but it means a long-lived secret that has to be rotated and protected. Trusted Publishing avoids the secret entirely.
  • Use the semantic variant of ruby-gem-release, which picks versions and writes notes from commit history. Rejected because this project writes its changelog by hand, and the version should be chosen by a maintainer, not inferred from commit messages.
  • Release from a dedicated Gemfile via the workflow's gemfile input, with its own committed lock. It would pin the release dependencies and remove the Ruby 3.3 guard from the main Gemfile, but it adds a second dependency set to maintain, so it is left for a follow-up.

@dblock

dblock commented Nov 13, 2026

Copy link
Copy Markdown
Member

Look good!

Releases are cut by hand today: `rake release` pushes the gem with the maintainer's local RubyGems credentials, and a tag-triggered workflow creates the GitHub Release afterwards. ruby-gem-release moves publication into one manual workflow dispatch that authenticates with RubyGems Trusted Publishing, so no API key is stored in the repository or on a laptop. The same run updates the changelog, tags the release, creates the GitHub Release, and opens the next development version.

The tag-triggered workflow is replaced because the new flow pushes the tag itself, and both would create the same GitHub Release. Local `rake release` now points to the workflow, so the gem cannot be published around it. The release tasks register only on Ruby 3.3+, so the Ruby 3.1 and 3.2 CI jobs still install the bundle.
The input declares the owner of a gem on its first publication. grape-swagger already exists on RubyGems and its owners are set, so the input has no effect and only adds a field to the dispatch form.
@numbata
numbata force-pushed the adopt-ruby-gem-release branch from 3fbe061 to 4388a1b Compare November 16, 2026 13:15
@github-actions

github-actions Bot commented Nov 16, 2026 •

Copy link
Copy Markdown

Danger Report

No issues found.

View run

@dblock

dblock commented Nov 20, 2026

Copy link
Copy Markdown
Member

@numbata finish this?

The Release workflow writes changelog headings in the project's dash date format, which ruby-gem-release only accepts since dblock/ruby-gem-release#69. Pin the gem and the reusable release workflow to v0.8.0, the first release that includes it, and rewrite RELEASING.md for the workflow-based steps, which replace the Travis check and local rake release.

v0.8.0 parses Markdown changelogs with Commonmarker, so the development bundle adds it alongside the gem.
@numbata
numbata marked this pull request as ready for review November 21, 2026 00:02
@numbata
numbata requested an adaptive review from Copilot November 21, 2026 00:03

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟡 Changes recommended

The release workflow grants repository write access and gem-publishing credentials to code referenced by a mutable upstream tag, allowing tag changes to silently alter privileged release runs.

6 open issues
What changed in this PR

This PR moves grape-swagger’s gem publication and release bookkeeping into a manually dispatched GitHub Actions workflow, replacing the split local-publishing and tag-triggered process.

Changes:

  • Adopt the reusable ruby-gem-release workflow with RubyGems Trusted Publishing.
  • Add Ruby 3.3+ release dependencies and tasks, and redirect local rake release to the workflow.
  • Update release instructions and record the automation change in the changelog.
File Description
RELEASING.md Documents workflow dispatch, approvals, and one-time publisher setup.
Rakefile Configures release tasks and blocks the top-level local release command.
Gemfile Adds release dependencies conditionally for Ruby 3.3 and newer.
CHANGELOG.md Records the switch to manual release automation.
.github/​workflows/​release.yml Replaces tag-triggered release creation with the reusable publishing workflow.

Review effort: Max (adaptive)

Comment thread .github/workflows/release.yml Resolved
Comment thread RELEASING.md Resolved
Comment thread RELEASING.md Resolved
Comment thread Rakefile Resolved
Comment thread Rakefile Resolved
Comment thread RELEASING.md Resolved
The reusable release workflow receives write access and an OIDC token that can publish the gem, and a version tag can be moved, so reference the v0.8.0 commit directly. Bundler's release:rubygem_push and release:source_control_push could still publish or tag from a laptop after only `release` was disabled, so disable all three.

RELEASING.md now documents the setup and failure cases the workflow leaves to maintainers: the RubyGems workflow repository fields for a reusable workflow, keeping a changelog placeholder until the release, and not merging into master while a release runs.
The first release is also the first real exercise of Trusted Publishing, so
the workflow now accepts a dry-run input that checks the release
prerequisites without publishing. The changelog transformer is told which
sections exist so an empty category is removed instead of being released as a
bare heading.

The changelog entry moves to Features, the Bundler task override tolerates a
renamed task, and the Ruby 3.3 version guard in the Gemfile is written once.
The release workflow and the Rakefile integration use the same gem version,
so both move together. 0.9.0 adds an optional `gemfile` input to the reusable
workflow and changes nothing for the current setup.
… bundle

A green dry run only proves Trusted Publishing and push permissions, and it
waits for the same environment approval as a real run, so RELEASING.md now
says both instead of implying the whole release was validated. The Rakefile
loads the release tasks when ruby-gem-release is in the bundle rather than
repeating the Ruby version check from the Gemfile, so the floor lives in one
place. The Gemfile comment and the placeholder note name who is affected and
when the note can go.
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.

3 participants