Skip to content

Commit f202e39

Browse files
authored
Add simple release script (gem-only) (#192)
* Remove bundler/gem_tasks to fix release task conflict Removed `require 'bundler/gem_tasks'` from Rakefile because it creates a conflicting `release` task that shadows our custom release task in rakelib/release.rake. Added manual :build task to replace what bundler/gem_tasks provided. This matches the react_on_rails pattern where rakelib/release.rake provides the release task without conflicts. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]> * Simplify release script to match react_on_rails without npm Cleaned up release.rake to exactly match react_on_rails pattern but without the npm/release-it parts that aren't needed for cypress-on-rails. Removed from react_on_rails version: - npm_version conversion logic - release-it command execution - Gemfile.lock updates for dummy apps - gemspec cleanup for subdirectories - GitHub packages publishing Kept from react_on_rails version: - Same structure and flow - RaisingMessageHandler class - TaskHelpers include pattern - git pull --rebase - gem bump with -v flag (fixed from --version) - gem release to rubygems.org - Post-release CHANGELOG reminder 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]> * Fix sh_in_dir to use Dir.chdir like react_on_rails * Add --file flag to gem bump for version file detection * Simplify Rakefile - remove unnecessary build task The build task was not needed: - gem release command handles building the gem - We don't need a separate build step - The default task can just run specs This makes the Rakefile cleaner and simpler.
1 parent 8615fc7 commit f202e39

File tree

3 files changed

+14
-8
lines changed

3 files changed

+14
-8
lines changed

Rakefile

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
1-
require 'bundler/gem_tasks'
2-
31
require 'rspec/core/rake_task'
42
RSpec::Core::RakeTask.new(:spec) do |t|
53
t.pattern = 'spec/cypress_on_rails/*_spec.rb'
64
end
75

8-
task default: %w[spec build]
6+
task default: :spec

rakelib/release.rake

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,15 @@ desc("Releases the gem using the given version.
1515
1616
IMPORTANT: the gem version must be in valid rubygem format (no dashes).
1717
18-
This task depends on the gem-release ruby gem which is installed via `bundle install`
18+
This task depends on the gem-release (ruby gem) which is installed via `bundle install`
1919
2020
1st argument: The new version in rubygem format (no dashes). Pass no argument to
2121
automatically perform a patch version bump.
2222
2nd argument: Perform a dry run by passing 'true' as a second argument.
2323
2424
Note, accept defaults for rubygems options. Script will pause to get 2FA tokens.
2525
26-
Example: `rake release[1.19.0,false]`")
26+
Example: `rake release[2.1.0,false]`")
2727
task :release, %i[gem_version dry_run] do |_t, args|
2828
include CypressOnRails::TaskHelpers
2929

@@ -40,7 +40,7 @@ task :release, %i[gem_version dry_run] do |_t, args|
4040

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

4545
# Release the new gem version
4646
puts "Carefully add your OTP for Rubygems. If you get an error, run 'gem release' again."

rakelib/task_helpers.rb

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,15 @@ def gem_root
99

1010
# Executes a string or an array of strings in a shell in the given directory
1111
def sh_in_dir(dir, *shell_commands)
12-
shell_commands.flatten.each { |shell_command| sh %(cd #{dir} && #{shell_command.strip}) }
12+
Dir.chdir(dir) do
13+
# Without `with_unbundled_env`, running bundle in the child directories won't correctly
14+
# update the Gemfile.lock
15+
Bundler.with_unbundled_env do
16+
shell_commands.flatten.each do |shell_command|
17+
sh(shell_command.strip)
18+
end
19+
end
20+
end
1321
end
1422
end
15-
end
23+
end

0 commit comments

Comments
 (0)