@@ -11,16 +11,16 @@ Gem::Specification.new do |spec|
1111 # Linux distros may package ruby gems differently,
1212 # and securely certify them independently via alternate package management systems.
1313 # Ref: https://gitlab.com/oauth-xx/version_gem/-/issues/3
14- # Hence, only enable signing if the cert_file is present .
14+ # Hence, only enable signing if `SKIP_GEM_SIGNING` is not set in ENV .
1515 # See CONTRIBUTING.md
16- default_user_cert = "certs/#{ ENV . fetch ( "GEM_CERT_USER" , ENV [ "USER" ] ) } .pem"
17- default_user_cert_path = File . join ( __dir__ , default_user_cert )
18- cert_file_path = ENV . fetch ( "GEM_CERT_PATH" , default_user_cert_path )
16+ user_cert = "certs/#{ ENV . fetch ( "GEM_CERT_USER" , ENV [ "USER" ] ) } .pem"
17+ cert_file_path = File . join ( __dir__ , user_cert )
1918 cert_chain = cert_file_path . split ( "," )
20- if cert_file_path && cert_chain . map { |fp | File . exist? ( fp ) }
19+ cert_chain . select! { |fp | File . exist? ( fp ) }
20+ if cert_file_path && cert_chain . any?
2121 spec . cert_chain = cert_chain
22- if $PROGRAM_NAME. end_with? ( "gem" , "rake" ) && ARGV [ 0 ] == "build"
23- spec . signing_key = File . expand_path ( "~/ .ssh/ gem-private_key.pem")
22+ if $PROGRAM_NAME. end_with? ( "gem" ) && ARGV [ 0 ] == "build" && ! ENV . include? ( "SKIP_GEM_SIGNING" )
23+ spec . signing_key = File . join ( Gem . user_home , " .ssh" , " gem-private_key.pem")
2424 end
2525 end
2626
0 commit comments