diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index a617b407..09239104 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,44 +1,20 @@ name: Release on: - push: - tags: - - 'v*' + workflow_dispatch: + inputs: + version: + description: Optional release version overriding the checked-in version. + 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 }} diff --git a/CHANGELOG.md b/CHANGELOG.md index 0bab3faf..71895b3d 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). diff --git a/Gemfile b/Gemfile index 4713afc3..4da8ad5e 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 02c318ec..5c321f57 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'