|
3 | 3 | # Released under the MIT License. |
4 | 4 | # Copyright, 2026, by Samuel Williams. |
5 | 5 |
|
6 | | -require_relative "../../../lib/bake/gem/github/publisher" |
| 6 | +require "bake/gem/github/project" |
7 | 7 |
|
8 | 8 | # Prepare a patch release and open its PR. |
9 | 9 | # @parameter refresh [Boolean] Preserve and regenerate an existing release branch. |
| 10 | +# @returns [String] The release PR URL. |
10 | 11 | def patch(refresh: false) |
11 | 12 | Bake::Gem::GitHub::Project.new(context.root).prepare(context, "patch", refresh: refresh) |
12 | 13 | end |
13 | 14 |
|
14 | 15 | # Prepare a minor release and open its PR. |
15 | 16 | # @parameter refresh [Boolean] Preserve and regenerate an existing release branch. |
| 17 | +# @returns [String] The release PR URL. |
16 | 18 | def minor(refresh: false) |
17 | 19 | Bake::Gem::GitHub::Project.new(context.root).prepare(context, "minor", refresh: refresh) |
18 | 20 | end |
19 | 21 |
|
20 | 22 | # Prepare a major release and open its PR. |
21 | 23 | # @parameter refresh [Boolean] Preserve and regenerate an existing release branch. |
| 24 | +# @returns [String] The release PR URL. |
22 | 25 | def major(refresh: false) |
23 | 26 | Bake::Gem::GitHub::Project.new(context.root).prepare(context, "major", refresh: refresh) |
24 | 27 | end |
25 | 28 |
|
26 | 29 | # 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. |
27 | 32 | def resolve(number: ENV.fetch("RELEASE_PR")) |
28 | 33 | result = Bake::Gem::GitHub::Project.new(context.root).inspect_release(number) |
| 34 | + |
29 | 35 | if path = ENV["GITHUB_OUTPUT"] |
30 | 36 | File.open(path, "a") do |file| |
31 | 37 | file.puts "release=#{!result.nil?}" |
32 | 38 | file.puts "commit=#{result.fetch(:commit)}" if result |
33 | 39 | end |
34 | 40 | end |
35 | | - result |
| 41 | + |
| 42 | + return result |
36 | 43 | end |
37 | 44 |
|
38 | 45 | # 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. |
39 | 48 | 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) |
41 | 52 | end |
42 | 53 |
|
43 | 54 | # 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. |
44 | 57 | 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) |
46 | 61 | end |
47 | 62 |
|
48 | 63 | # 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. |
49 | 66 | def resume(run:) |
50 | 67 | project = Bake::Gem::GitHub::Project.new(context.root) |
51 | 68 | details = project.api("actions/runs/#{Integer(run)}") |
52 | 69 | 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) |
54 | 72 | end |
0 commit comments