Skip to content

Commit ac7d59a

Browse files
justin808claude
andcommitted
Add automated release rake tasks
Implements rake tasks for automating the release process, similar to Shakapacker. New rake tasks: - rake release:prepare[VERSION] - Bumps version and updates CHANGELOG - rake release:publish - Tags, builds, and publishes gem to RubyGems - rake release:full[VERSION] - Complete release in one command Features: - Validates semantic versioning format - Confirms before making changes - Updates version.rb automatically - Updates CHANGELOG.md with date and compare link - Runs test suite before publishing - Creates and pushes git tags - Builds and publishes to RubyGems - Provides clear next steps after each phase Documentation: - RELEASING.md with complete release process guide - Troubleshooting section for common issues - Examples and pre-release checklist This eliminates the need for a manual PR to bump versions. Instead, maintainers can run: rake release:prepare[1.19.0] 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
1 parent 5cea37d commit ac7d59a

File tree

2 files changed

+362
-1
lines changed

2 files changed

+362
-1
lines changed

RELEASING.md

Lines changed: 225 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,225 @@
1+
# Release Process
2+
3+
This document describes how to release a new version of cypress-playwright-on-rails.
4+
5+
## Prerequisites
6+
7+
1. Maintainer access to the repository
8+
2. RubyGems account with publish permissions for `cypress-on-rails`
9+
3. Clean working directory on `master` branch
10+
11+
## Release Tasks
12+
13+
The project includes rake tasks to automate the release process:
14+
15+
### Quick Release
16+
17+
```bash
18+
# Prepare and publish in one command
19+
rake release:prepare[1.19.0]
20+
# Review changes, commit
21+
rake release:publish
22+
```
23+
24+
### Step-by-Step Release
25+
26+
#### 1. Prepare the Release
27+
28+
```bash
29+
rake release:prepare[1.19.0]
30+
```
31+
32+
This task will:
33+
- Validate the version format (X.Y.Z)
34+
- Update `lib/cypress_on_rails/version.rb`
35+
- Update `CHANGELOG.md` with the new version and date
36+
- Provide next steps
37+
38+
After running this:
39+
```bash
40+
# Review the changes
41+
git diff
42+
43+
# Commit the version bump
44+
git add -A
45+
git commit -m "Bump version to 1.19.0"
46+
47+
# Push to master
48+
git push origin master
49+
```
50+
51+
#### 2. Publish the Release
52+
53+
```bash
54+
rake release:publish
55+
```
56+
57+
This task will:
58+
- Verify you're on master branch
59+
- Verify working directory is clean
60+
- Run the test suite
61+
- Create a git tag (e.g., `v1.19.0`)
62+
- Push the tag to GitHub
63+
- Build the gem
64+
- Push the gem to RubyGems
65+
- Clean up the gem file
66+
67+
#### 3. Post-Release Steps
68+
69+
After publishing, complete these manual steps:
70+
71+
1. **Create GitHub Release**
72+
- Go to https://github.com/shakacode/cypress-playwright-on-rails/releases/new?tag=v1.19.0
73+
- Copy release notes from CHANGELOG.md
74+
- Publish the release
75+
76+
2. **Announce the Release**
77+
- Post in Slack channel
78+
- Tweet about the release
79+
- Update forum posts if needed
80+
81+
3. **Close Related Issues**
82+
- Review issues addressed in this release
83+
- Close them with reference to the release
84+
85+
## Version Numbering
86+
87+
Follow [Semantic Versioning](https://semver.org/):
88+
89+
- **MAJOR** (X.0.0): Breaking changes
90+
- **MINOR** (1.X.0): New features, backwards compatible
91+
- **PATCH** (1.19.X): Bug fixes, backwards compatible
92+
93+
### Examples
94+
95+
```bash
96+
# Patch release (bug fixes)
97+
rake release:prepare[1.18.1]
98+
99+
# Minor release (new features)
100+
rake release:prepare[1.19.0]
101+
102+
# Major release (breaking changes)
103+
rake release:prepare[2.0.0]
104+
```
105+
106+
## Pre-Release Checklist
107+
108+
Before running `rake release:prepare`:
109+
110+
- [ ] All PRs for the release are merged
111+
- [ ] CI is passing on master
112+
- [ ] CHANGELOG.md has [Unreleased] section with all changes
113+
- [ ] Major changes have been tested manually
114+
- [ ] Documentation is up to date
115+
- [ ] Issue #183 discussion is resolved (if applicable)
116+
117+
## Troubleshooting
118+
119+
### "Must be on master branch" error
120+
121+
```bash
122+
git checkout master
123+
git pull --rebase
124+
```
125+
126+
### "Working directory is not clean" error
127+
128+
```bash
129+
# Commit or stash your changes
130+
git status
131+
git add -A && git commit -m "Your message"
132+
# or
133+
git stash
134+
```
135+
136+
### "Tests failed" error
137+
138+
```bash
139+
# Fix the failing tests before releasing
140+
bundle exec rake spec
141+
142+
# If tests are truly failing, don't release
143+
```
144+
145+
### "Failed to push gem to RubyGems" error
146+
147+
Ensure you're authenticated with RubyGems:
148+
```bash
149+
gem signin
150+
# Enter your RubyGems credentials
151+
```
152+
153+
### Tag already exists
154+
155+
If you need to re-release:
156+
```bash
157+
# Delete local tag
158+
git tag -d v1.19.0
159+
160+
# Delete remote tag
161+
git push origin :v1.19.0
162+
163+
# Try again
164+
rake release:publish
165+
```
166+
167+
## Rollback
168+
169+
If you need to rollback a release:
170+
171+
### Yank the gem from RubyGems
172+
```bash
173+
gem yank cypress-on-rails -v 1.19.0
174+
```
175+
176+
### Delete the git tag
177+
```bash
178+
git tag -d v1.19.0
179+
git push origin :v1.19.0
180+
```
181+
182+
### Revert the version commit
183+
```bash
184+
git revert HEAD
185+
git push origin master
186+
```
187+
188+
## Example Release Flow
189+
190+
```bash
191+
# 1. Ensure you're on master and up to date
192+
git checkout master
193+
git pull --rebase
194+
195+
# 2. Prepare the release
196+
rake release:prepare[1.19.0]
197+
# Review output, confirm with 'y'
198+
199+
# 3. Review and commit changes
200+
git diff
201+
git add -A
202+
git commit -m "Bump version to 1.19.0"
203+
204+
# 4. Run tests (optional, publish will run them too)
205+
bundle exec rake spec
206+
207+
# 5. Push to master
208+
git push origin master
209+
210+
# 6. Publish the release
211+
rake release:publish
212+
213+
# 7. Create GitHub release
214+
open "https://github.com/shakacode/cypress-playwright-on-rails/releases/new?tag=v1.19.0"
215+
216+
# 8. Celebrate! 🎉
217+
```
218+
219+
## Notes
220+
221+
- The release tasks will **not** push commits to master for you
222+
- Always review changes before committing
223+
- The `publish` task will run tests before releasing
224+
- Tags are created locally first, then pushed
225+
- Failed releases can be retried after fixing issues

Rakefile

Lines changed: 137 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,145 @@
11
require 'bundler/gem_tasks'
22

3-
43
require 'rspec/core/rake_task'
54
RSpec::Core::RakeTask.new(:spec) do |t|
65
t.pattern = 'spec/cypress_on_rails/*_spec.rb'
76
end
87

98
task default: %w[spec build]
9+
10+
namespace :release do
11+
desc "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+
# Update version file
40+
version_file = 'lib/cypress_on_rails/version.rb'
41+
content = File.read(version_file)
42+
content.gsub!(/VERSION = '[^']+'/, "VERSION = '#{version}'")
43+
File.write(version_file, content)
44+
puts "✓ Updated #{version_file}"
45+
46+
# Update CHANGELOG
47+
changelog_file = 'CHANGELOG.md'
48+
changelog = File.read(changelog_file)
49+
50+
today = Time.now.strftime('%Y-%m-%d')
51+
52+
# Replace [Unreleased] with versioned entry
53+
if changelog.match?(/## \[Unreleased\]/)
54+
changelog.sub!(
55+
/## \[Unreleased\]/,
56+
"## [Unreleased]\n\n---\n\n## [#{version}] — #{today}\n[Compare]: https://github.com/shakacode/cypress-playwright-on-rails/compare/v#{current_version}...v#{version}"
57+
)
58+
File.write(changelog_file, changelog)
59+
puts "✓ Updated #{changelog_file}"
60+
else
61+
puts "Warning: Could not find [Unreleased] section in CHANGELOG.md"
62+
end
63+
64+
puts "\n✓ Version prepared!"
65+
puts "\nNext steps:"
66+
puts " 1. Review changes: git diff"
67+
puts " 2. Commit: git add -A && git commit -m 'Bump version to #{version}'"
68+
puts " 3. Run tests: bundle exec rake spec"
69+
puts " 4. Release: rake release:publish"
70+
end
71+
72+
desc "Tag, build, and push gem to RubyGems"
73+
task :publish do
74+
require_relative 'lib/cypress_on_rails/version'
75+
version = CypressOnRails::VERSION
76+
77+
# Ensure we're on master and up to date
78+
current_branch = `git rev-parse --abbrev-ref HEAD`.chomp
79+
unless current_branch == 'master'
80+
puts "Error: Must be on master branch to release (currently on #{current_branch})"
81+
exit 1
82+
end
83+
84+
if `git status --porcelain`.chomp != ''
85+
puts "Error: Working directory is not clean. Commit or stash changes first."
86+
exit 1
87+
end
88+
89+
puts "Preparing to release version #{version}..."
90+
91+
# Run tests
92+
puts "\n→ Running tests..."
93+
unless system('bundle exec rake spec')
94+
puts "Error: Tests failed. Fix them before releasing."
95+
exit 1
96+
end
97+
puts "✓ Tests passed"
98+
99+
# Create git tag
100+
tag_name = "v#{version}"
101+
puts "\n→ Creating git tag #{tag_name}..."
102+
unless system("git tag -a #{tag_name} -m 'Release version #{version}'")
103+
puts "Error: Failed to create git tag"
104+
exit 1
105+
end
106+
puts "✓ Tag created"
107+
108+
# Push tag
109+
puts "\n→ Pushing tag to origin..."
110+
unless system("git push origin #{tag_name}")
111+
puts "Error: Failed to push tag"
112+
exit 1
113+
end
114+
puts "✓ Tag pushed"
115+
116+
# Build gem
117+
puts "\n→ Building gem..."
118+
unless system('gem build cypress-on-rails.gemspec')
119+
puts "Error: Failed to build gem"
120+
exit 1
121+
end
122+
puts "✓ Gem built"
123+
124+
# Push to RubyGems
125+
gem_file = "cypress-on-rails-#{version}.gem"
126+
puts "\n→ Pushing #{gem_file} to RubyGems..."
127+
unless system("gem push #{gem_file}")
128+
puts "Error: Failed to push gem to RubyGems"
129+
exit 1
130+
end
131+
puts "✓ Gem published"
132+
133+
# Clean up gem file
134+
File.delete(gem_file) if File.exist?(gem_file)
135+
136+
puts "\n🎉 Successfully released version #{version}!"
137+
puts "\nNext steps:"
138+
puts " 1. Create GitHub release: https://github.com/shakacode/cypress-playwright-on-rails/releases/new?tag=v#{version}"
139+
puts " 2. Announce on Slack/Twitter"
140+
puts " 3. Close related issues"
141+
end
142+
143+
desc "Full release process (prepare + publish)"
144+
task :full, [:version] => [:prepare, :publish]
145+
end

0 commit comments

Comments
 (0)