Skip to content

Commit 95f95cf

Browse files
justin808claude
andcommitted
Fix release task conflicts by moving to rakelib
Fixed the mess caused by having two different release rake files: - lib/tasks/release.rake (our custom task) - Rakefile (with release:prepare and release:publish) Changes: 1. Removed lib/tasks/release.rake to avoid shadowing bundler/gem_tasks 2. Created rakelib/ directory (auto-loaded by Rake) 3. Moved release tasks from Rakefile to rakelib/release.rake 4. Fixed gem bump flag: changed --version to -v (line 33) 5. Cleaned up Rakefile to only have bundler/gem_tasks and specs The rakelib/ directory is automatically loaded by Rake (similar to react_on_rails), which explains why react_on_rails uses this pattern. Now the release workflow is: - rake release:prepare[X.Y.Z] - Bumps version and updates CHANGELOG - rake release:publish - Runs tests, tags, and publishes gem 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
1 parent 1a629c4 commit 95f95cf

File tree

3 files changed

+110
-170
lines changed

3 files changed

+110
-170
lines changed

Rakefile

Lines changed: 0 additions & 109 deletions
Original file line numberDiff line numberDiff line change
@@ -6,112 +6,3 @@ RSpec::Core::RakeTask.new(:spec) do |t|
66
end
77

