ruby_raider 1.1.4 → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (113) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/integration.yml +4 -6
  3. data/.github/workflows/reek.yml +6 -5
  4. data/.github/workflows/release.yml +175 -0
  5. data/.github/workflows/rubocop.yml +7 -6
  6. data/.github/workflows/system_tests.yml +83 -0
  7. data/.gitignore +1 -1
  8. data/.rubocop.yml +24 -0
  9. data/README.md +3 -1
  10. data/RELEASE.md +412 -0
  11. data/RELEASE_QUICK_GUIDE.md +77 -0
  12. data/bin/release +186 -0
  13. data/lib/adopter/adopt_menu.rb +150 -0
  14. data/lib/adopter/converters/base_converter.rb +85 -0
  15. data/lib/adopter/converters/identity_converter.rb +56 -0
  16. data/lib/adopter/migration_plan.rb +75 -0
  17. data/lib/adopter/migrator.rb +96 -0
  18. data/lib/adopter/plan_builder.rb +278 -0
  19. data/lib/adopter/project_analyzer.rb +256 -0
  20. data/lib/adopter/project_detector.rb +159 -0
  21. data/lib/commands/adopt_commands.rb +43 -0
  22. data/lib/generators/automation/templates/account.tt +9 -5
  23. data/lib/generators/automation/templates/appium_caps.tt +60 -6
  24. data/lib/generators/automation/templates/home.tt +4 -4
  25. data/lib/generators/automation/templates/login.tt +61 -4
  26. data/lib/generators/automation/templates/page.tt +13 -7
  27. data/lib/generators/automation/templates/partials/home_page_selector.tt +4 -4
  28. data/lib/generators/automation/templates/partials/initialize_selector.tt +3 -1
  29. data/lib/generators/automation/templates/partials/pdp_page_selector.tt +4 -4
  30. data/lib/generators/automation/templates/partials/visit_method.tt +11 -1
  31. data/lib/generators/automation/templates/pdp.tt +1 -1
  32. data/lib/generators/cucumber/templates/env.tt +6 -4
  33. data/lib/generators/cucumber/templates/partials/capybara_env.tt +20 -0
  34. data/lib/generators/cucumber/templates/partials/capybara_world.tt +6 -0
  35. data/lib/generators/cucumber/templates/partials/mobile_steps.tt +2 -2
  36. data/lib/generators/cucumber/templates/partials/web_steps.tt +4 -3
  37. data/lib/generators/cucumber/templates/steps.tt +2 -2
  38. data/lib/generators/cucumber/templates/world.tt +5 -3
  39. data/lib/generators/generator.rb +14 -2
  40. data/lib/generators/helper_generator.rb +16 -3
  41. data/lib/generators/infrastructure/github_generator.rb +6 -0
  42. data/lib/generators/infrastructure/templates/github.tt +11 -7
  43. data/lib/generators/infrastructure/templates/github_appium.tt +108 -0
  44. data/lib/generators/infrastructure/templates/gitlab.tt +5 -2
  45. data/lib/generators/invoke_generators.rb +1 -0
  46. data/lib/generators/menu_generator.rb +2 -0
  47. data/lib/generators/minitest/minitest_generator.rb +23 -0
  48. data/lib/generators/minitest/templates/test.tt +93 -0
  49. data/lib/generators/rspec/templates/spec.tt +12 -10
  50. data/lib/generators/template_renderer/partial_cache.rb +116 -0
  51. data/lib/generators/template_renderer/partial_resolver.rb +103 -0
  52. data/lib/generators/template_renderer/template_error.rb +50 -0
  53. data/lib/generators/template_renderer.rb +90 -0
  54. data/lib/generators/templates/common/config.tt +2 -2
  55. data/lib/generators/templates/common/gemfile.tt +15 -3
  56. data/lib/generators/templates/common/partials/web_config.tt +1 -1
  57. data/lib/generators/templates/common/read_me.tt +3 -1
  58. data/lib/generators/templates/helpers/allure_helper.tt +2 -2
  59. data/lib/generators/templates/helpers/browser_helper.tt +1 -0
  60. data/lib/generators/templates/helpers/capybara_helper.tt +28 -0
  61. data/lib/generators/templates/helpers/driver_helper.tt +1 -1
  62. data/lib/generators/templates/helpers/partials/allure_imports.tt +3 -1
  63. data/lib/generators/templates/helpers/partials/allure_requirements.tt +3 -1
  64. data/lib/generators/templates/helpers/partials/appium_driver.tt +46 -0
  65. data/lib/generators/templates/helpers/partials/axe_driver.tt +10 -0
  66. data/lib/generators/templates/helpers/partials/browserstack_config.tt +13 -0
  67. data/lib/generators/templates/helpers/partials/driver_and_options.tt +6 -114
  68. data/lib/generators/templates/helpers/partials/quit_driver.tt +3 -1
  69. data/lib/generators/templates/helpers/partials/screenshot.tt +3 -1
  70. data/lib/generators/templates/helpers/partials/selenium_driver.tt +25 -0
  71. data/lib/generators/templates/helpers/spec_helper.tt +17 -4
  72. data/lib/generators/templates/helpers/test_helper.tt +26 -0
  73. data/lib/generators/templates/helpers/visual_spec_helper.tt +1 -1
  74. data/lib/ruby_raider.rb +5 -0
  75. data/lib/version +1 -1
  76. data/spec/adopter/adopt_menu_spec.rb +176 -0
  77. data/spec/adopter/converters/identity_converter_spec.rb +145 -0
  78. data/spec/adopter/migration_plan_spec.rb +113 -0
  79. data/spec/adopter/migrator_spec.rb +277 -0
  80. data/spec/adopter/plan_builder_spec.rb +298 -0
  81. data/spec/adopter/project_analyzer_spec.rb +337 -0
  82. data/spec/adopter/project_detector_spec.rb +295 -0
  83. data/spec/generators/fixtures/templates/test.tt +1 -0
  84. data/spec/generators/fixtures/templates/test_partial.tt +1 -0
  85. data/spec/generators/template_renderer_spec.rb +298 -0
  86. data/spec/integration/commands/scaffolding_commands_spec.rb +2 -2
  87. data/spec/integration/commands/utility_commands_spec.rb +2 -2
  88. data/spec/integration/end_to_end_spec.rb +325 -0
  89. data/spec/integration/generators/automation_generator_spec.rb +11 -11
  90. data/spec/integration/generators/common_generator_spec.rb +40 -40
  91. data/spec/integration/generators/cucumber_generator_spec.rb +7 -7
  92. data/spec/integration/generators/github_generator_spec.rb +8 -8
  93. data/spec/integration/generators/gitlab_generator_spec.rb +8 -8
  94. data/spec/integration/generators/helpers_generator_spec.rb +73 -35
  95. data/spec/integration/generators/minitest_generator_spec.rb +70 -0
  96. data/spec/integration/generators/rspec_generator_spec.rb +7 -7
  97. data/spec/integration/settings_helper.rb +1 -1
  98. data/spec/integration/spec_helper.rb +20 -2
  99. data/spec/system/capybara_spec.rb +42 -0
  100. data/spec/system/selenium_spec.rb +19 -17
  101. data/spec/system/support/system_test_helper.rb +35 -0
  102. data/spec/system/watir_spec.rb +19 -17
  103. metadata +46 -16
  104. data/.github/workflows/push_gem.yml +0 -37
  105. data/.github/workflows/selenium.yml +0 -22
  106. data/.github/workflows/watir.yml +0 -22
  107. data/lib/generators/automation/templates/partials/android_caps.tt +0 -17
  108. data/lib/generators/automation/templates/partials/cross_platform_caps.tt +0 -25
  109. data/lib/generators/automation/templates/partials/ios_caps.tt +0 -18
  110. data/lib/generators/automation/templates/partials/selenium_account.tt +0 -9
  111. data/lib/generators/automation/templates/partials/selenium_login.tt +0 -34
  112. data/lib/generators/automation/templates/partials/watir_account.tt +0 -7
  113. data/lib/generators/automation/templates/partials/watir_login.tt +0 -32
