bake-modernize 0.60.0 → 0.61.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 51d18f56c68f066e57edde85e13977ab7c58accd900c3110cc1c7651c786a8ac
4
- data.tar.gz: 0afd62dd75d47fdf4d1fc45583fdfb4409704b21a0f1a5c798b7bc42bc394a7b
3
+ metadata.gz: 9e4b0b39c09795d386c79a00ca6b6ee8fe14365b6653ef96a5e89171d6cbed2f
4
+ data.tar.gz: 9e69e65ee1a2da00295b425ef16df650a67ff93d06f1573f0515d6ab4cad349f
5
5
  SHA512:
6
- metadata.gz: 2c82fbaa35a3e81a4369b7809a6b8deee54aa0a5f9b0eac54f1e62c1c75ff3a1618c65c94568b06511de01601af12b0667a339c113fec174274e875213b4c46a
7
- data.tar.gz: 72445ae2d086bbb2102f87fc11d01995607778097cf57c8a0ec578ae3245512a71683a1ed0dd1675f04b4bb8c37fb3ff4e0128ac342858ad36c80a9d59176912
6
+ metadata.gz: 91a9ef1fa66f27cd1cb13989a3c8e610e93598c74f2a8058da17b5f7ce8f072b613e4f7e5c828b9934842739ac57b24f937fd1eb3d2cc4abbfb30046e5f30b19
7
+ data.tar.gz: 425c31215daed9ed88e7827885347211afa152c2f97c77a2e73420358638b7c64a6d4b4f7485dc252dc5686b4734ec07e844fb01ee2ad8f33cbea8d82b461126
checksums.yaml.gz.sig CHANGED
Binary file
@@ -55,7 +55,13 @@ EOF
55
55
  def update_contributing(readme_path)
56
56
  root = Markly.parse(File.read(readme_path))
57
57
 
58
- replacement = Markly.parse(DEFAULT_CONTRIBUTING)
58
+ contributing = DEFAULT_CONTRIBUTING
59
+ if Bake::Modernize.gem_dependencies(File.dirname(readme_path)).include?("bake-gem-github")
60
+ contributing = contributing.sub("gem:release:patch", "gem:github:release:patch")
61
+ contributing = contributing.sub("### Developer Certificate of Origin", "See [bake-gem-github](https://github.com/socketry/bake-gem-github) for setup and release instructions.\n\n### Developer Certificate of Origin")
62
+ end
63
+
64
+ replacement = Markly.parse(contributing)
59
65
 
60
66
  return unless node = root.find_header("Contributing")
61
67
 
@@ -5,6 +5,7 @@
5
5
 
6
6
  require "bake/modernize"
7
7
  require "markly"
8
+ require "erb"
8
9
 
9
10
  # Update the project to use bake-releases for release notes.
10
11
  #
@@ -17,6 +18,28 @@ def releases(root: Dir.pwd)
17
18
  update_bake(root)
18
19
  end
19
20
 
21
+ # Migrate release dependencies and hooks to bake-gem-github. Configure its workflows with gem:github:setup afterwards.
22
+ #
23
+ # @parameter root [String] The root directory of the project.
24
+ def github(root: Dir.pwd)
25
+ require "bundler"
26
+
27
+ dependencies = Bake::Modernize.gem_dependencies(root)
28
+ environment = Bundler.unbundled_env
29
+
30
+ unless dependencies.include?("bake-gem-github")
31
+ system(environment, "bundle", "add", "bake-gem-github", "--group", "maintenance", chdir: root, unsetenv_others: true, exception: true)
32
+ end
33
+
34
+ if dependencies.include?("bake-gem")
35
+ system(environment, "bundle", "remove", "bake-gem", chdir: root, unsetenv_others: true, exception: true)
36
+ end
37
+
38
+ update_releases(File.join(root, "readme.md"))
39
+ update_releases_md(File.join(root, "releases.md"))
40
+ update_bake(root)
41
+ end
42
+
20
43
  private
21
44
 
22
45
  DEFAULT_CONTRIBUTING = <<~MARKDOWN
@@ -58,13 +81,21 @@ def update_bake(root)
58
81
  require "async/ollama"
59
82
 
60
83
  bake_path = File.join(root, "bake.rb")
