Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
75 changes: 75 additions & 0 deletions .github/workflows/push_gem.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
name: release

on:
workflow_dispatch:
inputs:
version:
description: 'Version to release (e.g. 0.21.3 or v0.21.3)'
required: true

jobs:
push:
name: Push gem to RubyGems.org
runs-on: ubuntu-latest

permissions:
id-token: write # IMPORTANT: this permission is mandatory for trusted publishing
contents: write # IMPORTANT: this permission is required for `rake release` to push the release tag
Copy link

Copilot AI Dec 2, 2025

Choose a reason for hiding this comment

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

The comment references "rake release" but the workflow actually uses rubygems/release-gem@v1 (line 68). Update the comment to match the actual implementation, e.g., "IMPORTANT: this permission is required for pushing commits and creating tags".

Suggested change
contents: write # IMPORTANT: this permission is required for `rake release` to push the release tag
contents: write # IMPORTANT: this permission is required for pushing commits and creating tags

Copilot uses AI. Check for mistakes.

steps:
- uses: actions/checkout@v5
with:
fetch-depth: 0
- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
bundler-cache: true
ruby-version: ruby

- name: Bump version.rb
run: |
set -euo pipefail
version="${{ github.event.inputs.version }}"
version="${version#v}"
echo "VERSION_NO_V=$version" >> "$GITHUB_ENV"
echo "VERSION_TAG=v$version" >> "$GITHUB_ENV"
current_version=$(ruby -e "require_relative './lib/rspec/openapi/version'; puts RSpec::OpenAPI::VERSION")
VERSION_NO_V="$version" CURRENT_VERSION="$current_version" ruby - <<'RUBY'
version = ENV.fetch('VERSION_NO_V')
unless version.match?(/\A\d+(?:\.\d+)*\z/)
warn "Invalid version format: #{version}"
exit 1
end
require 'rubygems'
new_version = Gem::Version.new(version)
current_version = Gem::Version.new(ENV.fetch('CURRENT_VERSION'))
unless new_version < current_version
warn "Given version (#{new_version}) must be lower than current version (#{current_version})"
Comment on lines +49 to +50
Copy link

Copilot AI Dec 2, 2025

Choose a reason for hiding this comment

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

The version comparison logic is inverted. The condition should check if new_version > current_version (using > operator), not <. Currently it requires the new version to be lower than the current version, which prevents version bumps. This will cause all release attempts to fail.

Suggested change
unless new_version < current_version
warn "Given version (#{new_version}) must be lower than current version (#{current_version})"
unless new_version > current_version
warn "Given version (#{new_version}) must be greater than current version (#{current_version})"

Copilot uses AI. Check for mistakes.
Comment on lines +49 to +50
Copy link

Copilot AI Dec 2, 2025

Choose a reason for hiding this comment

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

The error message is incorrect. It states "must be lower than" when it should state "must be greater than" to match the intended behavior of a version bump.

Suggested change
unless new_version < current_version
warn "Given version (#{new_version}) must be lower than current version (#{current_version})"
unless new_version > current_version
warn "Given version (#{new_version}) must be greater than current version (#{current_version})"

Copilot uses AI. Check for mistakes.
exit 1
end
RUBY
ruby -pi -e "sub(/VERSION = .*/, \"VERSION = '$version'\")" lib/rspec/openapi/version.rb
Copy link

Copilot AI Dec 2, 2025

Choose a reason for hiding this comment

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

The string substitution doesn't preserve the quotes around the version string. The regex replacement should be "VERSION = '\\$version'" (with single quotes around $version) to match the existing format in version.rb which uses VERSION = '0.21.2'.

Suggested change
ruby -pi -e "sub(/VERSION = .*/, \"VERSION = '$version'\")" lib/rspec/openapi/version.rb
ruby -pi -e "sub(/VERSION = '.*'/, \"VERSION = '$version'\")" lib/rspec/openapi/version.rb

Copilot uses AI. Check for mistakes.
git status --short
- name: Commit version bump
run: |
set -euo pipefail
version="$VERSION_NO_V"
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git commit -am "Bump version to ${version}"
git push origin "HEAD:${{ github.event.repository.default_branch }}"
- uses: rubygems/release-gem@v1

- name: Create GitHub release
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ env.VERSION_TAG }}
name: ${{ env.VERSION_TAG }}
generate_release_notes: true
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -410,9 +410,9 @@ Existing RSpec plugins which have OpenAPI integration:

## Releasing

1. Bump version in `lib/rspec/openapi/version.rb`
2. Run `bundle exec rake release`
3. Push tag
1. Ensure RubyGems trusted publishing is configured for this repo and gem ownership (see [Trusted publishing](https://guides.rubygems.org/trusted-publishing/)).
2. In GitHub Actions, run the `release` workflow manually and input the new version (`0.21.x` or `v0.21.x`).
3. The workflow bumps `lib/rspec/openapi/version.rb`, pushes the change to the default branch, publishes to RubyGems via `rubygems/release-gem`, and creates a GitHub release with autogenerated notes.
Copy link

Copilot AI Dec 2, 2025

Choose a reason for hiding this comment

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

Change "autogenerated" to "auto-generated" (hyphenated) for proper spelling.

Suggested change
3. The workflow bumps `lib/rspec/openapi/version.rb`, pushes the change to the default branch, publishes to RubyGems via `rubygems/release-gem`, and creates a GitHub release with autogenerated notes.
3. The workflow bumps `lib/rspec/openapi/version.rb`, pushes the change to the default branch, publishes to RubyGems via `rubygems/release-gem`, and creates a GitHub release with auto-generated notes.

Copilot uses AI. Check for mistakes.

## License

Expand Down