Skip to content

Commit b2f3cd1

Browse files
committed
Use extended dot version when building nightly gems
1 parent 6355fff commit b2f3cd1

File tree

1 file changed

+31
-3
lines changed

1 file changed

+31
-3
lines changed

Rakefile

Lines changed: 31 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,15 +47,43 @@ end
4747

4848
namespace :pl_ci do
4949
desc 'Build puppet gems'
50-
task :gem_build do
51-
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')
50+
task :gem_build, [:gemspec] do |t, args|
51+
args.with_defaults(gemspec: 'puppet.gemspec')
52+
stdout, stderr, status = Open3.capture3(<<~END)
53+
gem build #{args.gemspec} --platform x86-mingw32 && \
54+
gem build #{args.gemspec} --platform x64-mingw32 && \
55+
gem build #{args.gemspec} --platform universal-darwin && \
56+
gem build #{args.gemspec}
57+
END
5258
if !status.exitstatus.zero?
53-
puts "Error building facter.gemspec \n#{stdout} \n#{stderr}"
59+
puts "Error building #{args.gemspec}\n#{stdout} \n#{stderr}"
5460
exit(1)
5561
else
5662
puts stdout
5763
end
5864
end
65+
66+
desc 'build the nightly puppet gems'
67+
task :nightly_gem_build do
68+
# this is taken from `rake package:nightly_gem`
69+
extended_dot_version = %x{git describe --tags --dirty --abbrev=7}.chomp.tr('-', '.')
70+
71+
# we must create tempfile in the same directory as puppetg.gemspec, since
72+
# it uses __dir__ to determine which files to include
73+
require 'tempfile'
74+
Tempfile.create('gemspec', __dir__) do |dst|
75+
File.open('puppet.gemspec', 'r') do |src|
76+
src.readlines.each do |line|
77+
if line.match?(/version\s*=\s*['"][0-9.]+['"]/)
78+
line = "spec.version = '#{extended_dot_version}'"
79+
end
80+
dst.puts line
81+
end
82+
end
83+
dst.flush
84+
Rake::Task['pl_ci:gem_build'].invoke(dst.path)
85+
end
86+
end
5987
end
6088

6189
task :spec do

0 commit comments

Comments
 (0)