bake-modernize 0.63.0 → 0.64.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f1285a821430d0892953c2d45e86f8e5d11fe8d27d8212614ddb87914599370c
4
- data.tar.gz: f1c4f3edb34b0bbecc4b5cada2286f2572173db3d168d21aa0fd8193dcb60b79
3
+ metadata.gz: e1aadc6454ab0888d86a24dd830c3923d6aad289ad86feb368f24c7bfb53e211
4
+ data.tar.gz: 7c80f3d12f4d215a56b2eefad74a0157a97a4d1add74ea14cea17ed70413df33
5
5
  SHA512:
6
- metadata.gz: f75c658d10774d709155f72b2933bcd818cad028d2cff2c80071b1b09f46e9caa3fccc82e3503d988d29d410dd08027887d4bba51d6ace5a5abd4931d2b08434
7
- data.tar.gz: 35962d24b690a376da309acf3608817cee9340e1d330cf11a589153c445387e1a4e9e390d6b0836b021e5bb9f212878c7eb4a60bcdeedacb28fdce7ca23b0252
6
+ metadata.gz: 6f99b9120cb5cb55ea2d6dbb7f652b364a86d7c32cfe55e21b66f50fe8180e7779e330496d3c61bd909c5e794c8e938a87c550d21205ced641b5043a5c5a92fd
7
+ data.tar.gz: 0a2aa4783d673e20fbb7c778e385cbfe6c2c49e3c768deeaa01451eea65b75bc85148d68df3e080a194feba9e7fdc6159bbefe17cbf404f6e48ff5727eca9644
checksums.yaml.gz.sig CHANGED
Binary file
@@ -24,6 +24,7 @@ def update(path: default_gemspec_path, output: $stdout)
24
24
  spec = ::Gem::Specification.load(path)
25
25
 
26
26
  root = File.dirname(path)
27
+ signing = Bake::Modernize::Signing.new(spec)
27
28
  version_path = version_path(root, spec.name)
28
29
 
29
30
  constant = File.read(File.join(root, version_path))
@@ -56,7 +57,7 @@ def update(path: default_gemspec_path, output: $stdout)
56
57
  if File.exist?(certificate_path)
57
58
  output.puts "\t"
58
59
  output.puts "\tspec.cert_chain = [\"release.cert\"]"
59
- output.puts "\tspec.signing_key = File.expand_path(\"~/.gem/release.pem\")"
60
+ output.puts "\tspec.signing_key = #{signing.private_key_expression}"
60
61
  end
61
62
 
62
63
  if spec.homepage and !spec.homepage.empty?
@@ -10,10 +10,10 @@ def signing(root: Dir.pwd)
10
10
  end
11
11
 
12
12
  def update(root:)
13
- release_certificate_path = File.expand_path("~/.gem/release.cert")
13
+ signing = Bake::Modernize::Signing.load(root)
14
14
  certificate_path = File.expand_path("release.cert", root)
15
15
 
16
- if File.exist?(release_certificate_path)
17
- FileUtils.cp(release_certificate_path, certificate_path)
16
+ if signing.certificate_path
17
+ FileUtils.cp(signing.certificate_path, certificate_path)
18
18
  end
19
19
  end
data/context/index.yaml CHANGED
@@ -7,6 +7,7 @@ metadata:
7
7
  changelog_uri: https://github.com/ioquatix/bake-modernize/blob/main/releases.md
8
8
  documentation_uri: https://ioquatix.github.io/bake-modernize/
9
9
  funding_uri: https://github.com/sponsors/ioquatix/
10
+ signing_owner: socketry
10
11
  source_code_uri: https://github.com/ioquatix/bake-modernize.git
11
12
  files:
12
13
  - path: getting-started.md
