Skip to content

Commit a587c45

Browse files
committed
Use extended dot version when building nightly gems
1 parent edfed63 commit a587c45

File tree

1 file changed

+31
-3
lines changed

1 file changed

+31
-3
lines changed

Rakefile

+31-3
Original file line numberDiff line numberDiff line change
@@ -29,15 +29,43 @@ end
2929

3030
namespace :pl_ci do
3131
desc 'Build puppet gems'
32-
task :gem_build do
33-
stdout, stderr, status = Open3.capture3('gem build puppet.gemspec --platform x86-mingw32 && gem build puppet.gemspec --platform x64-mingw32 && gem build puppet.gemspec --platform universal-darwin && gem build puppet.gemspec')
32+
task :gem_build, [:gemspec] do |t, args|
33+
args.with_defaults(gemspec: 'puppet.gemspec')
34+
stdout, stderr, status = Open3.capture3(<<~END)
35+
gem build #{args.gemspec} --platform x86-mingw32 && \
36+
gem build #{args.gemspec} --platform x64-mingw32 && \
37+
gem build #{args.gemspec} --platform universal-darwin && \
38+
gem build #{args.gemspec}
39+
END
3440
if !status.exitstatus.zero?
35-
puts "Error building facter.gemspec \n#{stdout} \n#{stderr}"
41+
puts "Error building #{args.gemspec}\n#{stdout} \n#{stderr}"
3642
exit(1)
3743
else
3844
puts stdout
3945
end
4046
end
47+
48+
desc 'build the nightly puppet gems'
49+
task :nightly_gem_build do
50+
# this is taken from `rake package:nightly_gem`
51+
extended_dot_version = %x{git describe --tags --dirty --abbrev=7}.chomp.tr('-', '.')
52+
53+
# we must create tempfile in the same directory as puppetg.gemspec, since
54+
# it uses __dir__ to determine which files to include
55+
require 'tempfile'
56+
Tempfile.create('gemspec', __dir__) do |dst|
57+
File.open('puppet.gemspec', 'r') do |src|
58+
src.readlines.each do |line|
59+
if line.match?(/version\s*=\s*['"][0-9.]+['"]/)
60+
line = "spec.version = '#{extended_dot_version}'"
61+
end
62+
dst.puts line
63+
end
64+
end
65+
dst.flush
66+
Rake::Task['pl_ci:gem_build'].invoke(dst.path)
67+
end
68+
end
4169
end
4270

4371
task :spec do

0 commit comments

Comments
 (0)