Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
151 changes: 62 additions & 89 deletions RELEASING.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,80 +10,61 @@ This document describes how to release a new version of cypress-playwright-on-ra
4. Development dependencies installed: `bundle install`
- Includes `gem-release` for gem management (like react_on_rails)

## Release Tasks
## Release Command

The project uses rake tasks with `gem-release` to automate the release process (similar to react_on_rails and other ShakaCode gems):

### Quick Release

```bash
# Prepare and publish in one command
rake release:prepare[1.19.0]
# Review changes, commit
rake release:publish
```

### Step-by-Step Release

#### 1. Prepare the Release
The project uses a single rake task to automate the entire release process:

```bash
rake release:prepare[1.19.0]
rake release[VERSION,DRY_RUN]
```

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

After running this:
```bash
# Review the changes
git diff
# Release version 1.19.0
rake release[1.19.0]

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

# Push to master
git push origin master
# Dry run to preview what would happen
rake release[1.19.0,true]
```

#### 2. Publish the Release
### What the Release Task Does

```bash
rake release:publish
```
The `rake release` task will:

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

#### 3. Post-Release Steps
### Post-Release Steps

After publishing, complete these manual steps:

1. **Create GitHub Release**
- Go to https://github.com/shakacode/cypress-playwright-on-rails/releases/new?tag=v1.19.0
1. **Update CHANGELOG.md**
```bash
bundle exec rake update_changelog
git commit -a -m 'Update CHANGELOG.md'
git push
```

2. **Create GitHub Release**
- Go to the releases page: https://github.com/shakacode/cypress-playwright-on-rails/releases
- Click on the newly created tag
- Copy release notes from CHANGELOG.md
- Publish the release

2. **Announce the Release**
3. **Announce the Release** (optional)
- Post in Slack channel
- Tweet about the release
- Update forum posts if needed

3. **Close Related Issues**
- Review issues addressed in this release
- Close them with reference to the release

## Version Numbering

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

```bash
# Patch release (bug fixes)
rake release:prepare[1.18.1]
rake release[1.18.1]

# Minor release (new features)
rake release:prepare[1.19.0]
rake release[1.19.0]

# Major release (breaking changes)
rake release:prepare[2.0.0]
rake release[2.0.0]

# Automatic patch bump
rake release
```

## Pre-Release Checklist

Before running `rake release:prepare`:
Before running `rake release`:

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

## Troubleshooting

Expand All @@ -135,14 +118,6 @@ git add -A && git commit -m "Your message"
git stash
```

### "Tests failed" error

```bash
# Fix the failing tests before releasing
bundle exec rake spec

# If tests are truly failing, don't release
```

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

Expand All @@ -154,16 +129,19 @@ gem signin

### Tag already exists

If you need to re-release:
If you need to re-release the same version:
```bash
# Delete local tag
git tag -d v1.19.0

# Delete remote tag
git push origin :v1.19.0

# Try again
rake release:publish
# Reset to before the release commit
git reset --hard HEAD~1

# Try the release again
rake release[1.19.0]
```

## Rollback
Expand Down Expand Up @@ -194,34 +172,29 @@ git push origin master
git checkout master
git pull --rebase

# 2. Prepare the release
rake release:prepare[1.19.0]
# Review output, confirm with 'y'

# 3. Review and commit changes
git diff
git add -A
git commit -m "Bump version to 1.19.0"
# 2. Check CI is passing
# Visit: https://github.com/shakacode/cypress-playwright-on-rails/actions

# 4. Run tests (optional, publish will run them too)
bundle exec rake spec

# 5. Push to master
git push origin master
# 3. Release (will handle everything automatically)
rake release[1.19.0]
# Enter your RubyGems OTP when prompted

# 6. Publish the release
rake release:publish
# 4. Update the changelog
bundle exec rake update_changelog
git commit -a -m 'Update CHANGELOG.md'
git push

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

# 8. Celebrate! 🎉
# 6. Celebrate! 🎉
```

## Notes

- The release tasks will **not** push commits to master for you
- Always review changes before committing
- The `publish` task will run tests before releasing
- Tags are created locally first, then pushed
- Failed releases can be retried after fixing issues
- The release task handles all git operations (commit, tag, push) automatically
- Always ensure CI is green before releasing
- The task will fail fast if working directory is not clean
- Failed releases can be retried after fixing issues
- Use dry run mode (`rake release[VERSION,true]`) to preview changes
29 changes: 25 additions & 4 deletions rakelib/release.rake
Original file line number Diff line number Diff line change
Expand Up @@ -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
load File.expand_path("../lib/cypress_on_rails/version.rb", __dir__)
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 lib/cypress_on_rails/version.rb Gemfile.lock")
sh_in_dir(gem_root, "git commit -m \"Release v#{actual_version}\"")

# Tag the release
sh_in_dir(gem_root, "git tag v#{actual_version}")

# Push the commit and tag
sh_in_dir(gem_root, "git push && git push --tags")

# 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")
else
puts "DRY RUN: Would have committed, tagged v#{actual_version}, pushed, and released gem"
Copy link
Preview

Copilot AI Oct 2, 2025

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.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🔴 Critical

❓ 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:

  1. 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
  1. 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.

end

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