Repository navigation
Expand file tree
/
Copy pathgithub.rb
More file actions
43 lines (36 loc) · 1.73 KB
/
Copy pathgithub.rb
File metadata and controls
43 lines (36 loc) · 1.73 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
# frozen_string_literal: true
# Released under the MIT License.
# Copyright, 2026, by Samuel Williams.
# Generate local release workflows, policy payloads, and configuration for review.
# @parameter checks [Array(String)] Required CI check names, including matrix entries.
# @parameter repository [String] Canonical owner/repository; discovered through GitHub when omitted.
# @parameter branch [String] Default branch name; discovered through GitHub when omitted.
# @parameter approvals [Integer] Number of approving reviews.
# @parameter signing [Boolean] Require certificate signing; when omitted, enable it if `release.cert` exists.
# @parameter ruby [String] Ruby version for release workflows.
# @returns [Array(String)] Generated paths relative to the repository root.
def setup(checks:, repository: nil, branch: nil, approvals: 2, signing: nil, ruby: "3.4")
require "bake/gem/github/setup"
require "bake/gem/shell"
helper = Object.new.extend(Bake::Gem::Shell)
remote = if repository && branch
{}
else
JSON.parse(helper.readlines("gh", "repo", "view", "--json", "nameWithOwner,defaultBranchRef", chdir: context.root).join)
end
options = {
repository: repository || remote.fetch("nameWithOwner"),
branch: branch || remote.fetch("defaultBranchRef").fetch("name"),
checks: checks,
approvals: approvals,
ruby: ruby,
}
options[:signing] = signing unless signing.nil?
return Bake::Gem::GitHub::Setup.new(context.root).generate(**options)
end
# Show the desired rules, existing rules, environments, and RubyGems bootstrap values.
# @returns [Hash] Desired and observed settings; RubyGems values describe the expected configuration.
def doctor
require "bake/gem/github/project"
return Bake::Gem::GitHub::Project.new(context.root).doctor
end