-
-
Notifications
You must be signed in to change notification settings - Fork 62
Add automated release rake tasks #182
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,227 @@ | ||
# Release Process | ||
|
||
This document describes how to release a new version of cypress-playwright-on-rails. | ||
|
||
## Prerequisites | ||
|
||
1. Maintainer access to the repository | ||
2. RubyGems account with publish permissions for `cypress-on-rails` | ||
3. Clean working directory on `master` branch | ||
4. Development dependencies installed: `bundle install` | ||
- Includes `gem-release` for gem management (like react_on_rails) | ||
|
||
## Release Tasks | ||
|
||
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 | ||
|
||
```bash | ||
rake release:prepare[1.19.0] | ||
``` | ||
|
||
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 | ||
|
||
After running this: | ||
```bash | ||
# Review the changes | ||
git diff | ||
|
||
# Commit the version bump | ||
git add -A | ||
git commit -m "Bump version to 1.19.0" | ||
|
||
# Push to master | ||
git push origin master | ||
``` | ||
|
||
#### 2. Publish the Release | ||
|
||
```bash | ||
rake release:publish | ||
``` | ||
|
||
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 | ||
|
||
#### 3. 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 | ||
- Copy release notes from CHANGELOG.md | ||
- Publish the release | ||
|
||
2. **Announce the Release** | ||
- 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/): | ||
|
||
- **MAJOR** (X.0.0): Breaking changes | ||
- **MINOR** (1.X.0): New features, backwards compatible | ||
- **PATCH** (1.19.X): Bug fixes, backwards compatible | ||
|
||
### Examples | ||
|
||
```bash | ||
# Patch release (bug fixes) | ||
rake release:prepare[1.18.1] | ||
|
||
# Minor release (new features) | ||
rake release:prepare[1.19.0] | ||
|
||
# Major release (breaking changes) | ||
rake release:prepare[2.0.0] | ||
``` | ||
|
||
## Pre-Release Checklist | ||
|
||
Before running `rake release:prepare`: | ||
|
||
- [ ] 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 | ||
|
||
### "Must be on master branch" error | ||
|
||
```bash | ||
git checkout master | ||
git pull --rebase | ||
``` | ||
|
||
### "Working directory is not clean" error | ||
|
||
```bash | ||
# Commit or stash your changes | ||
git status | ||
git add -A && git commit -m "Your message" | ||
# or | ||
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 | ||
|
||
Ensure you're authenticated with RubyGems: | ||
```bash | ||
gem signin | ||
# Enter your RubyGems credentials | ||
``` | ||
|
||
### Tag already exists | ||
|
||
If you need to re-release: | ||
```bash | ||
# Delete local tag | ||
git tag -d v1.19.0 | ||
|
||
# Delete remote tag | ||
git push origin :v1.19.0 | ||
|
||
# Try again | ||
rake release:publish | ||
``` | ||
|
||
## Rollback | ||
|
||
If you need to rollback a release: | ||
|
||
### Yank the gem from RubyGems | ||
```bash | ||
gem yank cypress-on-rails -v 1.19.0 | ||
``` | ||
|
||
### Delete the git tag | ||
```bash | ||
git tag -d v1.19.0 | ||
git push origin :v1.19.0 | ||
``` | ||
|
||
### Revert the version commit | ||
```bash | ||
git revert HEAD | ||
git push origin master | ||
``` | ||
|
||
## Example Release Flow | ||
|
||
```bash | ||
# 1. Ensure you're on master and up to date | ||
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" | ||
|
||
# 4. Run tests (optional, publish will run them too) | ||
bundle exec rake spec | ||
|
||
# 5. Push to master | ||
git push origin master | ||
|
||
# 6. Publish the release | ||
rake release:publish | ||
|
||
# 7. Create GitHub release | ||
open "https://github.com/shakacode/cypress-playwright-on-rails/releases/new?tag=v1.19.0" | ||
|
||
# 8. 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,117 @@ | ||
require 'bundler/gem_tasks' | ||
|
||
|
||
require 'rspec/core/rake_task' | ||
RSpec::Core::RakeTask.new(:spec) do |t| | ||
t.pattern = 'spec/cypress_on_rails/*_spec.rb' | ||
end | ||
|
||
task default: %w[spec build] | ||
|
||
namespace :release do | ||
desc "Prepare release: bump version and update changelog" | ||
task :prepare, [:version] do |_t, args| | ||
require_relative 'lib/cypress_on_rails/version' | ||
|
||
version = args[:version] | ||
unless version | ||
puts "Usage: rake release:prepare[VERSION]" | ||
puts "Example: rake release:prepare[1.19.0]" | ||
exit 1 | ||
end | ||
|
||
unless version.match?(/^\d+\.\d+\.\d+$/) | ||
puts "Error: Version must be in format X.Y.Z (e.g., 1.19.0)" | ||
exit 1 | ||
end | ||
|
||
current_version = CypressOnRails::VERSION | ||
puts "Current version: #{current_version}" | ||
puts "New version: #{version}" | ||
|
||
# Confirm the version bump | ||
print "Continue? (y/n): " | ||
response = $stdin.gets.chomp.downcase | ||
unless response == 'y' | ||
puts "Aborted." | ||
exit 0 | ||
end | ||
|
||
# Use gem bump to update version | ||
puts "\n→ Bumping version with gem-release..." | ||
unless system("gem bump --version #{version} --no-commit") | ||
puts "Error: Failed to bump version" | ||
exit 1 | ||
end | ||
puts "✓ Updated version to #{version}" | ||
|
||
# Update CHANGELOG | ||
update_changelog(version, current_version) | ||
|
||
puts "\n✓ Version prepared!" | ||
puts "\nNext steps:" | ||
puts " 1. Review changes: git diff" | ||
puts " 2. Commit: git add -A && git commit -m 'Bump version to #{version}'" | ||
puts " 3. Push: git push origin master" | ||
puts " 4. Release: rake release:publish" | ||
end | ||
|
||
desc "Publish release: tag, build, and push gem" | ||
task :publish do | ||
require_relative 'lib/cypress_on_rails/version' | ||
version = CypressOnRails::VERSION | ||
|
||
# Pre-flight checks | ||
current_branch = `git rev-parse --abbrev-ref HEAD`.chomp | ||
unless current_branch == 'master' | ||
puts "Error: Must be on master branch to release (currently on #{current_branch})" | ||
exit 1 | ||
end | ||
|
||
if `git status --porcelain`.chomp != '' | ||
puts "Error: Working directory is not clean. Commit or stash changes first." | ||
exit 1 | ||
end | ||
|
||
puts "Preparing to release version #{version}..." | ||
|
||
# Run tests | ||
puts "\n→ Running tests..." | ||
unless system('bundle exec rake spec') | ||
puts "Error: Tests failed. Fix them before releasing." | ||
exit 1 | ||
end | ||
puts "✓ Tests passed" | ||
|
||
# Use gem release command | ||
puts "\n→ Releasing gem with gem-release..." | ||
unless system("gem release --tag --push") | ||
puts "Error: Failed to release gem" | ||
exit 1 | ||
end | ||
|
||
puts "\n🎉 Successfully released version #{version}!" | ||
puts "\nNext steps:" | ||
puts " 1. Create GitHub release: https://github.com/shakacode/cypress-playwright-on-rails/releases/new?tag=v#{version}" | ||
puts " 2. Announce on Slack/Twitter" | ||
puts " 3. Close related issues" | ||
end | ||
end | ||
|
||
def update_changelog(version, current_version) | ||
changelog_file = 'CHANGELOG.md' | ||
changelog = File.read(changelog_file) | ||
|
||
today = Time.now.strftime('%Y-%m-%d') | ||
|
||
# Replace [Unreleased] with versioned entry | ||
if changelog.match?(/## \[Unreleased\]/) | ||
changelog.sub!( | ||
/## \[Unreleased\]/, | ||
"## [Unreleased]\n\n---\n\n## [#{version}] — #{today}\n[Compare]: https://github.com/shakacode/cypress-playwright-on-rails/compare/v#{current_version}...v#{version}" | ||
) | ||
File.write(changelog_file, changelog) | ||
puts "✓ Updated #{changelog_file}" | ||
else | ||
puts "Warning: Could not find [Unreleased] section in CHANGELOG.md" | ||
end | ||
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion | 🟠 Major
Use array form of
system()
to prevent shell injection.Although the version is validated with a regex, using string interpolation in
system()
is a security risk. The array form ofsystem()
is safer as it avoids shell interpretation.Apply this diff:
📝 Committable suggestion
🤖 Prompt for AI Agents