88
task default: %w[spec build]
9-
10-
namespace :release do
11-
desc "Prepare release: bump version and update changelog"
12-
task :prepare, [:version] do |_t, args|
13-
require_relative 'lib/cypress_on_rails/version'
14-
15-
version = args[:version]
16-
unless version
17-
puts "Usage: rake release:prepare[VERSION]"
18-
puts "Example: rake release:prepare[1.19.0]"
19-
exit 1
20-
end
21-
22-
unless version.match?(/^\d+\.\d+\.\d+$/)
23-
puts "Error: Version must be in format X.Y.Z (e.g., 1.19.0)"
24-
exit 1
25-
end
26-
27-
current_version = CypressOnRails::VERSION
28-
puts "Current version: #{current_version}"
29-
puts "New version: #{version}"
30-
31-
# Confirm the version bump
32-
print "Continue? (y/n): "
33-
response = $stdin.gets.chomp.downcase
34-
unless response == 'y'
35-
puts "Aborted."
36-
exit 0
37-
end
38-
39-
# Use gem bump to update version
40-
puts "\n→ Bumping version with gem-release..."
41-
unless system("gem bump --version #{version} --no-commit")
42-
puts "Error: Failed to bump version"
43-
exit 1
44-
end
45-
puts "✓ Updated version to #{version}"
46-
47-
# Update CHANGELOG
48-
update_changelog(version, current_version)
49-
50-
puts "\n✓ Version prepared!"
51-
puts "\nNext steps:"
52-
puts " 1. Review changes: git diff"
53-
puts " 2. Commit: git add -A && git commit -m 'Bump version to #{version}'"
54-
puts " 3. Push: git push origin master"
55-
puts " 4. Release: rake release:publish"
56-
end
57-
58-
desc "Publish release: tag, build, and push gem"
59-
task :publish do
60-
require_relative 'lib/cypress_on_rails/version'
61-
version = CypressOnRails::VERSION
62-
63-
# Pre-flight checks
64-
current_branch = `git rev-parse --abbrev-ref HEAD`.chomp
65-
unless current_branch == 'master'
66-
puts "Error: Must be on master branch to release (currently on #{current_branch})"
67-
exit 1
68-
end
69-
70-
if `git status --porcelain`.chomp != ''
71-
puts "Error: Working directory is not clean. Commit or stash changes first."
72-
exit 1
73-
end
74-
75-
puts "Preparing to release version #{version}..."
76-
77-
# Run tests
78-
puts "\n→ Running tests..."
79-
unless system('bundle exec rake spec')
80-
puts "Error: Tests failed. Fix them before releasing."
81-
exit 1
82-
end
83-
puts "✓ Tests passed"
84-
85-
# Use gem release command
86-
puts "\n→ Releasing gem with gem-release..."
87-
unless system("gem release --tag --push")
88-
puts "Error: Failed to release gem"
89-
exit 1
90-
end
91-
92-
puts "\n🎉 Successfully released version #{version}!"
93-
puts "\nNext steps:"
94-
puts " 1. Create GitHub release: https://github.com/shakacode/cypress-playwright-on-rails/releases/new?tag=v#{version}"
95-
puts " 2. Announce on Slack/Twitter"
96-
puts " 3. Close related issues"
97-
end
98-
end
99-
100-
def update_changelog(version, current_version)
101-
changelog_file = 'CHANGELOG.md'
102-
changelog = File.read(changelog_file)
103-
104-
today = Time.now.strftime('%Y-%m-%d')
105-
106-
# Replace [Unreleased] with versioned entry
107-
if changelog.match?(/## \[Unreleased\]/)
108-
changelog.sub!(
109-
/## \[Unreleased\]/,
110-
"## [Unreleased]\n\n---\n\n## [#{version}] — #{today}\n[Compare]: https://github.com/shakacode/cypress-playwright-on-rails/compare/v#{current_version}...v#{version}"
111-
)
112-
File.write(changelog_file, changelog)
113-
puts "✓ Updated #{changelog_file}"
114-
else
115-
puts "Warning: Could not find [Unreleased] section in CHANGELOG.md"
116-
end
117-
end

lib/tasks/release.rake

Lines changed: 0 additions & 61 deletions
This file was deleted.

rakelib/release.rake

Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
# frozen_string_literal: true
2+
3+
namespace :release do
4+
desc "Prepare release: bump version and update changelog"
5+
task :prepare, [:version] do |_t, args|
6+
require_relative '../lib/cypress_on_rails/version'
7+
8+
version = args[:version]
9+
unless version
10+
puts "Usage: rake release:prepare[VERSION]"
11+
puts "Example: rake release:prepare[1.19.0]"
12+
exit 1
13+
end
14+
15+
unless version.match?(/^\d+\.\d+\.\d+$/)
16+
puts "Error: Version must be in format X.Y.Z (e.g., 1.19.0)"
17+
exit 1
18+
end
19+
20+
current_version = CypressOnRails::VERSION
21+
puts "Current version: #{current_version}"
22+
puts "New version: #{version}"
23+
24+
# Confirm the version bump
25+
print "Continue? (y/n): "
26+
response = $stdin.gets.chomp.downcase
27+
unless response == 'y'
28+
puts "Aborted."
29+
exit 0
30+
end
31+
32+
# Use gem bump to update version
33+
puts "\n→ Bumping version with gem-release..."
34+
unless system("gem bump -v #{version} --no-commit")
35+
puts "Error: Failed to bump version"
36+
exit 1
37+
end
38+
puts "✓ Updated version to #{version}"
39+
40+
# Update CHANGELOG
41+
update_changelog(version, current_version)
42+
43+
puts "\n✓ Version prepared!"
44+
puts "\nNext steps:"
45+
puts " 1. Review changes: git diff"
46+
puts " 2. Commit: git add -A && git commit -m 'Bump version to #{version}'"
47+
puts " 3. Push: git push origin master"
48+
puts " 4. Release: rake release:publish"
49+
end
50+
51+
desc "Publish release: tag, build, and push gem"
52+
task :publish do
53+
require_relative '../lib/cypress_on_rails/version'
54+
version = CypressOnRails::VERSION
55+
56+
# Pre-flight checks
57+
current_branch = `git rev-parse --abbrev-ref HEAD`.chomp
58+
unless current_branch == 'master'
59+
puts "Error: Must be on master branch to release (currently on #{current_branch})"
60+
exit 1
61+
end
62+
63+
if `git status --porcelain`.chomp != ''
64+
puts "Error: Working directory is not clean. Commit or stash changes first."
65+
exit 1
66+
end
67+
68+
puts "Preparing to release version #{version}..."
69+
70+
# Run tests
71+
puts "\n→ Running tests..."
72+
unless system('bundle exec rake spec')
73+
puts "Error: Tests failed. Fix them before releasing."
74+
exit 1
75+
end
76+
puts "✓ Tests passed"
77+
78+
# Use gem release command
79+
puts "\n→ Releasing gem with gem-release..."
80+
unless system("gem release --tag --push")
81+
puts "Error: Failed to release gem"
82+
exit 1
83+
end
84+
85+
puts "\n🎉 Successfully released version #{version}!"
86+
puts "\nNext steps:"
87+
puts " 1. Create GitHub release: https://github.com/shakacode/cypress-playwright-on-rails/releases/new?tag=v#{version}"
88+
puts " 2. Announce on Slack/Twitter"
89+
puts " 3. Close related issues"
90+
end
91+
end
92+
93+
def update_changelog(version, current_version)
94+
changelog_file = 'CHANGELOG.md'
95+
changelog = File.read(changelog_file)
96+
97+
today = Time.now.strftime('%Y-%m-%d')
98+
99+
# Replace [Unreleased] with versioned entry
100+
if changelog.match?(/## \[Unreleased\]/)
101+
changelog.sub!(
102+
/## \[Unreleased\]/,
103+
"## [Unreleased]\n\n---\n\n## [#{version}] — #{today}\n[Compare]: https://github.com/shakacode/cypress-playwright-on-rails/compare/v#{current_version}...v#{version}"
104+
)
105+
File.write(changelog_file, changelog)
106+
puts "✓ Updated #{changelog_file}"
107+
else
108+
puts "Warning: Could not find [Unreleased] section in CHANGELOG.md"
109+
end
110+
end

0 commit comments

Comments
 (0)