rake-gem-maintenance 0.1.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.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: e0c71b796d66f9eaeb77ba3913ace494ae4acddaecef72272ddbf193ba07aa46
4
+ data.tar.gz: 847747804775873ff3fbefa44978b62de67ab59ea1b12d4bd0cd5db30f0598c5
5
+ SHA512:
6
+ metadata.gz: 579d114ee49198db37492ef50d20a72904961ae530685ca8e8f3fa9b51211d8434bc1610c6d6f25c7a6c91e52d4992f2864c3a273224ac8652071af3b6b65ac7
7
+ data.tar.gz: 244936a0827886e6987a8dfb1290adf8ad168cd1c19520eb35b1266af859280ba29ab513afaf38a2a9bd2846f8ed59a4ed63dd5eb427873ee43722fd6e22ca97
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --require spec_helper
2
+ --format documentation
data/.rubocop.yml ADDED
@@ -0,0 +1,12 @@
1
+ AllCops:
2
+ NewCops: enable
3
+
4
+ plugins:
5
+ - rubocop-rake
6
+ - rubocop-rspec
7
+
8
+ Layout/LineLength:
9
+ Max: 120
10
+
11
+ Style/StringLiterals:
12
+ EnforcedStyle: double_quotes
data/CLAUDE.md ADDED
@@ -0,0 +1,39 @@
1
+ # CLAUDE.md
2
+
3
+ ## Project Overview
4
+
5
+ rake-gem-maintenance is a Ruby gem providing reusable Rake::TaskLib subclasses for gem maintenance workflows: dependency upgrades and version bumps.
6
+
7
+ ## Common Commands
8
+
9
+ ```bash
10
+ # Install dependencies
11
+ bundle install
12
+
13
+ # Run all verification (specs + rubocop)
14
+ rake
15
+
16
+ # Run RSpec tests only
17
+ rake spec
18
+
19
+ # Run linter with auto-correct
20
+ rake rubocop
21
+ ```
22
+
23
+ ## Architecture
24
+
25
+ ### Core Classes (lib/rake/gem_maintenance/)
26
+
27
+ - **UpgradeTask** — Rake::TaskLib subclass defining upgrade:* tasks (branch, gems, commit, push, auto)
28
+ - **VersionBumpTask** — Rake::TaskLib subclass defining version:bump[type] and bump[type] tasks
29
+
30
+ ### Entry Points
31
+
32
+ - `rake/gem_maintenance.rb` — requires both task classes
33
+ - `rake/gem_maintenance/install_tasks.rb` — auto-instantiates both with defaults
34
+
35
+ ## Commit Conventions
36
+
37
+ - Use conventional commit format: `type(scope): subject`
38
+ - Keep subject line under 50 characters
39
+ - Use present tense ("add feature" not "added feature")
data/Gemfile ADDED
@@ -0,0 +1,16 @@
1
+ # frozen_string_literal: true
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gemspec
6
+
7
+ gem "ostruct"
8
+
9
+ gem "guard"
10
+ gem "guard-bundler"
11
+ gem "guard-rspec"
12
+ gem "guard-rubocop"
13
+ gem "rspec"
14
+ gem "rubocop"
15
+ gem "rubocop-rake", require: false
16
+ gem "rubocop-rspec", require: false
data/Gemfile.lock ADDED
@@ -0,0 +1,191 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ rake-gem-maintenance (0.1.0)
5
+ bundler-audit
6
+ gem-release (~> 2.2)
7
+ rake (>= 13.0)
8
+
9
+ GEM
10
+ remote: https://rubygems.org/
11
+ specs:
12
+ ast (2.4.3)
13
+ bundler-audit (0.9.3)
14
+ bundler (>= 1.2.0)
15
+ thor (~> 1.0)
16
+ coderay (1.1.3)
17
+ diff-lcs (1.6.2)
18
+ ffi (1.17.3)
19
+ ffi (1.17.3-x64-mingw-ucrt)
20
+ ffi (1.17.3-x86_64-linux-gnu)
21
+ formatador (1.2.3)
22
+ reline
23
+ gem-release (2.2.4)
24
+ guard (2.20.1)
25
+ formatador (>= 0.2.4)
26
+ listen (>= 2.7, < 4.0)
27
+ logger (~> 1.6)
28
+ lumberjack (>= 1.0.12, < 2.0)
29
+ nenv (~> 0.1)
30
+ notiffany (~> 0.0)
31
+ pry (>= 0.13.0)
32
+ shellany (~> 0.0)
33
+ thor (>= 0.18.1)
34
+ guard-bundler (3.1.0)
35
+ bundler (>= 2.1, < 5)
36
+ guard (~> 2.2)
37
+ guard-compat (~> 1.1)
38
+ guard-compat (1.2.1)
39
+ guard-rspec (4.7.3)
40
+ guard (~> 2.1)
41
+ guard-compat (~> 1.1)
42
+ rspec (>= 2.99.0, < 4.0)
43
+ guard-rubocop (1.5.0)
44
+ guard (~> 2.0)
45
+ rubocop (< 2.0)
46
+ io-console (0.8.2)
47
+ json (2.18.1)
48
+ language_server-protocol (3.17.0.5)
49
+ lint_roller (1.1.0)
50
+ listen (3.10.0)
51
+ logger
52
+ rb-fsevent (~> 0.10, >= 0.10.3)
53
+ rb-inotify (~> 0.9, >= 0.9.10)
54
+ logger (1.7.0)
55
+ lumberjack (1.4.2)
56
+ method_source (1.1.0)
57
+ nenv (0.3.0)
58
+ notiffany (0.1.3)
59
+ nenv (~> 0.1)
60
+ shellany (~> 0.0)
61
+ ostruct (0.6.3)
62
+ parallel (1.27.0)
63
+ parser (3.3.10.1)
64
+ ast (~> 2.4.1)
65
+ racc
66
+ prism (1.9.0)
67
+ pry (0.16.0)
68
+ coderay (~> 1.1)
69
+ method_source (~> 1.0)
70
+ reline (>= 0.6.0)
71
+ racc (1.8.1)
72
+ rainbow (3.1.1)
73
+ rake (13.3.1)
74
+ rb-fsevent (0.11.2)
75
+ rb-inotify (0.11.1)
76
+ ffi (~> 1.0)
77
+ regexp_parser (2.11.3)
78
+ reline (0.6.3)
79
+ io-console (~> 0.5)
80
+ rspec (3.13.2)
81
+ rspec-core (~> 3.13.0)
82
+ rspec-expectations (~> 3.13.0)
83
+ rspec-mocks (~> 3.13.0)
84
+ rspec-core (3.13.6)
85
+ rspec-support (~> 3.13.0)
86
+ rspec-expectations (3.13.5)
87
+ diff-lcs (>= 1.2.0, < 2.0)
88
+ rspec-support (~> 3.13.0)
89
+ rspec-mocks (3.13.7)
90
+ diff-lcs (>= 1.2.0, < 2.0)
91
+ rspec-support (~> 3.13.0)
92
+ rspec-support (3.13.7)
93
+ rubocop (1.84.1)
94
+ json (~> 2.3)
95
+ language_server-protocol (~> 3.17.0.2)
96
+ lint_roller (~> 1.1.0)
97
+ parallel (~> 1.10)
98
+ parser (>= 3.3.0.2)
99
+ rainbow (>= 2.2.2, < 4.0)
100
+ regexp_parser (>= 2.9.3, < 3.0)
101
+ rubocop-ast (>= 1.49.0, < 2.0)
102
+ ruby-progressbar (~> 1.7)
103
+ unicode-display_width (>= 2.4.0, < 4.0)
104
+ rubocop-ast (1.49.0)
105
+ parser (>= 3.3.7.2)
106
+ prism (~> 1.7)
107
+ rubocop-rake (0.7.1)
108
+ lint_roller (~> 1.1)
109
+ rubocop (>= 1.72.1)
110
+ rubocop-rspec (3.9.0)
111
+ lint_roller (~> 1.1)
112
+ rubocop (~> 1.81)
113
+ ruby-progressbar (1.13.0)
114
+ shellany (0.0.1)
115
+ thor (1.5.0)
116
+ unicode-display_width (3.2.0)
117
+ unicode-emoji (~> 4.1)
118
+ unicode-emoji (4.2.0)
119
+
120
+ PLATFORMS
121
+ ruby
122
+ x64-mingw-ucrt
123
+ x86_64-linux
124
+
125
+ DEPENDENCIES
126
+ guard
127
+ guard-bundler
128
+ guard-rspec
129
+ guard-rubocop
130
+ ostruct
131
+ rake-gem-maintenance!
132
+ rspec
133
+ rubocop
134
+ rubocop-rake
135
+ rubocop-rspec
136
+
137
+ CHECKSUMS
138
+ ast (2.4.3) sha256=954615157c1d6a382bc27d690d973195e79db7f55e9765ac7c481c60bdb4d383
139
+ bundler-audit (0.9.3) sha256=81c8766c71e47d0d28a0f98c7eed028539f21a6ea3cd8f685eb6f42333c9b4e9
140
+ coderay (1.1.3) sha256=dc530018a4684512f8f38143cd2a096c9f02a1fc2459edcfe534787a7fc77d4b
141
+ diff-lcs (1.6.2) sha256=9ae0d2cba7d4df3075fe8cd8602a8604993efc0dfa934cff568969efb1909962
142
+ ffi (1.17.3) sha256=0e9f39f7bb3934f77ad6feab49662be77e87eedcdeb2a3f5c0234c2938563d4c
143
+ ffi (1.17.3-x64-mingw-ucrt) sha256=5f1d7d067a9a1058ad183dba25b05557cd51c85fc1768c49338eabc1cf242d7c
144
+ ffi (1.17.3-x86_64-linux-gnu) sha256=3746b01f677aae7b16dc1acb7cb3cc17b3e35bdae7676a3f568153fb0e2c887f
145
+ formatador (1.2.3) sha256=19fa898133c2c26cdbb5d09f6998c1e137ad9427a046663e55adfe18b950d894
146
+ gem-release (2.2.4) sha256=2f11124c1580c811507c3b47e875e420cf3ed792a98105b49df11971e6e94db3
147
+ guard (2.20.1) sha256=ab9cd7873854e6b76080c0589f781ff3e390e441bdda20165804df54f977015a
148
+ guard-bundler (3.1.0) sha256=d0e60e46d6c06e201e79f61623211f64961cb000188f55fb76e36dc892ff0e35
149
+ guard-compat (1.2.1) sha256=3ad21ab0070107f92edfd82610b5cdc2fb8e368851e72362ada9703443d646fe
150
+ guard-rspec (4.7.3) sha256=a47ba03cbd1e3c71e6ae8645cea97e203098a248aede507461a43e906e2f75ca
151
+ guard-rubocop (1.5.0) sha256=3041d796dcb5ee31e352de74732250826f5f235b4ff48df9dbf424a6dc736251
152
+ io-console (0.8.2) sha256=d6e3ae7a7cc7574f4b8893b4fca2162e57a825b223a177b7afa236c5ef9814cc
153
+ json (2.18.1) sha256=fe112755501b8d0466b5ada6cf50c8c3f41e897fa128ac5d263ec09eedc9f986
154
+ language_server-protocol (3.17.0.5) sha256=fd1e39a51a28bf3eec959379985a72e296e9f9acfce46f6a79d31ca8760803cc
155
+ lint_roller (1.1.0) sha256=2c0c845b632a7d172cb849cc90c1bce937a28c5c8ccccb50dfd46a485003cc87
156
+ listen (3.10.0) sha256=c6e182db62143aeccc2e1960033bebe7445309c7272061979bb098d03760c9d2
157
+ logger (1.7.0) sha256=196edec7cc44b66cfb40f9755ce11b392f21f7967696af15d274dde7edff0203
158
+ lumberjack (1.4.2) sha256=40de5ae46321380c835031bcc1370f13bba304d29f2b5f5bb152061a5a191b95
159
+ method_source (1.1.0) sha256=181301c9c45b731b4769bc81e8860e72f9161ad7d66dd99103c9ab84f560f5c5
160
+ nenv (0.3.0) sha256=d9de6d8fb7072228463bf61843159419c969edb34b3cef51832b516ae7972765
161
+ notiffany (0.1.3) sha256=d37669605b7f8dcb04e004e6373e2a780b98c776f8eb503ac9578557d7808738
162
+ ostruct (0.6.3) sha256=95a2ed4a4bd1d190784e666b47b2d3f078e4a9efda2fccf18f84ddc6538ed912
163
+ parallel (1.27.0) sha256=4ac151e1806b755fb4e2dc2332cbf0e54f2e24ba821ff2d3dcf86bf6dc4ae130
164
+ parser (3.3.10.1) sha256=06f6a725d2cd91e5e7f2b7c32ba143631e1f7c8ae2fb918fc4cebec187e6a688
165
+ prism (1.9.0) sha256=7b530c6a9f92c24300014919c9dcbc055bf4cdf51ec30aed099b06cd6674ef85
166
+ pry (0.16.0) sha256=d76c69065698ed1f85e717bd33d7942c38a50868f6b0673c636192b3d1b6054e
167
+ racc (1.8.1) sha256=4a7f6929691dbec8b5209a0b373bc2614882b55fc5d2e447a21aaa691303d62f
168
+ rainbow (3.1.1) sha256=039491aa3a89f42efa1d6dec2fc4e62ede96eb6acd95e52f1ad581182b79bc6a
169
+ rake (13.3.1) sha256=8c9e89d09f66a26a01264e7e3480ec0607f0c497a861ef16063604b1b08eb19c
170
+ rake-gem-maintenance (0.1.0)
171
+ rb-fsevent (0.11.2) sha256=43900b972e7301d6570f64b850a5aa67833ee7d87b458ee92805d56b7318aefe
172
+ rb-inotify (0.11.1) sha256=a0a700441239b0ff18eb65e3866236cd78613d6b9f78fea1f9ac47a85e47be6e
173
+ regexp_parser (2.11.3) sha256=ca13f381a173b7a93450e53459075c9b76a10433caadcb2f1180f2c741fc55a4
174
+ reline (0.6.3) sha256=1198b04973565b36ec0f11542ab3f5cfeeec34823f4e54cebde90968092b1835
175
+ rspec (3.13.2) sha256=206284a08ad798e61f86d7ca3e376718d52c0bc944626b2349266f239f820587
176
+ rspec-core (3.13.6) sha256=a8823c6411667b60a8bca135364351dda34cd55e44ff94c4be4633b37d828b2d
177
+ rspec-expectations (3.13.5) sha256=33a4d3a1d95060aea4c94e9f237030a8f9eae5615e9bd85718fe3a09e4b58836
178
+ rspec-mocks (3.13.7) sha256=0979034e64b1d7a838aaaddf12bf065ea4dc40ef3d4c39f01f93ae2c66c62b1c
179
+ rspec-support (3.13.7) sha256=0640e5570872aafefd79867901deeeeb40b0c9875a36b983d85f54fb7381c47c
180
+ rubocop (1.84.1) sha256=14cc626f355141f5a2ef53c10a68d66b13bb30639b26370a76559096cc6bcc1a
181
+ rubocop-ast (1.49.0) sha256=49c3676d3123a0923d333e20c6c2dbaaae2d2287b475273fddee0c61da9f71fd
182
+ rubocop-rake (0.7.1) sha256=3797f2b6810c3e9df7376c26d5f44f3475eda59eb1adc38e6f62ecf027cbae4d
183
+ rubocop-rspec (3.9.0) sha256=8fa70a3619408237d789aeecfb9beef40576acc855173e60939d63332fdb55e2
184
+ ruby-progressbar (1.13.0) sha256=80fc9c47a9b640d6834e0dc7b3c94c9df37f08cb072b7761e4a71e22cff29b33
185
+ shellany (0.0.1) sha256=0e127a9132698766d7e752e82cdac8250b6adbd09e6c0a7fbbb6f61964fedee7
186
+ thor (1.5.0) sha256=e3a9e55fe857e44859ce104a84675ab6e8cd59c650a49106a05f55f136425e73
187
+ unicode-display_width (3.2.0) sha256=0cdd96b5681a5949cdbc2c55e7b420facae74c4aaf9a9815eee1087cb1853c42
188
+ unicode-emoji (4.2.0) sha256=519e69150f75652e40bf736106cfbc8f0f73aa3fb6a65afe62fefa7f80b0f80f
189
+
190
+ BUNDLED WITH
191
+ 4.0.4
data/Guardfile ADDED
@@ -0,0 +1,32 @@
1
+ # frozen_string_literal: true
2
+
3
+ guard "bundler" do
4
+ require "guard/bundler"
5
+ require "guard/bundler/verify"
6
+ helper = Guard::Bundler::Verify.new
7
+
8
+ files = ["Gemfile"]
9
+ files += Dir["*.gemspec"] if files.any? { |f| helper.uses_gemspec?(f) }
10
+
11
+ files.each { |file| watch(helper.real_path(file)) }
12
+ end
13
+
14
+ group :red_green_refactor, halt_on_fail: true do
15
+ guard "rspec", cmd: "bundle exec rspec" do
16
+ require "guard/rspec/dsl"
17
+ dsl = Guard::RSpec::Dsl.new(self)
18
+
19
+ rspec = dsl.rspec
20
+ watch(rspec.spec_helper) { rspec.spec_dir }
21
+ watch(rspec.spec_support) { rspec.spec_dir }
22
+ watch(rspec.spec_files)
23
+
24
+ ruby = dsl.ruby
25
+ dsl.watch_spec_files_for(ruby.lib_files)
26
+ end
27
+
28
+ guard "rubocop", cli: ["--format", "clang", "--autocorrect"] do
29
+ watch(/.+\.rb$/)
30
+ watch(%r{(?:.+/)?\.rubocop(?:_todo)?\.yml$}) { |m| m[0] ? File.dirname(m[0]) : "." }
31
+ end
32
+ end
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2025 Christophe Broult
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,51 @@
1
+ # Rake::GemMaintenance
2
+
3
+ [![Test rake-gem-maintenance](https://github.com/cbroult/rake-gem-maintenance/actions/workflows/main.yml/badge.svg)](https://github.com/cbroult/rake-gem-maintenance/actions/workflows/main.yml)
4
+ [![Dependabot Updates](https://github.com/cbroult/rake-gem-maintenance/actions/workflows/dependabot/dependabot-updates/badge.svg)](https://github.com/cbroult/rake-gem-maintenance/actions/workflows/dependabot/dependabot-updates)
5
+
6
+ Reusable Rake tasks for gem maintenance: dependency upgrades and version bumps.
7
+
8
+ ## Installation
9
+
10
+ Add to your Gemfile:
11
+
12
+ ```ruby
13
+ gem "rake-gem-maintenance"
14
+ ```
15
+
16
+ ## Quick Start
17
+
18
+ Add to your Rakefile for default behavior:
19
+
20
+ ```ruby
21
+ require "rake/gem_maintenance/install_tasks"
22
+ ```
23
+
24
+ This defines:
25
+ - `upgrade` / `upgrade:auto` — full upgrade pipeline (branch, update, verify, commit, bump, release, push)
26
+ - `upgrade:branch` — create upgrade branch
27
+ - `upgrade:gems` — update rubygems, bundler, and all gems
28
+ - `upgrade:commit` — commit upgraded Gemfile/Gemfile.lock
29
+ - `upgrade:push` — push upgrade branch
30
+ - `version:bump[type]` — bump version (patch/minor/major) and update Gemfile.lock
31
+ - `bump[type]` — alias for `version:bump`
32
+
33
+ ## Customization
34
+
35
+ ```ruby
36
+ require "rake/gem_maintenance"
37
+
38
+ Rake::GemMaintenance::UpgradeTask.new do |t|
39
+ t.main_branch = "develop"
40
+ t.upgrade_branch = "chore/upgrade-deps"
41
+ t.commit_message = "chore: upgrade dependencies"
42
+ end
43
+
44
+ Rake::GemMaintenance::VersionBumpTask.new do |t|
45
+ t.default_type = "minor"
46
+ end
47
+ ```
48
+
49
+ ## License
50
+
51
+ The gem is available as open source under the terms of the [MIT License](LICENSE.txt).
data/Rakefile ADDED
@@ -0,0 +1,19 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "bundler/gem_tasks"
4
+ require "rspec/core/rake_task"
5
+
6
+ RSpec::Core::RakeTask.new(:spec)
7
+
8
+ require "rubocop/rake_task"
9
+
10
+ RuboCop::RakeTask.new do |t|
11
+ t.options = ["--autocorrect"]
12
+ end
13
+
14
+ require "rake/gem_maintenance/install_tasks"
15
+
16
+ task default: :verify
17
+
18
+ desc "Run all verification tasks"
19
+ task verify: %i[spec rubocop]
@@ -0,0 +1,6 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "../gem_maintenance"
4
+
5
+ Rake::GemMaintenance::UpgradeTask.new
6
+ Rake::GemMaintenance::VersionBumpTask.new
@@ -0,0 +1,124 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "rake"
4
+ require "rake/tasklib"
5
+
6
+ module Rake
7
+ module GemMaintenance
8
+ # Defines Rake tasks for upgrading gem dependencies.
9
+ #
10
+ # Creates: upgrade, upgrade:auto, upgrade:branch, upgrade:gems,
11
+ # upgrade:commit, upgrade:push
12
+ class UpgradeTask < ::Rake::TaskLib
13
+ attr_accessor :name, :main_branch, :upgrade_branch, :commit_message,
14
+ :files_to_commit, :verification_task, :release_task,
15
+ :version_bump_task, :update_rubygems, :update_gems,
16
+ :run_bundle_audit, :auto_pipeline
17
+
18
+ def initialize(name = :upgrade) # rubocop:disable Metrics/MethodLength
19
+ super()
20
+ @name = name
21
+ @main_branch = "main"
22
+ @upgrade_branch = "upgrade/gems"
23
+ @commit_message = "chore(deps): upgrade gems"
24
+ @files_to_commit = %w[Gemfile Gemfile.lock]
25
+ @verification_task = :verify
26
+ @release_task = :release
27
+ @version_bump_task = "version:bump"
28
+ @update_rubygems = true
29
+ @update_gems = true
30
+ @run_bundle_audit = true
31
+ @auto_pipeline = nil
32
+
33
+ yield self if block_given?
34
+ define_tasks
35
+ end
36
+
37
+ private
38
+
39
+ def define_tasks
40
+ define_top_level_task
41
+ define_auto_task
42
+ define_branch_task
43
+ define_gems_task
44
+ define_commit_task
45
+ define_push_task
46
+ end
47
+
48
+ def define_top_level_task
49
+ desc "Alias for #{name}:auto"
50
+ task name => "#{name}:auto"
51
+ end
52
+
53
+ def define_auto_task
54
+ task_instance = self
55
+ namespace name do
56
+ desc "Update gems automatically (branch to push and release)"
57
+ task auto: task_instance.send(:pipeline_tasks)
58
+ end
59
+ end
60
+
61
+ def define_branch_task
62
+ task_instance = self
63
+ namespace name do
64
+ desc "Create a branch for the upgrade"
65
+ task(:branch) { task_instance.send(:create_upgrade_branch) }
66
+ end
67
+ end
68
+
69
+ def define_gems_task
70
+ task_instance = self
71
+ namespace name do
72
+ desc "Upgrade gems, including bundler and gem"
73
+ task(:gems) { task_instance.send(:do_upgrade_gems) }
74
+ end
75
+ end
76
+
77
+ def define_commit_task
78
+ task_instance = self
79
+ namespace name do
80
+ desc "Commit the upgrade branch"
81
+ task(:commit) { task_instance.send(:commit_changes) }
82
+ end
83
+ end
84
+
85
+ def define_push_task
86
+ task_instance = self
87
+ namespace name do
88
+ desc "Push the upgrade"
89
+ task(:push) { task_instance.send(:push_branch) }
90
+ end
91
+ end
92
+
93
+ def pipeline_tasks
94
+ return auto_pipeline if auto_pipeline
95
+
96
+ %i[branch gems] + [verification_task, :commit, version_bump_task.to_sym, release_task, :push]
97
+ end
98
+
99
+ def create_upgrade_branch
100
+ sh "git checkout #{main_branch}"
101
+ sh "git pull"
102
+ sh "git branch -D #{upgrade_branch}" unless `git branch --list #{upgrade_branch}`.chomp.empty?
103
+ sh "git checkout -b #{upgrade_branch}"
104
+ end
105
+
106
+ def do_upgrade_gems
107
+ sh "gem update --system" if update_rubygems
108
+ sh "gem update" if update_gems
109
+ sh "bundle update --bundler"
110
+ sh "bundle update --all"
111
+ sh "bundle audit" if run_bundle_audit
112
+ end
113
+
114
+ def commit_changes
115
+ sh "git add #{files_to_commit.join(' ')}"
116
+ sh "git commit -m '#{commit_message}'"
117
+ end
118
+
119
+ def push_branch
120
+ sh "git push origin #{upgrade_branch}"
121
+ end
122
+ end
123
+ end
124
+ end
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Rake
4
+ module GemMaintenance
5
+ VERSION = "0.1.0"
6
+ end
7
+ end
@@ -0,0 +1,97 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "rake"
4
+ require "rake/tasklib"
5
+
6
+ module Rake
7
+ module GemMaintenance
8
+ # Defines Rake tasks for version bumping with gem-release.
9
+ #
10
+ # Creates: version:bump[type] and bump[type] (alias)
11
+ class VersionBumpTask < ::Rake::TaskLib
12
+ VALID_TYPES = %w[patch minor major].freeze
13
+
14
+ attr_accessor :namespace_name, :default_type, :commit_message_template,
15
+ :create_alias, :amend_with_gemfile_lock
16
+
17
+ def initialize
18
+ super
19
+ @namespace_name = :version
20
+ @default_type = "patch"
21
+ @commit_message_template = "chore(release): %<version>s"
22
+ @create_alias = true
23
+ @amend_with_gemfile_lock = true
24
+
25
+ yield self if block_given?
26
+
27
+ define_tasks
28
+ end
29
+
30
+ private
31
+
32
+ def define_tasks
33
+ define_version_bump_task
34
+ define_alias_task if create_alias
35
+ end
36
+
37
+ def define_version_bump_task
38
+ task_instance = self
39
+ bump_desc = "Bump version (patch, minor, major) and update Gemfile.lock. Default: #{default_type}"
40
+
41
+ namespace namespace_name do
42
+ desc bump_desc
43
+ task :bump, [:type] do |_t, args|
44
+ task_instance.send(:run_bump, args)
45
+ end
46
+ end
47
+ end
48
+
49
+ def define_alias_task
50
+ ns = namespace_name
51
+
52
+ desc "Alias for #{ns}:bump"
53
+ task :bump, [:type] => ["#{ns}:bump"]
54
+ end
55
+
56
+ def run_bump(args)
57
+ args.with_defaults(type: default_type)
58
+
59
+ validate_version_type(args.type)
60
+ execute_version_bump(args.type)
61
+
62
+ return unless amend_with_gemfile_lock
63
+
64
+ update_gemfile_lock
65
+ amend_commit_to_include_gemfile_lock_changes
66
+ end
67
+
68
+ def validate_version_type(type)
69
+ return if VALID_TYPES.include?(type)
70
+
71
+ abort "Error: Version type must be one of: #{VALID_TYPES.join(', ')}"
72
+ end
73
+
74
+ def execute_version_bump(type)
75
+ puts "Bumping #{type} version..."
76
+ bump_result = system("bundle exec gem bump --version #{type} --message '#{commit_message_template}'")
77
+ return if bump_result
78
+
79
+ abort "Error: Failed to bump version"
80
+ end
81
+
82
+ def update_gemfile_lock
83
+ puts "Updating Gemfile.lock..."
84
+ bundle_result = system("bundle install")
85
+ return if bundle_result
86
+
87
+ abort "Error: Failed to update Gemfile.lock"
88
+ end
89
+
90
+ def amend_commit_to_include_gemfile_lock_changes
91
+ puts "Amending commit to include Gemfile.lock update..."
92
+ system("git add .")
93
+ system("git commit --amend --no-edit")
94
+ end
95
+ end
96
+ end
97
+ end
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "gem_maintenance/version"
4
+ require_relative "gem_maintenance/upgrade_task"
5
+ require_relative "gem_maintenance/version_bump_task"
@@ -0,0 +1,32 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "lib/rake/gem_maintenance/version"
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = "rake-gem-maintenance"
7
+ spec.version = Rake::GemMaintenance::VERSION
8
+ spec.authors = ["Christophe Broult"]
9
+ spec.email = ["cbroult@yahoo.com"]
10
+
11
+ spec.summary = "Rake tasks for gem maintenance: dependency upgrades and version bumps."
12
+ spec.description = "Provides reusable Rake::TaskLib subclasses for upgrading gem dependencies and bumping versions."
13
+ spec.homepage = "https://github.com/cbroult/rake-gem-maintenance"
14
+ spec.license = "MIT"
15
+ spec.required_ruby_version = ">= 3.3.7"
16
+
17
+ spec.metadata["allowed_push_host"] = "https://rubygems.org"
18
+ spec.metadata["homepage_uri"] = spec.homepage
19
+ spec.metadata["changelog_uri"] = File.join(spec.homepage, "Changelog")
20
+ spec.metadata["rubygems_mfa_required"] = "true"
21
+
22
+ spec.files = Dir.chdir(File.expand_path(__dir__)) do
23
+ `git ls-files -z`.split("\x0").reject do |f|
24
+ (f == __FILE__) || f.match(%r{\A(?:(?:test|spec|features)/|\.(?:git|travis|circleci)|appveyor)})
25
+ end
26
+ end
27
+ spec.require_paths = ["lib"]
28
+
29
+ spec.add_dependency "bundler-audit"
30
+ spec.add_dependency "gem-release", "~> 2.2"
31
+ spec.add_dependency "rake", ">= 13.0"
32
+ end
metadata ADDED
@@ -0,0 +1,102 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: rake-gem-maintenance
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Christophe Broult
8
+ bindir: bin
9
+ cert_chain: []
10
+ date: 1980-01-02 00:00:00.000000000 Z
11
+ dependencies:
12
+ - !ruby/object:Gem::Dependency
13
+ name: bundler-audit
14
+ requirement: !ruby/object:Gem::Requirement
15
+ requirements:
16
+ - - ">="
17
+ - !ruby/object:Gem::Version
18
+ version: '0'
19
+ type: :runtime
20
+ prerelease: false
21
+ version_requirements: !ruby/object:Gem::Requirement
22
+ requirements:
23
+ - - ">="
24
+ - !ruby/object:Gem::Version
25
+ version: '0'
26
+ - !ruby/object:Gem::Dependency
27
+ name: gem-release
28
+ requirement: !ruby/object:Gem::Requirement
29
+ requirements:
30
+ - - "~>"
31
+ - !ruby/object:Gem::Version
32
+ version: '2.2'
33
+ type: :runtime
34
+ prerelease: false
35
+ version_requirements: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - "~>"
38
+ - !ruby/object:Gem::Version
39
+ version: '2.2'
40
+ - !ruby/object:Gem::Dependency
41
+ name: rake
42
+ requirement: !ruby/object:Gem::Requirement
43
+ requirements:
44
+ - - ">="
45
+ - !ruby/object:Gem::Version
46
+ version: '13.0'
47
+ type: :runtime
48
+ prerelease: false
49
+ version_requirements: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - ">="
52
+ - !ruby/object:Gem::Version
53
+ version: '13.0'
54
+ description: Provides reusable Rake::TaskLib subclasses for upgrading gem dependencies
55
+ and bumping versions.
56
+ email:
57
+ - cbroult@yahoo.com
58
+ executables: []
59
+ extensions: []
60
+ extra_rdoc_files: []
61
+ files:
62
+ - ".rspec"
63
+ - ".rubocop.yml"
64
+ - CLAUDE.md
65
+ - Gemfile
66
+ - Gemfile.lock
67
+ - Guardfile
68
+ - LICENSE.txt
69
+ - README.md
70
+ - Rakefile
71
+ - lib/rake/gem_maintenance.rb
72
+ - lib/rake/gem_maintenance/install_tasks.rb
73
+ - lib/rake/gem_maintenance/upgrade_task.rb
74
+ - lib/rake/gem_maintenance/version.rb
75
+ - lib/rake/gem_maintenance/version_bump_task.rb
76
+ - rake-gem-maintenance.gemspec
77
+ homepage: https://github.com/cbroult/rake-gem-maintenance
78
+ licenses:
79
+ - MIT
80
+ metadata:
81
+ allowed_push_host: https://rubygems.org
82
+ homepage_uri: https://github.com/cbroult/rake-gem-maintenance
83
+ changelog_uri: https://github.com/cbroult/rake-gem-maintenance/Changelog
84
+ rubygems_mfa_required: 'true'
85
+ rdoc_options: []
86
+ require_paths:
87
+ - lib
88
+ required_ruby_version: !ruby/object:Gem::Requirement
89
+ requirements:
90
+ - - ">="
91
+ - !ruby/object:Gem::Version
92
+ version: 3.3.7
93
+ required_rubygems_version: !ruby/object:Gem::Requirement
94
+ requirements:
95
+ - - ">="
96
+ - !ruby/object:Gem::Version
97
+ version: '0'
98
+ requirements: []
99
+ rubygems_version: 4.0.6
100
+ specification_version: 4
101
+ summary: 'Rake tasks for gem maintenance: dependency upgrades and version bumps.'
102
+ test_files: []