Skip to content

Commit 92fe580

Browse files
committed
📦️ Allow packaging on secure linux distros
- https://gitlab.com/oauth-xx/version_gem/-/issues/3
1 parent 6aed218 commit 92fe580

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

version_gem.gemspec

+11-2
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,17 @@ gem_version = VersionGem::Version::VERSION
88
VersionGem::Version.send(:remove_const, :VERSION)
99

1010
Gem::Specification.new do |spec|
11-
spec.cert_chain = ["certs/pboling.pem"]
12-
spec.signing_key = File.expand_path("~/.ssh/gem-private_key.pem") if $PROGRAM_NAME.end_with?("gem")
11+
# Linux distros may package ruby gems differently,
12+
# and securely certify them independently via alternate package management systems.
13+
# Ref: https://gitlab.com/oauth-xx/version_gem/-/issues/3
14+
# Hence, only enable signing if the cert_file is present.
15+
cert_file = ENV.fetch("GEM_CERT_PATH", "certs/#{ENV.fetch("GEM_CERT_USER", ENV["USER"])}.pem")
16+
if cert_file && File.exist?(cert_file)
17+
spec.cert_chain = [ENV.fetch("GEM_CERT_PATH", "certs/#{ENV.fetch("GEM_CERT_USER", ENV["USER"])}.pem")]
18+
if $PROGRAM_NAME.end_with?("gem") && ARGV == ["build", __FILE__]
19+
spec.signing_key = File.expand_path("~/.ssh/gem-private_key.pem")
20+
end
21+
end
1322

1423
spec.name = "version_gem"
1524
spec.version = gem_version

0 commit comments

Comments
 (0)