data/RELEASE.md ADDED
@@ -0,0 +1,412 @@
1
+ # Release Process Documentation
2
+
3
+ ## Overview
4
+
5
+ Ruby Raider uses a **fully automated release process**. You only need to run a single command, and everything else happens automatically via GitHub Actions.
6
+
7
+ ## Prerequisites
8
+
9
+ Before releasing, ensure you have:
10
+
11
+ 1. ✅ Merged all changes to `master` branch
12
+ 2. ✅ All tests passing locally
13
+ 3. ✅ RuboCop and Reek checks passing
14
+ 4. ✅ GitHub repository configured with secrets:
15
+ - `RUBYGEMS_API_KEY` - RubyGems API key for publishing
16
+
17
+ ## One-Command Release
18
+
19
+ ```bash
20
+ # For bug fixes (1.1.4 -> 1.1.5)
21
+ bin/release patch
22
+
23
+ # For new features (1.1.4 -> 1.2.0)
24
+ bin/release minor
25
+
26
+ # For breaking changes (1.1.4 -> 2.0.0)
27
+ bin/release major
28
+ ```
29
+
30
+ That's it! Everything else is automated.
31
+
32
+ ---
33
+
34
+ ## What Happens Automatically
35
+
36
+ ### 1. Local Checks (bin/release script)
37
+
38
+ The release script will:
39
+ - ✅ Verify working directory is clean
40
+ - ✅ Confirm you're on master/main branch
41
+ - ✅ Run all unit tests
42
+ - ✅ Run integration tests
43
+ - ✅ Run RuboCop linter
44
+ - ✅ Run Reek code smell detector
45
+ - ✅ Calculate new version number
46
+ - ✅ Ask for confirmation
47
+ - ✅ Update `lib/version` file
48
+ - ✅ Create git commit with version bump
49
+ - ✅ Create git tag (e.g., `v1.2.0`)
50
+ - ✅ Push commit and tag to GitHub
51
+
52
+ **If any step fails, the release is aborted.**
53
+
54
+ ### 2. GitHub Actions Workflow (Triggered by Tag)
55
+
56
+ When the tag is pushed, the `.github/workflows/release.yml` workflow:
57
+
58
+ **Validation Phase:**
59
+ - ✅ Verifies version in `lib/version` matches tag
60
+ - ✅ Runs all tests again (unit + integration)
61
+ - ✅ Runs RuboCop
62
+ - ✅ Runs Reek
63
+
64
+ **Build Phase:**
65
+ - ✅ Builds the gem (`ruby_raider-X.Y.Z.gem`)
66
+
67
+ **Release Phase:**
68
+ - ✅ Generates changelog from git commits
69
+ - ✅ Creates GitHub Release with:
70
+ - Release notes
71
+ - Changelog
72
+ - Gem file attachment
73
+ - ✅ Publishes gem to RubyGems.org
74
+
75
+ **All of this happens automatically within 2-3 minutes.**
76
+
77
+ ---
78
+
79
+ ## Example Release Flow
80
+
81
+ ```bash
82
+ $ bin/release minor
83
+
84
+ 🧪 Running tests...
85
+ ......................................
86
+
87
+ ✓ All tests and linters passed
88
+
89
+ 📦 Release Summary
90
+ Current version: 1.1.4
91
+ New version: 1.2.0
92
+ Bump type: minor
93
+
94
+ This will:
95
+ 1. Update lib/version to 1.2.0
96
+ 2. Commit changes
97
+ 3. Create git tag v1.2.0
98
+ 4. Push to GitHub (triggers automated release)
99
+ 5. Publish gem to RubyGems (via GitHub Actions)
100
+ 6. Create GitHub release with changelog
101
+
102
+ Proceed with release? [y/N] y
103
+
104
+ 📝 Updating version to 1.2.0...
105
+ ✓ Updated lib/version
106
+
107
+ 📌 Creating commit and tag...
108
+ ✓ Created commit and tag v1.2.0
109
+
110
+ 🚀 Pushing to GitHub...
111
+ ✓ Pushed to GitHub
112
+
113
+ ============================================================
114
+ 🎉 Release 1.2.0 initiated successfully!
115
+ ============================================================
116
+
117
+ The GitHub Actions workflow is now:
118
+ 1. Running tests
119
+ 2. Building the gem
120
+ 3. Publishing to RubyGems
121
+ 4. Creating GitHub release
122
+
123
+ Monitor progress at:
124
+ https://github.com/RubyRaider/ruby_raider/actions
125
+
126
+ Release will be available at:
127
+ https://github.com/RubyRaider/ruby_raider/releases/tag/v1.2.0
128
+ https://rubygems.org/gems/ruby_raider/versions/1.2.0
129
+
130
+ ✨ Thank you for contributing to Ruby Raider!
131
+ ```
132
+
133
+ ---
134
+
135
+ ## Semantic Versioning Guide
136
+
137
+ Ruby Raider follows [Semantic Versioning](https://semver.org/):
138
+
139
+ ### Patch Release (X.Y.Z+1)
140
+
141
+ **When:** Bug fixes, small improvements, no new features
142
+
143
+ **Examples:**
144
+ - Fix template rendering bug
145
+ - Update documentation
146
+ - Performance improvements
147
+ - Dependency updates
148
+
149
+ **Command:**
150
+ ```bash
151
+ bin/release patch # 1.1.4 -> 1.1.5
152
+ ```
153
+
154
+ ### Minor Release (X.Y+1.0)
155
+
156
+ **When:** New features, backward-compatible changes
157
+
158
+ **Examples:**
159
+ - Add new framework support
160
+ - New template system
161
+ - New CLI commands
162
+ - Enhanced functionality
163
+
164
+ **Command:**
165
+ ```bash
166
+ bin/release minor # 1.1.4 -> 1.2.0
167
+ ```
168
+
169
+ ### Major Release (X+1.0.0)
170
+
171
+ **When:** Breaking changes, major refactors
172
+
173
+ **Examples:**
174
+ - Drop Ruby 2.x support
175
+ - Change public API
176
+ - Remove deprecated features
177
+ - Architectural changes
178
+
179
+ **Command:**
180
+ ```bash
181
+ bin/release major # 1.1.4 -> 2.0.0
182
+ ```
183
+
184
+ ---
185
+
186
+ ## Monitoring the Release
187
+
188
+ ### 1. GitHub Actions Progress
189
+
190
+ Visit: https://github.com/RubyRaider/ruby_raider/actions
191
+
192
+ You'll see the "Automated Release" workflow running with steps:
193
+ - ✅ Checkout code
194
+ - ✅ Run tests
195
+ - ✅ Build gem
196
+ - ✅ Generate changelog
197
+ - ✅ Create GitHub Release
198
+ - ✅ Publish to RubyGems
199
+
200
+ **Expected duration:** 2-3 minutes
201
+
202
+ ### 2. GitHub Release
203
+
204
+ Visit: https://github.com/RubyRaider/ruby_raider/releases
205
+
206
+ You'll see the new release with:
207
+ - Version number
208
+ - Changelog (auto-generated from commits)
209
+ - Gem file download
210
+ - Installation instructions
211
+
212
+ ### 3. RubyGems.org
213
+
214
+ Visit: https://rubygems.org/gems/ruby_raider
215
+
216
+ The new version will appear within 1-2 minutes of publication.
217
+
218
+ ---
219
+
220
+ ## Troubleshooting
221
+
222
+ ### Problem: "Working directory is not clean"
223
+
224
+ **Solution:** Commit or stash your changes first
225
+ ```bash
226
+ git status
227
+ git add .
228
+ git commit -m "Your changes"
229
+ # Then try release again
230
+ ```
231
+
232
+ ### Problem: "Tests failed"
233
+
234
+ **Solution:** Fix the failing tests before releasing
235
+ ```bash
236
+ bundle exec rspec
237
+ bundle exec rubocop --auto-correct
238
+ bundle exec reek
239
+ ```
240
+
241
+ ### Problem: "Version mismatch in workflow"
242
+
243
+ **Solution:** This means `lib/version` doesn't match the tag
244
+
245
+ This should never happen if using `bin/release`, but if it does:
246
+ ```bash
247
+ # Check version
248
+ cat lib/version
249
+
250
+ # Update manually
251
+ echo "1.2.0" > lib/version
252
+ git add lib/version
253
+ git commit -m "Fix version"
254
+ git push
255
+ ```
256
+
257
+ ### Problem: "RubyGems API key not configured"
258
+
259
+ **Solution:** Add the secret in GitHub:
260
+
261
+ 1. Get your RubyGems API key:
262
+ ```bash
263
+ curl -u your-rubygems-username https://rubygems.org/api/v1/api_key.yaml
264
+ ```
265
+
266
+ 2. Add to GitHub Secrets:
267
+ - Go to: https://github.com/RubyRaider/ruby_raider/settings/secrets/actions
268
+ - Click "New repository secret"
269
+ - Name: `RUBYGEMS_API_KEY`
270
+ - Value: (paste your API key)
271
+ - Click "Add secret"
272
+
273
+ ### Problem: "Failed to push to GitHub"
274
+
275
+ **Solution:** Check your authentication
276
+ ```bash
277
+ # Test push access
278
+ git push origin master
279
+
280
+ # If using HTTPS, you may need a personal access token
281
+ # If using SSH, ensure your key is added
282
+ ```
283
+
284
+ ---
285
+
286
+ ## Manual Release (Backup Method)
287
+
288
+ If the automated system fails, you can release manually:
289
+
290
+ ```bash
291
+ # 1. Update version
292
+ echo "1.2.0" > lib/version
293
+
294
+ # 2. Commit
295
+ git add lib/version
296
+ git commit -m "Bump version to 1.2.0"
297
+
298
+ # 3. Create tag
299
+ git tag -a v1.2.0 -m "Release version 1.2.0"
300
+
301
+ # 4. Push
302
+ git push origin master
303
+ git push origin v1.2.0
304
+
305
+ # 5. Build gem
306
+ gem build ruby_raider.gemspec
307
+
308
+ # 6. Push to RubyGems
309
+ gem push ruby_raider-1.2.0.gem
310
+
311
+ # 7. Create GitHub Release manually
312
+ # Visit: https://github.com/RubyRaider/ruby_raider/releases/new
313
+ ```
314
+
315
+ ---
316
+
317
+ ## Release Checklist
318
+
319
+ Before releasing, verify:
320
+
321
+ - [ ] All PRs merged to master
322
+ - [ ] CHANGELOG or commit messages are clear
323
+ - [ ] Tests passing locally (`bundle exec rspec`)
324
+ - [ ] RuboCop passing (`bundle exec rubocop`)
325
+ - [ ] Reek passing (`bundle exec reek`)
326
+ - [ ] Version bump type is correct (patch/minor/major)
327
+ - [ ] GitHub Actions secrets configured (RUBYGEMS_API_KEY)
328
+
329
+ Then run:
330
+
331
+ ```bash
332
+ bin/release [patch|minor|major]
333
+ ```
334
+
335
+ And monitor at:
336
+ - https://github.com/RubyRaider/ruby_raider/actions
337
+
338
+ ---
339
+
340
+ ## Post-Release
341
+
342
+ After a successful release:
343
+
344
+ 1. ✅ Verify gem on RubyGems: https://rubygems.org/gems/ruby_raider
345
+ 2. ✅ Check GitHub Release: https://github.com/RubyRaider/ruby_raider/releases
346
+ 3. ✅ Test installation:
347
+ ```bash
348
+ gem install ruby_raider -v 1.2.0
349
+ raider --version
350
+ ```
351
+ 4. ✅ Announce release (Twitter, Discord, etc.)
352
+ 5. ✅ Update website if needed
353
+
354
+ ---
355
+
356
+ ## Configuration Files
357
+
358
+ ### Release Workflow
359
+ - **File:** `.github/workflows/release.yml`
360
+ - **Trigger:** Push of tag matching `v*.*.*`
361
+ - **Actions:** Test → Build → Release → Publish
362
+
363
+ ### Release Script
364
+ - **File:** `bin/release`
365
+ - **Usage:** `bin/release [major|minor|patch]`
366
+ - **Purpose:** Local validation and version bumping
367
+
368
+ ### Version File
369
+ - **File:** `lib/version`
370
+ - **Format:** Single line with version number (no 'v' prefix)
371
+ - **Example:** `1.2.0`
372
+
373
+ ---
374
+
375
+ ## FAQ
376
+
377
+ **Q: Can I release from a branch?**
378
+ A: The script will warn you. It's recommended to release from master/main only.
379
+
380
+ **Q: Can I skip tests?**
381
+ A: No. Tests are mandatory for releases to ensure quality.
382
+
383
+ **Q: How do I rollback a release?**
384
+ A: You can't unpublish from RubyGems, but you can:
385
+ 1. Yank the version: `gem yank ruby_raider -v X.Y.Z`
386
+ 2. Release a new patch version with fixes
387
+
388
+ **Q: What if the GitHub Actions workflow fails?**
389
+ A: Check the logs, fix the issue, delete the tag, and try again:
390
+ ```bash
391
+ git tag -d v1.2.0
392
+ git push origin :refs/tags/v1.2.0
393
+ # Fix issue, then re-run bin/release
394
+ ```
395
+
396
+ **Q: How long does a release take?**
397
+ A: ~2-3 minutes from pushing the tag to gem being available on RubyGems.
398
+
399
+ ---
400
+
401
+ ## Support
402
+
403
+ If you encounter issues with the release process:
404
+
405
+ 1. Check the [troubleshooting section](#troubleshooting)
406
+ 2. Review GitHub Actions logs
407
+ 3. Open an issue: https://github.com/RubyRaider/ruby_raider/issues
408
+
409
+ ---
410
+
411
+ **Last Updated:** 2026-02-10
412
+ **Automation Version:** 1.0
@@ -0,0 +1,77 @@
1
+ # Quick Release Guide
2
+
3
+ ## TL;DR - One Command Release
4
+
5
+ ```bash
6
+ # Bug fixes: 1.1.4 -> 1.1.5
7
+ bin/release patch
8
+
9
+ # New features: 1.1.4 -> 1.2.0
10
+ bin/release minor
11
+
12
+ # Breaking changes: 1.1.4 -> 2.0.0
13
+ bin/release major
14
+ ```
15
+
16
+ **Everything else is automated!**
17
+
18
+ ---
19
+
20
+ ## What Happens
21
+
22
+ 1. ✅ Script validates & tests locally
23
+ 2. ✅ Updates version in `lib/version`
24
+ 3. ✅ Creates git commit + tag
25
+ 4. ✅ Pushes to GitHub
26
+ 5. ✅ GitHub Actions automatically:
27
+ - Runs tests
28
+ - Builds gem
29
+ - Publishes to RubyGems
30
+ - Creates GitHub Release
31
+
32
+ **Duration:** ~3 minutes total
33
+
34
+ ---
35
+
36
+ ## Before Releasing
37
+
38
+ Ensure:
39
+ - [ ] All changes merged to master
40
+ - [ ] Tests passing: `bundle exec rspec`
41
+ - [ ] Linters passing: `bundle exec rubocop && bundle exec reek`
42
+
43
+ ---
44
+
45
+ ## Monitor Progress
46
+
47
+ **GitHub Actions:**
48
+ https://github.com/RubyRaider/ruby_raider/actions
49
+
50
+ **GitHub Releases:**
51
+ https://github.com/RubyRaider/ruby_raider/releases
52
+
53
+ **RubyGems:**
54
+ https://rubygems.org/gems/ruby_raider
55
+
56
+ ---
57
+
58
+ ## First-Time Setup
59
+
60
+ Add RubyGems API key to GitHub Secrets:
61
+
62
+ 1. Get API key:
63
+ ```bash
64
+ gem signin
65
+ # Visit https://rubygems.org/profile/edit
66
+ # Copy API key
67
+ ```
68
+
69
+ 2. Add to GitHub:
70
+ - Go to: Settings → Secrets → Actions
71
+ - Add `RUBYGEMS_API_KEY` secret
72
+
73
+ ---
74
+
75
+ ## Full Documentation
76
+
77
+ See [RELEASE.md](RELEASE.md) for complete documentation.
data/bin/release ADDED
@@ -0,0 +1,186 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ # Automated release script for Ruby Raider
5
+ # Usage: bin/release [major|minor|patch]
6
+
7
+ require 'fileutils'
8
+
9
+ class ReleaseManager
10
+ VERSION_FILE = 'lib/version'
11
+ GEMSPEC_FILE = 'ruby_raider.gemspec'
12
+
13
+ def initialize(bump_type)
14
+ @bump_type = bump_type
15
+ @current_version = read_version
16
+ end
17
+
18
+ def run
19
+ validate_clean_repo
20
+ validate_branch
21
+ validate_tests
22
+
23
+ new_version = calculate_new_version
24
+ confirm_release(new_version)
25
+
26
+ update_version(new_version)
27
+ commit_and_tag(new_version)
28
+ push_release
29
+
30
+ success_message(new_version)
31
+ end
32
+
33
+ private
34
+
35
+ def read_version
36
+ File.read(VERSION_FILE).strip
37
+ end
38
+
39
+ def validate_clean_repo
40
+ status = `git status --porcelain`.strip
41
+ return if status.empty?
42
+
43
+ puts '❌ Error: Working directory is not clean'
44
+ puts 'Please commit or stash your changes first:'
45
+ puts status
46
+ exit 1
47
+ end
48
+
49
+ def validate_branch
50
+ branch = `git branch --show-current`.strip
51
+ return unless branch != 'master' && branch != 'main'
52
+
53
+ puts "⚠️ Warning: You're on branch '#{branch}', not master/main"
54
+ print 'Continue anyway? [y/N] '
55
+ exit 1 unless gets.strip.downcase == 'y'
56
+ end
57
+
58
+ def validate_tests
59
+ puts '🧪 Running tests...'
60
+
61
+ # Run unit tests
62
+ unless system('bundle exec rspec spec/generators/ --format progress')
63
+ puts '❌ Unit tests failed'
64
+ exit 1
65
+ end
66
+
67
+ # Run integration tests (skip slow e2e tests)
68
+ unless system('bundle exec rspec spec/integration/ --tag ~slow --format progress')
69
+ puts '❌ Integration tests failed'
70
+ exit 1
71
+ end
72
+
73
+ # Run linters
74
+ unless system('bundle exec rubocop')
75
+ puts '❌ RuboCop failed'
76
+ exit 1
77
+ end
78
+
79
+ unless system('bundle exec reek')
80
+ puts '❌ Reek failed'
81
+ exit 1
82
+ end
83
+
84
+ puts '✓ All tests and linters passed'
85
+ end
86
+
87
+ def calculate_new_version
88
+ major, minor, patch = @current_version.split('.').map(&:to_i)
89
+
90
+ case @bump_type
91
+ when 'major'
92
+ "#{major + 1}.0.0"
93
+ when 'minor'
94
+ "#{major}.#{minor + 1}.0"
95
+ when 'patch'
96
+ "#{major}.#{minor}.#{patch + 1}"
97
+ else
98
+ puts "❌ Error: Invalid bump type '#{@bump_type}'"
99
+ puts 'Usage: bin/release [major|minor|patch]'
100
+ exit 1
101
+ end
102
+ end
103
+
104
+ def confirm_release(new_version)
105
+ puts "\n📦 Release Summary"
106
+ puts " Current version: #{@current_version}"
107
+ puts " New version: #{new_version}"
108
+ puts " Bump type: #{@bump_type}"
109
+ puts "\nThis will:"
110
+ puts " 1. Update lib/version to #{new_version}"
111
+ puts ' 2. Commit changes'
112
+ puts " 3. Create git tag v#{new_version}"
113
+ puts ' 4. Push to GitHub (triggers automated release)'
114
+ puts ' 5. Publish gem to RubyGems (via GitHub Actions)'
115
+ puts ' 6. Create GitHub release with changelog'
116
+
117
+ print "\nProceed with release? [y/N] "
118
+ exit 0 unless gets.strip.downcase == 'y'
119
+ end
120
+
121
+ def update_version(new_version)
122
+ puts "\n📝 Updating version to #{new_version}..."
123
+ File.write(VERSION_FILE, "#{new_version}\n")
124
+ puts "✓ Updated #{VERSION_FILE}"
125
+ end
126
+
127
+ def commit_and_tag(new_version)
128
+ puts "\n📌 Creating commit and tag..."
129
+
130
+ # Commit version change
131
+ system("git add #{VERSION_FILE}")
132
+ system("git commit -m 'Bump version to #{new_version}'")
133
+
134
+ # Create annotated tag
135
+ system("git tag -a v#{new_version} -m 'Release version #{new_version}'")
136
+
137
+ puts "✓ Created commit and tag v#{new_version}"
138
+ end
139
+
140
+ def push_release
141
+ puts "\n🚀 Pushing to GitHub..."
142
+
143
+ # Push commit
144
+ unless system('git push origin HEAD')
145
+ puts '❌ Failed to push commits'
146
+ exit 1
147
+ end
148
+
149
+ # Push tag (this triggers the release workflow)
150
+ unless system('git push origin --tags')
151
+ puts '❌ Failed to push tags'
152
+ exit 1
153
+ end
154
+
155
+ puts '✓ Pushed to GitHub'
156
+ end
157
+
158
+ def success_message(new_version)
159
+ puts "\n#{'=' * 60}"
160
+ puts "🎉 Release #{new_version} initiated successfully!"
161
+ puts '=' * 60
162
+ puts "\nThe GitHub Actions workflow is now:"
163
+ puts ' 1. Running tests'
164
+ puts ' 2. Building the gem'
165
+ puts ' 3. Publishing to RubyGems'
166
+ puts ' 4. Creating GitHub release'
167
+ puts "\nMonitor progress at:"
168
+ puts ' https://github.com/RubyRaider/ruby_raider/actions'
169
+ puts "\nRelease will be available at:"
170
+ puts " https://github.com/RubyRaider/ruby_raider/releases/tag/v#{new_version}"
171
+ puts " https://rubygems.org/gems/ruby_raider/versions/#{new_version}"
172
+ puts "\n✨ Thank you for contributing to Ruby Raider!"
173
+ end
174
+ end
175
+
176
+ # Main execution
177
+ if ARGV.length != 1
178
+ puts 'Usage: bin/release [major|minor|patch]'
179
+ puts "\nExamples:"
180
+ puts ' bin/release patch # 1.1.4 -> 1.1.5 (bug fixes)'
181
+ puts ' bin/release minor # 1.1.4 -> 1.2.0 (new features)'
182
+ puts ' bin/release major # 1.1.4 -> 2.0.0 (breaking changes)'
183
+ exit 1
184
+ end
185
+
186
+ ReleaseManager.new(ARGV[0]).run