From 78194cc9ecb5cba2ac9216ac23adf60821cc988e Mon Sep 17 00:00:00 2001 From: Andrey Subbota Date: Thu, 12 Nov 2026 12:40:12 +0100 Subject: [PATCH 1/3] Adopt ruby-gem-release for gem releases 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. --- .github/workflows/release.yml | 51 +++++++++++------------------------ Gemfile | 2 ++ Rakefile | 17 ++++++++++++ 3 files changed, 35 insertions(+), 35 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index a617b407e..927c2646f 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,44 +1,25 @@ name: Release on: - push: - tags: - - 'v*' + workflow_dispatch: + inputs: + version: + description: Optional release version overriding the checked-in version. + type: string + required: false + rubygems-owner: + description: RubyGems account ID for first publication; omit for an existing gem. + type: string + required: false permissions: contents: write + id-token: write jobs: release: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v7 - with: - fetch-depth: 0 - - name: Extract changelog - id: changelog - shell: bash - run: | - set -euo pipefail - tag="${GITHUB_REF_NAME}" - version="${tag#v}" - notes="$(awk -v version="$version" ' - $0 ~ "^### " version " " {found=1; next} - found && $0 ~ "^### " {exit} - found {print} - ' CHANGELOG.md)" - if [[ -z "${notes// }" ]]; then - echo "No changelog entry found for ${version}" >&2 - exit 1 - fi - { - echo "notes<> "$GITHUB_OUTPUT" - - name: Create GitHub release - uses: softprops/action-gh-release@v3 - with: - tag_name: ${{ github.ref_name }} - name: ${{ github.ref_name }} - body: ${{ steps.changelog.outputs.notes }} + uses: dblock/ruby-gem-release/.github/workflows/release.yml@v0.6.0 + with: + ruby-version: '3.4' + version: ${{ inputs.version }} + rubygems-owner: ${{ inputs.rubygems-owner }} diff --git a/Gemfile b/Gemfile index 4713afc3b..4da8ad5e1 100644 --- a/Gemfile +++ b/Gemfile @@ -43,6 +43,8 @@ group :development, :test do gem 'rdoc' gem 'rspec', '~> 3.9' gem 'rubocop', '~> 1.50', require: false + # ruby-gem-release requires Ruby 3.3+; older CI Rubies skip it. + gem 'ruby-gem-release', require: false if Gem::Version.new(RUBY_VERSION) >= Gem::Version.new('3.3.0') unless ENV['MODEL_PARSER'] == 'grape-swagger-entity' gem 'grape-swagger-entity', git: 'https://github.com/ruby-grape/grape-swagger-entity' diff --git a/Rakefile b/Rakefile index 02c318ec0..5c321f57c 100644 --- a/Rakefile +++ b/Rakefile @@ -9,6 +9,23 @@ require 'rake' Bundler::GemHelper.install_tasks +# Publish only through the Release workflow, never a local push to rubygems.org. +Rake::Task['release'].clear +desc 'Publish through the Release workflow' +task :release do + abort 'Dispatch the Release workflow instead: gh workflow run release.yml' +end + +if Gem::Version.new(RUBY_VERSION) >= Gem::Version.new('3.3.0') + require 'ruby-gem-release/workflow/ruby_gem' + require 'ruby-gem-release/changelog' + + RubyGemRelease::Workflow::RubyGem.new( + version: RubyGemRelease::Version::RubyConstant.new(path: 'lib/grape-swagger/version.rb', constant: 'VERSION'), + changelog: RubyGemRelease::Changelog::Intridea.new(path: 'CHANGELOG.md', placeholder: '* Your contribution here.') + ).install_tasks +end + require 'rspec/core' require 'rspec/core/rake_task' From 25cb7540c79a51276ba5374b73e2a1a232cda975 Mon Sep 17 00:00:00 2001 From: Andrey Subbota Date: Thu, 12 Nov 2026 12:40:34 +0100 Subject: [PATCH 2/3] Add changelog entry for ruby-gem-release adoption --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0bab3faf6..71895b3d8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,7 @@ #### Fixes +* [#1017](https://github.com/ruby-grape/grape-swagger/pull/1017): Release through the manual Release workflow with `ruby-gem-release` and RubyGems Trusted Publishing, replacing the tag-triggered GitHub Release workflow and local `rake release` - [@numbata](https://github.com/numbata). * [#905](https://github.com/ruby-grape/grape-swagger/pull/905): Allow Float, BigDecimal and beginless ranges in `values` to set `minimum` and `maximum`, and skip infinite bounds that cannot be serialized to JSON - [@artyomb](https://github.com/artyomb). * [#1016](https://github.com/ruby-grape/grape-swagger/pull/1016): Hide the nested parameters of a Hash parameter marked `documentation: { hidden: true }`, and pass the resolved `token_owner` to parameter-level `hidden:` procs like route-level ones (raising `TokenOwnerNotFound` if the configured method is missing) - [@numbata](https://github.com/numbata). * [#1013](https://github.com/ruby-grape/grape-swagger/pull/1013): Fix array `default` values being placed inside `items` instead of on the array parameter or property, and emit an empty array `default` - [@numbata](https://github.com/numbata). From 3fbe0614efd47f2b867994cdc191491430227b9b Mon Sep 17 00:00:00 2001 From: Andrey Subbota Date: Thu, 12 Nov 2026 14:36:26 +0100 Subject: [PATCH 3/3] Drop rubygems-owner input from the release workflow 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. --- .github/workflows/release.yml | 5 ----- 1 file changed, 5 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 927c2646f..09239104e 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -7,10 +7,6 @@ on: description: Optional release version overriding the checked-in version. type: string required: false - rubygems-owner: - description: RubyGems account ID for first publication; omit for an existing gem. - type: string - required: false permissions: contents: write @@ -22,4 +18,3 @@ jobs: with: ruby-version: '3.4' version: ${{ inputs.version }} - rubygems-owner: ${{ inputs.rubygems-owner }}