@@ -0,0 +1,85 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Released under the MIT License.
4
+ # Copyright, 2026, by Samuel Williams.
5
+
6
+ module Bake
7
+ module Modernize
8
+ # Resolve the RubyGems signing certificate and private key for a project.
9
+ class Signing
10
+ GEM_CREDENTIALS_PATH = File.expand_path("~/.gem")
11
+ GITHUB_OWNER = %r{\Ahttps?://github\.com/([\w.-]+)/}
12
+
13
+ # Load signing configuration from a project's gemspec.
14
+ # @parameter root [String] The project root.
15
+ # @returns [Signing] The signing configuration.
16
+ def self.load(root)
17
+ gemspec_path = Dir["*.gemspec", base: root].first
18
+ gemspec = Gem::Specification.load(File.join(root, gemspec_path)) if gemspec_path
19
+
20
+ return new(gemspec)
21
+ end
22
+
23
+ # @parameter gemspec [Gem::Specification | Nil] The project gemspec.
24
+ def initialize(gemspec)
25
+ @gemspec = gemspec
26
+ end
27
+
28
+ # The preferred certificate, if available.
29
+ # @returns [String | Nil] The certificate path.
30
+ def certificate_path
31
+ paths = []
32
+
33
+ if owner = signing_owner
34
+ paths << File.join(GEM_CREDENTIALS_PATH, "#{owner}-release.cert")
35
+ end
36
+
37
+ paths << File.join(GEM_CREDENTIALS_PATH, "release.cert")
38
+ return paths.find{|path| File.file?(path)}
39
+ end
40
+
41
+ # The private key path, preserving an existing gemspec setting.
42
+ # @returns [String] The private key path.
43
+ def private_key_path
44
+ return @gemspec.signing_key if @gemspec&.signing_key
45
+
46
+ if certificate_path = self.certificate_path
47
+ return certificate_path.sub(/\.cert\z/, ".pem")
48
+ end
49
+
50
+ return File.join(GEM_CREDENTIALS_PATH, "release.pem")
51
+ end
52
+
53
+ # Format a private key path for use in a gemspec.
54
+ # @returns [String] A Ruby expression.
55
+ def private_key_expression
56
+ prefix = GEM_CREDENTIALS_PATH + File::SEPARATOR
57
+ path = self.private_key_path
58
+
59
+ if path.start_with?(prefix)
60
+ relative_path = path.delete_prefix(prefix)
61
+ path = "~/.gem/#{relative_path}"
62
+ return "File.expand_path(#{path.inspect})"
63
+ end
64
+
65
+ return path.inspect
66
+ end
67
+
68
+ private
69
+
70
+ def signing_owner
71
+ return unless @gemspec
72
+
73
+ owner = @gemspec.metadata["signing_owner"]
74
+ return owner if owner&.match?(/\A[\w.-]+\z/)
75
+
76
+ urls = [@gemspec.metadata["source_code_uri"], @gemspec.homepage].compact
77
+ urls.each do |url|
78
+ if match = GITHUB_OWNER.match(url)
79
+ return match[1]
80
+ end
81
+ end
82
+ end
83
+ end
84
+ end
85
+ end
@@ -5,6 +5,6 @@
5
5
 
6
6
  module Bake
7
7
  module Modernize
8
- VERSION = "0.63.0"
8
+ VERSION = "0.64.0"
9
9
  end
10
10
  end
@@ -5,6 +5,7 @@
5
5
 
6
6
  require_relative "modernize/git"
7
7
  require_relative "modernize/license"
8
+ require_relative "modernize/signing"
8
9
  require_relative "modernize/version"
9
10
 
10
11
  require "build/files/glob"
data/readme.md CHANGED
@@ -14,6 +14,10 @@ Please see the [project documentation](https://ioquatix.github.io/bake-modernize
14
14
 
15
15
  Please see the [project releases](https://ioquatix.github.io/bake-modernize/releases/index) for all releases.
16
16
 
17
+ ### v0.64.0
18
+
19
+ - Prefer the configured signing owner or GitHub owner when selecting RubyGems signing certificates and private keys.
20
+
17
21
  ### v0.62.0
18
22
 
19
23
  - Refresh `license.md` and Ruby copyright headers with `modernize:license` after version increments in generated release hooks.
data/releases.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # Releases
2
2
 
3
+ ## v0.64.0
4
+
5
+ - Prefer the configured signing owner or GitHub owner when selecting RubyGems signing certificates and private keys.
6
+
3
7
  ## v0.62.0
4
8
 
5
9
  - Refresh `license.md` and Ruby copyright headers with `modernize:license` after version increments in generated release hooks.
data.tar.gz.sig CHANGED
@@ -1,2 +1 @@
1
- f�Fa���"�(ŋ��a�!�9u-�s�v��T�J�vLn��6�)�7�>+Z�M0��0�Ae��`�����5qnې"�a���H���n0u��;
2
- 0����_��9Ê�ѯ�������h�� O���o0~ր�<�ʱ��(r2��\[߫@D:*Nq�~�"5��y���`"I��Z��'D�.���C��5oț�*K�[>�=4�յ����p��D����0�y�
1
+ 2 ���0�Z�c�#�Q��'�����L�T��o�� � �k,���󢠲3xy
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bake-modernize
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.63.0
4
+ version: 0.64.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Samuel Williams
@@ -158,6 +158,7 @@ files:
158
158
  - lib/bake/modernize.rb
159
159
  - lib/bake/modernize/git.rb
160
160
  - lib/bake/modernize/license.rb
161
+ - lib/bake/modernize/signing.rb
161
162
  - lib/bake/modernize/version.rb
162
163
  - license.md
163
164
  - readme.md
@@ -186,6 +187,7 @@ metadata:
186
187
  changelog_uri: https://github.com/ioquatix/bake-modernize/blob/main/releases.md
187
188
  documentation_uri: https://ioquatix.github.io/bake-modernize/
188
189
  funding_uri: https://github.com/sponsors/ioquatix/
190
+ signing_owner: socketry
189
191
  source_code_uri: https://github.com/ioquatix/bake-modernize.git
190
192
  rdoc_options: []
191
193
  require_paths:
metadata.gz.sig CHANGED
Binary file