-
Notifications
You must be signed in to change notification settings - Fork 498
/
Rakefile
60 lines (52 loc) · 1.73 KB
/
Rakefile
1
2
3
4
5
6
7
8
9
10
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
# frozen_string_literal: true
require 'bundler/gem_tasks'
require 'open3'
require 'rspec/core/rake_task'
require 'facter/version'
Dir.glob(File.join('tasks/**/*.rake')).each { |file| load file }
task default: :spec
desc 'Generate changelog'
task :changelog, [:version] do |_t, args|
sh "./scripts/generate_changelog.rb #{args[:version]}"
end
namespace :pl_ci do
desc 'build the gem and place it at the directory root'
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?
begin
require 'packaging'
Pkg::Util::RakeUtils.load_packaging_tasks
rescue LoadError => e
puts "Error loading packaging rake tasks: #{e}"
end
end