Module: DevopsHelper::GemPublishHelper
- Includes:
- TR::CondUtils
- Included in:
- GemReleaseHelper
- Defined in:
- lib/devops_helper/gem_publish_helper.rb
Defined Under Namespace
Classes: GemPublisherError
Instance Method Summary
collapse
Instance Method Details
#publish_gem(version, opts = { }, &block) ⇒ Object
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
|
# File 'lib/devops_helper/gem_publish_helper.rb', line 11
def publish_gem(version, opts = { }, &block)
cred = find_rubygems_api_key
selAcct = cred.keys.first
if cred.keys.length > 1
logger.tdebug :pubgem, "Multiple rubygems account detected."
selAcct = block.call(:multiple_rubygems_account, cred)
raise GemPublisherError, "No rubygems account is selected." if is_empty?(selAcct)
end
root = opts[:root] || Dir.getwd
foundGem = Dir.glob("**/*-#{version}.gem")
if foundGem.length == 0
raise DevopsHelper::Error, "No built gem found."
elsif foundGem.length > 1
if block
targetGem = block.call(:multiple_built_gems, foundGem)
else
raise DevopsHelper::Error, "Multiple versions of gem found : #{foundGem}. Please provide a block for selection"
end
else
targetGem = foundGem.first
end
cmd = "cd #{root} && gem push #{targetGem} -k #{selAcct}"
logger.tdebug :pubgem, "Command to publish gem : #{cmd}"
`#{cmd}`
[$?, targetGem]
end
|
#publish_gem_file(gemfile, opts = { }, &block) ⇒ Object
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
|
# File 'lib/devops_helper/gem_publish_helper.rb', line 45
def publish_gem_file(gemfile, opts = { }, &block)
cred = find_rubygems_api_key
selAcct = cred.keys.first
if cred.keys.length > 1
logger.tdebug :pubgemfile, "Multiple rubygems account detected."
selAcct = block.call(:multiple_rubygems_account, cred)
raise GemPublisherError, "No rubygems account is selected." if is_empty?(selAcct)
end
if File.exist?(gemfile)
root = File.dirname(gemfile)
targetGem = File.basename(gemfile)
cmd = "cd #{root} && gem push #{targetGem} -k #{selAcct}"
logger.tdebug :pubgemfile, "Command to publish gem : #{cmd}"
res = `#{cmd}`
[$?, res, targetGem]
else
raise GemPublisherError, "Given Gemfile '#{gemfile}' not found"
end
end
|