Skip to content

Commit a576fa4

Browse files
committed
✨ Allow building gem without signing
- for linux distros - Set SKIP_GEM_SIGNING in ENV
1 parent 63123e5 commit a576fa4

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

oauth2.gemspec

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,16 +18,16 @@ Gem::Specification.new do |spec|
1818
# Linux distros may package ruby gems differently,
1919
# and securely certify them independently via alternate package management systems.
2020
# Ref: https://gitlab.com/oauth-xx/version_gem/-/issues/3
21-
# Hence, only enable signing if the cert_file is present.
21+
# Hence, only enable signing if `SKIP_GEM_SIGNING` is not set in ENV.
2222
# See CONTRIBUTING.md
23-
default_user_cert = "certs/#{ENV.fetch("GEM_CERT_USER", ENV["USER"])}.pem"
24-
default_user_cert_path = File.join(__dir__, default_user_cert)
25-
cert_file_path = ENV.fetch("GEM_CERT_PATH", default_user_cert_path)
23+
user_cert = "certs/#{ENV.fetch("GEM_CERT_USER", ENV["USER"])}.pem"
24+
cert_file_path = File.join(__dir__, user_cert)
2625
cert_chain = cert_file_path.split(",")
27-
if cert_file_path && cert_chain.map { |fp| File.exist?(fp) }
26+
cert_chain.select! { |fp| File.exist?(fp) }
27+
if cert_file_path && cert_chain.any?
2828
spec.cert_chain = cert_chain
29-
if $PROGRAM_NAME.end_with?("gem", "rake") && ARGV[0] == "build"
30-
spec.signing_key = File.expand_path("~/.ssh/gem-private_key.pem")
29+
if $PROGRAM_NAME.end_with?("gem") && ARGV[0] == "build" && !ENV.include?("SKIP_GEM_SIGNING")
30+
spec.signing_key = File.join(Gem.user_home, ".ssh", "gem-private_key.pem")
3131
end
3232
end
3333

0 commit comments

Comments
 (0)