-
-
Notifications
You must be signed in to change notification settings - Fork 62
Fix release task to commit version bump before gem release (#???) #195
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
Changes from 1 commit
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 | ||||
---|---|---|---|---|---|---|
|
@@ -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") | ||||||
|
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.
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.
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.
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.
❓ 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:
- 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
- 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.
Uh oh!
There was an error while loading. Please reload this page.