Skip to content
Merged
Changes from 1 commit
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
29 changes: 25 additions & 4 deletions rakelib/release.rake
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,32 @@ task :release, %i[gem_version dry_run] do |_t, args|

# See https://github.com/svenfuchs/gem-release
sh_in_dir(gem_root, "git pull --rebase")
sh_in_dir(gem_root, "gem bump --no-commit --file lib/cypress_on_rails/version.rb #{gem_version.strip.empty? ? '' : %(-v #{gem_version})}")
sh_in_dir(gem_root, "gem bump --no-commit --file lib/cypress_on_rails/version.rb #{gem_version.strip.empty? ? '' : %(--version #{gem_version})}")

# Release the new gem version
puts "Carefully add your OTP for Rubygems. If you get an error, run 'gem release' again."
sh_in_dir(gem_root, "gem release") unless is_dry_run
# Read the actual version from the file after bump
require_relative "../lib/cypress_on_rails/version"
actual_version = CypressOnRails::VERSION

# Update Gemfile.lock files
sh_in_dir(gem_root, "bundle install")

unless is_dry_run
# Commit the version bump and Gemfile.lock update
sh_in_dir(gem_root, "git add -A")
Copy link
Preview

Copilot AI Oct 2, 2025

Choose a reason for hiding this comment

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

[nitpick] git add -A may unintentionally include unrelated local changes in the release commit. Restrict the add to the specific intended files, e.g.: git add lib/cypress_on_rails/version.rb Gemfile.lock to avoid accidental inclusion of unrelated modifications.

Suggested change
sh_in_dir(gem_root, "git add -A")
sh_in_dir(gem_root, "git add lib/cypress_on_rails/version.rb Gemfile.lock")

Copilot uses AI. Check for mistakes.

sh_in_dir(gem_root, "git commit -m \"Release v#{actual_version}\"")

# Tag the release
sh_in_dir(gem_root, "git tag v#{actual_version}")

# Push the commit and tag
sh_in_dir(gem_root, "git push && git push --tags")

# Release the new gem version
puts "Carefully add your OTP for Rubygems. If you get an error, run 'gem release' again."
sh_in_dir(gem_root, "gem release")
else
puts "DRY RUN: Would have committed, tagged v#{actual_version}, pushed, and released gem"
Copy link
Preview

Copilot AI Oct 2, 2025

Choose a reason for hiding this comment

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

In dry-run mode the task still performs gem bump and bundle install earlier (modifying version.rb and Gemfile.lock), leaving a dirty workspace despite messaging that implies only hypothetical actions. Consider wrapping the bump and bundle install in the same unless is_dry_run block (or revert changes after) so a dry run does not alter the working tree.

Copilot uses AI. Check for mistakes.

Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🔴 Critical

❓ Verification inconclusive

Dry-run message will fail after fixing the workspace modification issue.

After addressing the critical dry-run issue (moving bump/install inside the conditional), actual_version won't be defined in the else branch, causing this line to fail with an undefined variable error.

After applying the fix for line 43, you'll need to determine the version for the dry-run message. Consider one of these approaches:

  1. Parse current version and calculate next version:
else
  # For dry-run, calculate what the version would be
  require_relative "../lib/cypress_on_rails/version"
  current_version = CypressOnRails::VERSION
  if gem_version.strip.empty?
    # Calculate patch bump
    parts = current_version.split('.')
    parts[-1] = (parts[-1].to_i + 1).to_s
    next_version = parts.join('.')
  else
    next_version = gem_version
  end
  puts "DRY RUN: Would have committed, tagged v#{next_version}, pushed, and released gem"
end
  1. Use gem bump --pretend if supported:
else
  output = `cd #{gem_root} && gem bump --pretend --file lib/cypress_on_rails/version.rb #{gem_version.strip.empty? ? '' : %(--version #{gem_version})}`
  # Parse output to get version
  puts "DRY RUN: Would have committed, tagged v<version>, pushed, and released gem"
end

Run this script to check if gem bump supports --pretend:


🏁 Script executed:

#!/bin/bash
gem bump --help | grep -E '(pretend|dry.?run|simulate)' -i

Length of output: 83


Handle undefined actual_version in dry-run branch

After moving the bump/install into the production path, actual_version no longer exists in the else branch and will trigger an undefined variable error. Replace the dry-run message with a manual version calculation (since gem bump --pretend isn’t supported):

else
  require_relative "../lib/cypress_on_rails/version"
  current_version = CypressOnRails::VERSION
  gem_version_strip = gem_version.strip
  next_version = if gem_version_strip.empty?
    parts = current_version.split('.')
    parts[-1] = (parts[-1].to_i + 1).to_s
    parts.join('.')
  else
    gem_version_strip
  end
  puts "DRY RUN: Would have committed, tagged v#{next_version}, pushed, and released gem"
end
🤖 Prompt for AI Agents
In rakelib/release.rake around line 67, the dry-run branch references undefined
actual_version after moving bump/install into the production path; fix by
loading the current gem version (require_relative
"../lib/cypress_on_rails/version" and read CypressOnRails::VERSION), strip
gem_version, and compute next_version: if gem_version is blank, split current
version on '.', increment the last numeric segment and rejoin, otherwise use the
stripped gem_version; then use next_version in the dry-run puts message so no
undefined variable is referenced.

end

msg = <<~MSG
Once you have successfully published, run these commands to update CHANGELOG.md:
Expand Down