Skip to content

Commit a2ae70e

Browse files
Clarify release preparation, publishing, tests, and documentation. (#25)
1 parent 84e466e commit a2ae70e

36 files changed

Lines changed: 1551 additions & 707 deletions

‎bake-gem-github.gemspec‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ Gem::Specification.new do |spec|
1010
spec.license = "MIT"
1111
spec.homepage = "https://github.com/socketry/bake-gem-github"
1212
spec.metadata = {
13+
"documentation_uri" => "https://socketry.github.io/bake-gem-github/",
1314
"bug_tracker_uri" => "https://github.com/socketry/bake-gem-github/issues",
1415
"changelog_uri" => "https://github.com/socketry/bake-gem-github/blob/main/releases.md",
1516
"source_code_uri" => "https://github.com/socketry/bake-gem-github.git",

‎bake.rb‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,10 @@
33
# Released under the MIT License.
44
# Copyright, 2026, by Samuel Williams.
55

6-
# Regenerate documentation when preparing a release.
6+
# Update the project documentation with the new version number.
7+
#
8+
# @parameter version [String] The new version number.
79
def after_gem_release_version_increment(version)
810
context["releases:update"].call(version)
9-
context["utopia:project:agent:context:update"].call
11+
context["utopia:project:update"].call
1012
end

‎bake/gem/github.rb‎

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,29 +3,41 @@
33
# Released under the MIT License.
44
# Copyright, 2026, by Samuel Williams.
55

6-
# Generate local release workflows, policy, and documentation for review.
6+
# Generate local release workflows, policy payloads, and configuration for review.
77
# @parameter checks [Array(String)] Required CI check names, including matrix entries.
8-
# @parameter repository [String] Canonical owner/repository.
9-
# @parameter branch [String] Default branch name.
8+
# @parameter repository [String] Canonical owner/repository; discovered through GitHub when omitted.
9+
# @parameter branch [String] Default branch name; discovered through GitHub when omitted.
1010
# @parameter approvals [Integer] Number of approving reviews.
11-
# @parameter signing [Boolean] Require legacy certificate signing.
11+
# @parameter signing [Boolean] Require certificate signing; when omitted, enable it if `release.cert` exists.
1212
# @parameter ruby [String] Ruby version for release workflows.
13+
# @returns [Array(String)] Generated paths relative to the repository root.
1314
def setup(checks:, repository: nil, branch: nil, approvals: 2, signing: nil, ruby: "3.4")
14-
require_relative "../../lib/bake/gem/github/setup"
15+
require "bake/gem/github/setup"
1516
require "bake/gem/shell"
17+
1618
helper = Object.new.extend(Bake::Gem::Shell)
1719
remote = if repository && branch
1820
{}
1921
else
2022
JSON.parse(helper.readlines("gh", "repo", "view", "--json", "nameWithOwner,defaultBranchRef", chdir: context.root).join)
2123
end
22-
options = {repository: repository || remote.fetch("nameWithOwner"), branch: branch || remote.fetch("defaultBranchRef").fetch("name"), checks: checks, approvals: approvals, ruby: ruby}
24+
25+
options = {
26+
repository: repository || remote.fetch("nameWithOwner"),
27+
branch: branch || remote.fetch("defaultBranchRef").fetch("name"),
28+
checks: checks,
29+
approvals: approvals,
30+
ruby: ruby,
31+
}
2332
options[:signing] = signing unless signing.nil?
24-
Bake::Gem::GitHub::Setup.new(context.root).generate(**options)
33+
34+
return Bake::Gem::GitHub::Setup.new(context.root).generate(**options)
2535
end
2636

2737
# Show the desired rules, existing rules, environments, and RubyGems bootstrap values.
38+
# @returns [Hash] Desired and observed settings; RubyGems values describe the expected configuration.
2839
def doctor
29-
require_relative "../../lib/bake/gem/github/project"
30-
Bake::Gem::GitHub::Project.new(context.root).doctor
40+
require "bake/gem/github/project"
41+
42+
return Bake::Gem::GitHub::Project.new(context.root).doctor
3143
end

‎bake/gem/github/release.rb‎

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,52 +3,70 @@
33
# Released under the MIT License.
44
# Copyright, 2026, by Samuel Williams.
55

6-
require_relative "../../../lib/bake/gem/github/publisher"
6+
require "bake/gem/github/project"
77

88
# Prepare a patch release and open its PR.
99
# @parameter refresh [Boolean] Preserve and regenerate an existing release branch.
10+
# @returns [String] The release PR URL.
1011
def patch(refresh: false)
1112
Bake::Gem::GitHub::Project.new(context.root).prepare(context, "patch", refresh: refresh)
1213
end
1314

1415
# Prepare a minor release and open its PR.
1516
# @parameter refresh [Boolean] Preserve and regenerate an existing release branch.
17+
# @returns [String] The release PR URL.
1618
def minor(refresh: false)
1719
Bake::Gem::GitHub::Project.new(context.root).prepare(context, "minor", refresh: refresh)
1820
end
1921

2022
# Prepare a major release and open its PR.
2123
# @parameter refresh [Boolean] Preserve and regenerate an existing release branch.
24+
# @returns [String] The release PR URL.
2225
def major(refresh: false)
2326
Bake::Gem::GitHub::Project.new(context.root).prepare(context, "major", refresh: refresh)
2427
end
2528

2629
# Resolve and validate a merged PR, emitting a commit output for the publishing job.
30+
# @parameter number [String] The merged PR number; defaults to `RELEASE_PR`.
31+
# @returns [Hash | Nil] Release metadata, or nil for an ordinary PR.
2732
def resolve(number: ENV.fetch("RELEASE_PR"))
2833
result = Bake::Gem::GitHub::Project.new(context.root).inspect_release(number)
34+
2935
if path = ENV["GITHUB_OUTPUT"]
3036
File.open(path, "a") do |file|
3137
file.puts "release=#{!result.nil?}"
3238
file.puts "commit=#{result.fetch(:commit)}" if result
3339
end
3440
end
35-
result
41+
42+
return result
3643
end
3744

3845
# Build or restore the exact artifact for a merged release PR.
46+
# @parameter number [String] The merged release PR number; defaults to `RELEASE_PR`.
47+
# @returns [Hash] The built or restored release receipt.
3948
def build(number: ENV.fetch("RELEASE_PR"))
40-
Bake::Gem::GitHub::Publisher.new(context.root).build(number)
49+
require "bake/gem/github/publisher"
50+
51+
return Bake::Gem::GitHub::Publisher.new(context.root).build(number)
4152
end
4253

4354
# Verify, upload and finalize a merged release using its retained artifact.
55+
# @parameter number [String] The merged release PR number; defaults to `RELEASE_PR`.
56+
# @returns [Hash] The published release receipt.
4457
def publish(number: ENV.fetch("RELEASE_PR"))
45-
Bake::Gem::GitHub::Publisher.new(context.root).publish(number)
58+
require "bake/gem/github/publisher"
59+
60+
return Bake::Gem::GitHub::Publisher.new(context.root).publish(number)
4661
end
4762

4863
# Rerun the original publishing workflow, preserving event identity and artifact bytes.
64+
# @parameter run [String] The original release-publish workflow run ID.
65+
# @returns [Boolean] True when GitHub accepts the rerun request.
4966
def resume(run:)
5067
project = Bake::Gem::GitHub::Project.new(context.root)
5168
details = project.api("actions/runs/#{Integer(run)}")
5269
raise "Expected a release-publish workflow run." unless details.fetch("path") == ".github/workflows/release-publish.yaml"
53-
project.system("gh", "run", "rerun", run.to_s, "--repo", project.config.fetch("repository"), chdir: context.root)
70+
71+
return project.system("gh", "run", "rerun", run.to_s, "--repo", project.config.fetch("repository"), chdir: context.root)
5472
end

‎bake/gem/github/setup.rb‎

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,23 @@
44
# Copyright, 2026, by Samuel Williams.
55

66
# Inspect external settings before applying the generated policy.
7+
# @returns [Hash] Desired and observed settings for review.
78
def plan
89
context.lookup("gem:github:doctor").call
910
end
1011

1112
# Apply the four managed rulesets using the current gh administrator credentials.
13+
# @returns [Hash] The managed ruleset payloads after successful application.
1214
def apply
13-
require_relative "../../../lib/bake/gem/github/project"
14-
Bake::Gem::GitHub::Project.new(context.root).apply
15+
require "bake/gem/github/project"
16+
17+
return Bake::Gem::GitHub::Project.new(context.root).apply
1518
end
1619

1720
# Update generated files in the working tree using config/release.yaml and the installed templates.
21+
# @returns [Array(String)] Changed paths relative to the repository root.
1822
def update
19-
require_relative "../../../lib/bake/gem/github/setup"
20-
Bake::Gem::GitHub::Setup.new(context.root).update
23+
require "bake/gem/github/setup"
24+
25+
return Bake::Gem::GitHub::Setup.new(context.root).update
2126
end

0 commit comments

Comments
 (0)