Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(PA-6427) Add rake tasks for building nightly gem #2726

Merged
merged 1 commit into from
May 29, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 25 additions & 2 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,38 @@ end

namespace :pl_ci do
desc 'build the gem and place it at the directory root'
task :gem_build do
stdout, stderr, status = Open3.capture3('gem build facter.gemspec')
task :gem_build, [:gemspec] do |_t, args|
args.with_defaults(gemspec: 'facter.gemspec')
stdout, stderr, status = Open3.capture3("gem build #{args.gemspec}")
if !status.exitstatus.zero?
puts "Error building facter.gemspec \n#{stdout} \n#{stderr}"
exit(1)
else
puts stdout
end
end

desc 'build the nightly gem and place it at the directory root'
task :nightly_gem_build do
# this is taken from `rake package:nightly_gem`
extended_dot_version = `git describe --tags --dirty --abbrev=7`.chomp.tr('-', '.')

# we must create tempfile in the same directory as facter.gemspec, since
# it uses __dir__ to determine which files to include
require 'tempfile'
Tempfile.create('gemspec', __dir__) do |dst|
File.open('facter.gemspec', 'r') do |src|
src.readlines.each do |line|
if line.match?(/spec\.version\s*=\s*'[0-9.]+'/)
line = "spec.version = '#{extended_dot_version}'"
end
dst.puts line
end
end
dst.flush
Rake::Task['pl_ci:gem_build'].invoke(dst.path)
end
end
end

if Rake.application.top_level_tasks.grep(/^(pl:|package:)/).any?
Expand Down