Skip to content

Commit 2ba5e8d

Browse files
authored
Fix release task to commit version bump before gem release (#195)
1 parent 5e4041d commit 2ba5e8d

File tree

2 files changed

+87
-93
lines changed

2 files changed

+87
-93
lines changed

RELEASING.md

Lines changed: 62 additions & 89 deletions
Original file line numberDiff line numberDiff line change
@@ -10,80 +10,61 @@ This document describes how to release a new version of cypress-playwright-on-ra
1010
4. Development dependencies installed: `bundle install`
1111
- Includes `gem-release` for gem management (like react_on_rails)
1212

13-
## Release Tasks
13+
## Release Command
1414

15-
The project uses rake tasks with `gem-release` to automate the release process (similar to react_on_rails and other ShakaCode gems):
16-
17-
### Quick Release
18-
19-
```bash
20-
# Prepare and publish in one command
21-
rake release:prepare[1.19.0]
22-
# Review changes, commit
23-
rake release:publish
24-
```
25-
26-
### Step-by-Step Release
27-
28-
#### 1. Prepare the Release
15+
The project uses a single rake task to automate the entire release process:
2916

3017
```bash
31-
rake release:prepare[1.19.0]
18+
rake release[VERSION,DRY_RUN]
3219
```
3320

34-
This task will:
35-
- Validate the version format (X.Y.Z)
36-
- Use `gem bump` to update `lib/cypress_on_rails/version.rb`
37-
- Update `CHANGELOG.md` with the new version and date
38-
- Provide next steps
21+
### Examples
3922

40-
After running this:
4123
```bash
42-
# Review the changes
43-
git diff
24+
# Release version 1.19.0
25+
rake release[1.19.0]
4426

45-
# Commit the version bump
46-
git add -A
47-
git commit -m "Bump version to 1.19.0"
27+
# Automatic patch version bump (e.g., 1.18.0 -> 1.18.1)
28+
rake release
4829

49-
# Push to master
50-
git push origin master
30+
# Dry run to preview what would happen
31+
rake release[1.19.0,true]
5132
```
5233

53-
#### 2. Publish the Release
34+
### What the Release Task Does
5435

55-
```bash
56-
rake release:publish
57-
```
36+
The `rake release` task will:
5837

59-
This task will:
60-
- Verify you're on master branch
61-
- Verify working directory is clean
62-
- Run the test suite
63-
- Use `gem release` to:
64-
- Build the gem
65-
- Push the gem to RubyGems
66-
- Create a git tag (e.g., `v1.19.0`)
67-
- Push the tag to GitHub
38+
1. Pull latest changes from master
39+
2. Bump the version in `lib/cypress_on_rails/version.rb`
40+
3. Update `Gemfile.lock` via `bundle install`
41+
4. Commit the version bump and Gemfile.lock changes
42+
5. Create a git tag (e.g., `v1.19.0`)
43+
6. Push the commit and tag to GitHub
44+
7. Build and publish the gem to RubyGems (will prompt for OTP)
6845

69-
#### 3. Post-Release Steps
46+
### Post-Release Steps
7047

7148
After publishing, complete these manual steps:
7249

73-
1. **Create GitHub Release**
74-
- Go to https://github.com/shakacode/cypress-playwright-on-rails/releases/new?tag=v1.19.0
50+
1. **Update CHANGELOG.md**
51+
```bash
52+
bundle exec rake update_changelog
53+
git commit -a -m 'Update CHANGELOG.md'
54+
git push
55+
```
56+
57+
2. **Create GitHub Release**
58+
- Go to the releases page: https://github.com/shakacode/cypress-playwright-on-rails/releases
59+
- Click on the newly created tag
7560
- Copy release notes from CHANGELOG.md
7661
- Publish the release
7762

78-
2. **Announce the Release**
63+
3. **Announce the Release** (optional)
7964
- Post in Slack channel
8065
- Tweet about the release
8166
- Update forum posts if needed
8267

83-
3. **Close Related Issues**
84-
- Review issues addressed in this release
85-
- Close them with reference to the release
86-
8768
## Version Numbering
8869

8970
Follow [Semantic Versioning](https://semver.org/):
@@ -96,25 +77,27 @@ Follow [Semantic Versioning](https://semver.org/):
9677

9778
```bash
9879
# Patch release (bug fixes)
99-
rake release:prepare[1.18.1]
80+
rake release[1.18.1]
10081

10182
# Minor release (new features)
102-
rake release:prepare[1.19.0]
83+
rake release[1.19.0]
10384

10485
# Major release (breaking changes)
105-
rake release:prepare[2.0.0]
86+
rake release[2.0.0]
87+
88+
# Automatic patch bump
89+
rake release
10690
```
10791

10892
## Pre-Release Checklist
10993

110-
Before running `rake release:prepare`:
94+
Before running `rake release`:
11195

11296
- [ ] All PRs for the release are merged
11397
- [ ] CI is passing on master
11498
- [ ] CHANGELOG.md has [Unreleased] section with all changes
11599
- [ ] Major changes have been tested manually
116100
- [ ] Documentation is up to date
117-
- [ ] Issue #183 discussion is resolved (if applicable)
118101

119102
## Troubleshooting
120103

@@ -135,14 +118,6 @@ git add -A && git commit -m "Your message"
135118
git stash
136119
```
137120

138-
### "Tests failed" error
139-
140-
```bash
141-
# Fix the failing tests before releasing
142-
bundle exec rake spec
143-
144-
# If tests are truly failing, don't release
145-
```
146121

147122
### "Failed to push gem to RubyGems" error
148123

@@ -154,16 +129,19 @@ gem signin
154129

155130
### Tag already exists
156131

157-
If you need to re-release:
132+
If you need to re-release the same version:
158133
```bash
159134
# Delete local tag
160135
git tag -d v1.19.0
161136

162137
# Delete remote tag
163138
git push origin :v1.19.0
164139

165-
# Try again
166-
rake release:publish
140+
# Reset to before the release commit
141+
git reset --hard HEAD~1
142+
143+
# Try the release again
144+
rake release[1.19.0]
167145
```
168146

169147
## Rollback
@@ -194,34 +172,29 @@ git push origin master
194172
git checkout master
195173
git pull --rebase
196174

197-
# 2. Prepare the release
198-
rake release:prepare[1.19.0]
199-
# Review output, confirm with 'y'
200-
201-
# 3. Review and commit changes
202-
git diff
203-
git add -A
204-
git commit -m "Bump version to 1.19.0"
175+
# 2. Check CI is passing
176+
# Visit: https://github.com/shakacode/cypress-playwright-on-rails/actions
205177

206-
# 4. Run tests (optional, publish will run them too)
207-
bundle exec rake spec
208-
209-
# 5. Push to master
210-
git push origin master
178+
# 3. Release (will handle everything automatically)
179+
rake release[1.19.0]
180+
# Enter your RubyGems OTP when prompted
211181

212-
# 6. Publish the release
213-
rake release:publish
182+
# 4. Update the changelog
183+
bundle exec rake update_changelog
184+
git commit -a -m 'Update CHANGELOG.md'
185+
git push
214186

215-
# 7. Create GitHub release
216-
open "https://github.com/shakacode/cypress-playwright-on-rails/releases/new?tag=v1.19.0"
187+
# 5. Create GitHub release
188+
open "https://github.com/shakacode/cypress-playwright-on-rails/releases"
189+
# Click on the new tag, add release notes from CHANGELOG.md
217190

218-
# 8. Celebrate! 🎉
191+
# 6. Celebrate! 🎉
219192
```
220193

221194
## Notes
222195

223-
- The release tasks will **not** push commits to master for you
224-
- Always review changes before committing
225-
- The `publish` task will run tests before releasing
226-
- Tags are created locally first, then pushed
227-
- Failed releases can be retried after fixing issues
196+
- The release task handles all git operations (commit, tag, push) automatically
197+
- Always ensure CI is green before releasing
198+
- The task will fail fast if working directory is not clean
199+
- Failed releases can be retried after fixing issues
200+
- Use dry run mode (`rake release[VERSION,true]`) to preview changes

rakelib/release.rake

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,32 @@ 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 --file lib/cypress_on_rails/version.rb #{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? ? '' : %(--version #{gem_version})}")
4444

45-
# Release the new gem version
46-
puts "Carefully add your OTP for Rubygems. If you get an error, run 'gem release' again."
47-
sh_in_dir(gem_root, "gem release") unless is_dry_run
45+
# Read the actual version from the file after bump
46+
load File.expand_path("../lib/cypress_on_rails/version.rb", __dir__)
47+
actual_version = CypressOnRails::VERSION
48+
49+
# Update Gemfile.lock files
50+
sh_in_dir(gem_root, "bundle install")
51+
52+
unless is_dry_run
53+
# Commit the version bump and Gemfile.lock update
54+
sh_in_dir(gem_root, "git add lib/cypress_on_rails/version.rb Gemfile.lock")
55+
sh_in_dir(gem_root, "git commit -m \"Release v#{actual_version}\"")
56+
57+
# Tag the release
58+
sh_in_dir(gem_root, "git tag v#{actual_version}")
59+
60+
# Push the commit and tag
61+
sh_in_dir(gem_root, "git push && git push --tags")
62+
63+
# Release the new gem version
64+
puts "Carefully add your OTP for Rubygems. If you get an error, run 'gem release' again."
65+
sh_in_dir(gem_root, "gem release")
66+
else
67+
puts "DRY RUN: Would have committed, tagged v#{actual_version}, pushed, and released gem"
68+
end
4869

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

0 commit comments

Comments
 (0)