-
Notifications
You must be signed in to change notification settings - Fork 69
Automate release #278
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Automate release #278
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| 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 | ||||||||||||||||||
|
|
||||||||||||||||||
| 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
|
||||||||||||||||||
| 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
AI
Dec 2, 2025
There was a problem hiding this comment.
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.
| 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
AI
Dec 2, 2025
There was a problem hiding this comment.
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'.
| ruby -pi -e "sub(/VERSION = .*/, \"VERSION = '$version'\")" lib/rspec/openapi/version.rb | |
| ruby -pi -e "sub(/VERSION = '.*'/, \"VERSION = '$version'\")" lib/rspec/openapi/version.rb |
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -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. | ||||||
|
||||||
| 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. |
There was a problem hiding this comment.
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 usesrubygems/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".