61
- template = File.read(RELEASES_TEMPLATE_ROOT + "bake.rb")
84
+ github_releases = Bake::Modernize.gem_dependencies(root).include?("bake-gem-github")
85
+ template = ERB.new(File.read(RELEASES_TEMPLATE_ROOT + "bake.rb.erb"), trim_mode: "-").result(binding)
86
+ instruction = "Merge the template into the existing file. Add any missing methods and update existing method bodies to include any missing calls shown in the template."
87
+
88
+ if github_releases
89
+ instruction += " Remove the releases:github:release call from after_gem_release, because bake-gem-github publishes the GitHub release. Remove that method and its documentation if it becomes empty. Do not add an after_gem_release hook. Preserve all other methods and calls."
90
+ else
91
+ instruction += " Do not remove any existing calls."
92
+ end
62
93
 
63
94
  if File.exist?(bake_path)
64
95
  existing = File.read(bake_path)
65
96
  updated = Async::Ollama::Transform.call(existing,
66
97
  model: "qwen3-coder:latest",
67
- instruction: "Merge the template into the existing file. Add any missing methods and update existing method bodies to include any missing calls shown in the template. Do not remove any existing calls.",
98
+ instruction: instruction,
68
99
  template: template,
69
100
  )
70
101
  File.write(bake_path, updated)
