Repository navigation
Expand file tree
/
Copy pathrelease.rb
More file actions
54 lines (45 loc) · 2.07 KB
/
Copy pathrelease.rb
File metadata and controls
54 lines (45 loc) · 2.07 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
# frozen_string_literal: true
# Released under the MIT License.
# Copyright, 2026, by Samuel Williams.
require_relative "../../../lib/bake/gem/github/publisher"
# Prepare a patch release and open its PR.
# @parameter refresh [Boolean] Preserve and regenerate an existing release branch.
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.
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.
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.
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
result
end
# Build or restore the exact artifact for a merged release PR.
def build(number: ENV.fetch("RELEASE_PR"))
Bake::Gem::GitHub::Publisher.new(context.root).build(number)
end
# Verify, upload and finalize a merged release using its retained artifact.
def publish(number: ENV.fetch("RELEASE_PR"))
Bake::Gem::GitHub::Publisher.new(context.root).publish(number)
end
# Rerun the original publishing workflow, preserving event identity and artifact bytes.
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"
project.system("gh", "run", "rerun", run.to_s, "--repo", project.config.fetch("repository"), chdir: context.root)
end