Repository navigation
Expand file tree
/
Copy pathrelease.rb
More file actions
72 lines (58 loc) · 2.82 KB
/
Copy pathrelease.rb
File metadata and controls
72 lines (58 loc) · 2.82 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
# frozen_string_literal: true
# Released under the MIT License.
# Copyright, 2026, by Samuel Williams.
require "bake/gem/github/project"
# Prepare a patch release and open its PR.
# @parameter refresh [Boolean] Preserve and regenerate an existing release branch.
# @returns [String] The release PR URL.
def patch(refresh: false)
Bake::Gem::GitHub::Project.new(context.root).prepare(context, "patch", refresh: refresh)
end
# Prepare a minor release and open its PR.
# @parameter refresh [Boolean] Preserve and regenerate an existing release branch.
# @returns [String] The release PR URL.
def minor(refresh: false)
Bake::Gem::GitHub::Project.new(context.root).prepare(context, "minor", refresh: refresh)
end
# Prepare a major release and open its PR.
# @parameter refresh [Boolean] Preserve and regenerate an existing release branch.
# @returns [String] The release PR URL.
def major(refresh: false)
Bake::Gem::GitHub::Project.new(context.root).prepare(context, "major", refresh: refresh)
end
# Resolve and validate a merged PR, emitting a commit output for the publishing job.
# @parameter number [String] The merged PR number; defaults to `RELEASE_PR`.
# @returns [Hash | Nil] Release metadata, or nil for an ordinary PR.
def resolve(number: ENV.fetch("RELEASE_PR"))
result = Bake::Gem::GitHub::Project.new(context.root).inspect_release(number)
if path = ENV["GITHUB_OUTPUT"]
File.open(path, "a") do |file|
file.puts "release=#{!result.nil?}"
file.puts "commit=#{result.fetch(:commit)}" if result
end
end
return result
end
# Build or restore the exact artifact for a merged release PR.
# @parameter number [String] The merged release PR number; defaults to `RELEASE_PR`.
# @returns [Hash] The built or restored release receipt.
def build(number: ENV.fetch("RELEASE_PR"))
require "bake/gem/github/publisher"
return Bake::Gem::GitHub::Publisher.new(context.root).build(number)
end
# Verify, upload and finalize a merged release using its retained artifact.
# @parameter number [String] The merged release PR number; defaults to `RELEASE_PR`.
# @returns [Hash] The published release receipt.
def publish(number: ENV.fetch("RELEASE_PR"))
require "bake/gem/github/publisher"
return Bake::Gem::GitHub::Publisher.new(context.root).publish(number)
end
# Rerun the original publishing workflow, preserving event identity and artifact bytes.
# @parameter run [String] The original release-publish workflow run ID.
# @returns [Boolean] True when GitHub accepts the rerun request.
def resume(run:)
project = Bake::Gem::GitHub::Project.new(context.root)
details = project.api("actions/runs/#{Integer(run)}")
raise "Expected a release-publish workflow run." unless details.fetch("path") == ".github/workflows/release-publish.yaml"
return project.system("gh", "run", "rerun", run.to_s, "--repo", project.config.fetch("repository"), chdir: context.root)
end