@@ -0,0 +1,85 @@
1
+ # Getting Started
2
+
3
+ This guide explains how to update a Ruby gem with `bake-modernize`, review the generated changes, and optionally migrate to releases through GitHub.
4
+
5
+ ## Installation
6
+
7
+ Add the tools to the project's maintenance dependencies, preserving the existing groups and version requirements:
8
+
9
+ ``` ruby
10
+ group :maintenance, optional: true do
11
+ gem "agent-context"
12
+ gem "bake-modernize"
13
+ end
14
+ ```
15
+
16
+ Install the maintenance group and its agent guidance:
17
+
18
+ ``` bash
19
+ bundle config set --local with maintenance
20
+ bundle install
21
+ bundle exec bake agent:context:install
22
+ ```
23
+
24
+ If `bake-modernize` is already installed, use `bundle update bake-modernize --conservative` to update it, then reinstall the agent context. Read the project's instructions and relevant dependency guides before making changes. Generated `agents.md` and installed context are local working files; do not commit them.
25
+
26
+ ## Update a gem
27
+
28
+ Start from an up-to-date checkout with a clean working tree and create a branch for the modernization. Check the gem's supported Ruby versions, CI jobs, release process, signing configuration, and custom Bake tasks before updating them.
29
+
30
+ List the available tasks, then run the default modernization from the gem's root directory:
31
+
32
+ ``` bash
33
+ bundle exec bake list modernize
34
+ bundle exec bake modernize
35
+ git diff
36
+ ```
37
+
38
+ The default task updates standard files including CI workflows, dependency manifests, the gemspec, copyright attributions, contributing instructions, and release hooks. It modifies the working tree directly. Review the diff and selectively keep appropriate changes; generated changes are suggestions, and repository customizations can be intentional. Some tasks install gems, inspect GitHub URLs, or use Ollama with `qwen3-coder:latest` to merge existing files. Those merges need a running Ollama service with that model available.
39
+
40
+ You can run individual tasks when only part of the project needs updating:
41
+
42
+ ``` bash
43
+ bundle exec bake modernize:actions
44
+ bundle exec bake modernize:license
45
+ bundle exec bake modernize:releases
46
+ ```
47
+
48
+ Check the resulting Ruby compatibility requirements, gem dependencies, workflow names and required status checks, gemspec file list, signing paths, and release hooks. Preserve custom tasks and project-specific CI. Copyright generation ignores author names ending in `[bot]`; `.mailmap`, `.contributors.yaml`, and human authorship through file renames remain supported.
49
+
50
+ Run the project's checks before opening a PR. For gems using the standard Sus, RuboCop, and Decode tasks:
51
+
52
+ ``` bash
53
+ bundle exec bake test
54
+ bundle exec rubocop
55
+ bundle exec bake decode:index:coverage lib
56
+ ```
57
+
58
+ Add user-visible changes under `## Unreleased` in `releases.md`. If guides or project documentation changed, run `bundle exec bake utopia:project:update` and review its output. Commit the selected changes and describe any remaining manual setup in the PR.
59
+
60
+ ## Opt in to GitHub releases
61
+
62
+ The default `modernize` task does not migrate the publishing process. To adopt reviewed release PRs explicitly:
63
+
64
+ ``` bash
65
+ bundle exec bake modernize:releases:github
66
+ ```
67
+
68
+ This task adds `bake-gem-github` to maintenance dependencies, removes the direct `bake-gem` dependency when present, and updates release notes and Bake hooks. `bake-gem-github` supplies `bake-gem` and `bake-releases` as dependencies. Existing `bake-gem-github` version requirements are preserved.
69
+
70
+ Keep `after_gem_release_version_increment`, which updates release notes and project documentation. GitHub publishing replaces the `after_gem_release` call to `releases:github:release`. When merging an existing `bake.rb`, review the generated edit to ensure it removes that call while preserving unrelated custom behavior. Subsequent `modernize:releases` runs select the same template based on the target project's dependencies and do not add the publishing hook back. Contributing instructions also use `gem:github:release:patch` for projects that have adopted it.
71
+
72
+ Configure the release workflows separately using the installed gem's setup task. Pass the actual required CI job names; for example, a repository using the standard Ruby matrix and coverage workflows might use:
73
+
74
+ ``` bash
75
+ bundle exec bake gem:github:setup checks="3.3 on ubuntu,3.3 on macos,3.4 on ubuntu,3.4 on macos,4.0 on ubuntu,4.0 on macos,check,ruby on ubuntu,ruby on macos,validate"
76
+ bundle exec bake gem:github:setup:plan
77
+ ```
78
+
79
+ For an existing `config/release.yaml`, use `bundle exec bake gem:github:setup:update` to regenerate managed files instead. Review and commit the generated workflows, rulesets, configuration, and readme changes. Keep the readme's `Making Releases` section short: a release command and a link to [bake-gem-github](https://github.com/socketry/bake-gem-github).
80
+
81
+ Complete the setup described by [bake-gem-github](https://github.com/socketry/bake-gem-github): configure the RubyGems Trusted Publisher for `release-publish.yaml` and the `rubygems` environment, restrict that environment to the default branch, and install a matching signing key if signing is enabled. Select environment reviewers per repository when a separate publishing approval is wanted, for example `reviewers: [socketry/managers]`. Omitting reviewers leaves the environment's existing reviewer configuration unchanged.
82
+
83
+ After the setup PR is merged and the required CI jobs are available, an administrator reviews the plan and runs `bundle exec bake gem:github:setup:apply`. Generating files or upgrading gems does not apply remote settings. Workflow execution approvals, PR reviews, and publishing environment approvals are separate controls.
84
+
85
+ Once setup is complete, prepare a release with `bundle exec bake gem:github:release:patch` (or `minor` or `major`), or dispatch `release-prepare.yaml` remotely. Merge the reviewed release PR to start publishing.
@@ -0,0 +1,15 @@
1
+ # Automatically generated context index for Utopia::Project guides.
2
+ # Do not edit then files in this directory directly, instead edit the guides and then run `bake utopia:project:agent:context:update`.
3
+ ---
4
+ description: Automatically modernize parts of your project/gem.
5
+ metadata:
6
+ bug_tracker_uri: https://github.com/ioquatix/bake-modernize/issues
7
+ changelog_uri: https://github.com/ioquatix/bake-modernize/blob/main/releases.md
8
+ documentation_uri: https://ioquatix.github.io/bake-modernize/
9
+ funding_uri: https://github.com/sponsors/ioquatix/
10
+ source_code_uri: https://github.com/ioquatix/bake-modernize.git
11
+ files:
12
+ - path: getting-started.md
13
+ title: Getting Started
14
+ description: This guide explains how to update a Ruby gem with `bake-modernize`,
15
+ review the generated changes, and optionally migrate to releases through GitHub.
@@ -229,6 +229,8 @@ module Bake
229
229
 
230
230
  # Add a modification to the authorship.
231
231
  def add(path, author, time, id = nil)
232
+ return if author[:name].end_with?("[bot]")
233
+
232
234
  modification = Modification.new(author, time, path, id)
233
235
 
234
236
  @commits[modification.key] << modification
@@ -5,6 +5,6 @@
5
5
 
6
6
  module Bake
7
7
  module Modernize
8
- VERSION = "0.60.0"
8
+ VERSION = "0.61.0"
9
9
  end
10
10
  end
@@ -18,6 +18,21 @@ module Bake
18
18
 
19
19
  TEMPLATE_ROOT = Build::Files::Path.new(ROOT) + "template"
20
20
 
21
+ # Read the gem dependencies declared by the target project, including optional groups.
22
+ # @parameter root [String] The root directory of the project.
23
+ # @returns [Array(String)] The declared dependency names.
24
+ def self.gem_dependencies(root)
25
+ require "bundler"
26
+
27
+ if path = ["gems.rb", "Gemfile"].map{|name| File.expand_path(name, root)}.find{|path| File.file?(path)}
28
+ dsl = Bundler::Dsl.new
29
+ dsl.eval_gemfile(path)
30
+ return dsl.dependencies.map(&:name)
31
+ end
32
+
33
+ return []
34
+ end
35
+
21
36
  # Compute the template root path relative to the gem root.
22
37
  def self.template_path_for(path)
23
38
  TEMPLATE_ROOT + path
data/readme.md CHANGED
@@ -8,10 +8,18 @@ A gem for modernizing files in your Ruby project.
8
8
 
9
9
  Please see the [project documentation](https://ioquatix.github.io/bake-modernize/) for more details.
10
10
 
11
+ - [Getting Started](https://ioquatix.github.io/bake-modernize/guides/getting-started/index) - This guide explains how to update a Ruby gem with `bake-modernize`, review the generated changes, and optionally migrate to releases through GitHub.
12
+
11
13
  ## Releases
12
14
 
13
15
  Please see the [project releases](https://ioquatix.github.io/bake-modernize/releases/index) for all releases.
14
16
 
17
+ ### v0.61.0
18
+
19
+ - Provide agent context for updating gems and configuring GitHub releases.
20
+ - Ignore `[bot]` authors in copyright attributions and gem authors.
21
+ - Add opt-in `modernize:releases:github` migration and omit redundant publishing hooks for gems using `bake-gem-github`.
22
+
15
23
  ### v0.60.0
16
24
 
17
25
  - Ignore `/vendor/bundle` by default for dependencies installed by GitHub Actions' Bundler cache.
data/releases.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # Releases
2
2
 
3
+ ## v0.61.0
4
+
5
+ - Provide agent context for updating gems and configuring GitHub releases.
6
+ - Ignore `[bot]` authors in copyright attributions and gem authors.
7
+ - Add opt-in `modernize:releases:github` migration and omit redundant publishing hooks for gems using `bake-gem-github`.
8
+
3
9
  ## v0.60.0
4
10
 
5
11
  - Ignore `/vendor/bundle` by default for dependencies installed by GitHub Actions' Bundler cache.
@@ -10,6 +10,7 @@ def after_gem_release_version_increment(version)
10
10
  context["releases:update"].call(version)
11
11
  context["utopia:project:update"].call
12
12
  end
13
+ <% unless github_releases -%>
13
14
 
14
15
  # Create a GitHub release for the given tag.
15
16
  #
@@ -17,3 +18,4 @@ end
17
18
  def after_gem_release(tag:, **options)
18
19
  context["releases:github:release"].call(tag)
19
20
  end
21
+ <% end -%>
data.tar.gz.sig CHANGED
Binary file
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bake-modernize
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.60.0
4
+ version: 0.61.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Samuel Williams
@@ -92,6 +92,20 @@ dependencies:
92
92
  - - "~>"
93
93
  - !ruby/object:Gem::Version
94
94
  version: '1.6'
95
+ - !ruby/object:Gem::Dependency
96
+ name: erb
97
+ requirement: !ruby/object:Gem::Requirement
98
+ requirements:
99
+ - - ">="
100
+ - !ruby/object:Gem::Version
101
+ version: '0'
102
+ type: :runtime
103
+ prerelease: false
104
+ version_requirements: !ruby/object:Gem::Requirement
105
+ requirements:
106
+ - - ">="
107
+ - !ruby/object:Gem::Version
108
+ version: '0'
95
109
  - !ruby/object:Gem::Dependency
96
110
  name: markly
97
111
  requirement: !ruby/object:Gem::Requirement
@@ -139,6 +153,8 @@ files:
139
153
  - bake/modernize/releases.rb
140
154
  - bake/modernize/rubocop.rb
141
155
  - bake/modernize/signing.rb
156
+ - context/getting-started.md
157
+ - context/index.yaml
142
158
  - lib/bake/modernize.rb
143
159
  - lib/bake/modernize/git.rb
144
160
  - lib/bake/modernize/license.rb
@@ -158,7 +174,7 @@ files:
158
174
  - template/editorconfig/.editorconfig
159
175
  - template/git/.gitignore
160
176
  - template/readme/readme.md
161
- - template/releases/bake.rb
177
+ - template/releases/bake.rb.erb
162
178
  - template/releases/releases.md
163
179
  - template/rubocop/.github/workflows/rubocop.yaml
164
180
  - template/rubocop/.rubocop.yml
metadata.gz.sig CHANGED
Binary file