bake-modernize 0.63.0 → 0.65.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: 32e279a2cd64b6db3d274c56caed5dd93cc3f8a5854c6cad52252354ab110968
4
+ data.tar.gz: e8314e50b8118a0d0a6f897088b791c4b1d743a648cb7d92e9ab3338e0c7c17e
5
5
  SHA512:
6
- metadata.gz: f75c658d10774d709155f72b2933bcd818cad028d2cff2c80071b1b09f46e9caa3fccc82e3503d988d29d410dd08027887d4bba51d6ace5a5abd4931d2b08434
7
- data.tar.gz: 35962d24b690a376da309acf3608817cee9340e1d330cf11a589153c445387e1a4e9e390d6b0836b021e5bb9f212878c7eb4a60bcdeedacb28fdce7ca23b0252
6
+ metadata.gz: 4c90c6778c2878f35d4ec00c79e7a17c48af5a0da3ff949db6ee8705169f3ab6c2d087633497d4ee1889e3dac1d135d53ae0bd25aace031374a23a19a6fcbaad
7
+ data.tar.gz: f4d0775f78dea54d1cd5ac739ecf17fe12169d39f9123fac195b1159b9e7e0c1291622782a76e4b703978445dc17a994d805d4149bb6664496812b2bb960c4c0
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.65.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.
@@ -25,12 +25,6 @@ jobs:
25
25
  experimental: [false]
26
26
 
27
27
  include:
28
- - os: ubuntu
29
- ruby: truffleruby
30
- experimental: true
31
- - os: ubuntu
32
- ruby: jruby
33
- experimental: true
34
28
  - os: ubuntu
35
29
  ruby: head
36
30
  experimental: true
@@ -38,13 +32,6 @@ jobs:
38
32
  steps:
39
33
  - uses: actions/checkout@v7
40
34
 
41
- # JRuby requires a more recent JDK than the runner provides by default:
42
- - uses: actions/setup-java@v4
43
- if: startsWith(matrix.ruby, 'jruby')
44
- with:
45
- distribution: temurin
46
- java-version: "21"
47
-
48
35
  - uses: ruby/setup-ruby@v1
49
36
  with:
50
37
  ruby-version: ${{matrix.ruby}}
data.tar.gz.sig CHANGED
Binary file
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.65.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