Repository navigation
Expand file tree
/
Copy pathRakefile
More file actions
96 lines (84 loc) · 2.97 KB
/
Copy pathRakefile
File metadata and controls
96 lines (84 loc) · 2.97 KB
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
# 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
begin
require 'github_changelog_generator/task'
require_relative 'lib/facter/version'
GitHubChangelogGenerator::RakeTask.new :changelog do |config|
config.header = <<~HEADER.chomp
# Changelog
All notable changes to this project will be documented in this file.
HEADER
config.user = 'openvoxproject'
config.project = 'openfact'
config.exclude_labels = %w[dependencies duplicate question invalid wontfix wont-fix modulesync skip-changelog]
config.future_release = Facter::VERSION
# we limit the changelog to all new openvox releases, to skip perforce onces
# otherwise the changelog generate takes a lot amount of time
config.since_tag = '6.0.0'
config.exclude_tags_regex = /\A5\./
end
rescue LoadError
task :changelog do
abort('Run `bundle install --with release` to install the `github_changelog_generator` gem.')
end
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 stdout
else
puts "Error building facter.gemspec \n#{stdout} \n#{stderr}"
exit(1)
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
desc 'Prepare for a release'
task 'release:prepare' => [:changelog]
begin
require 'rubocop/rake_task'
rescue LoadError
# Do nothing if no required gem installed
else
RuboCop::RakeTask.new(:rubocop) do |task|
# These make the rubocop experience maybe slightly less terrible
task.options = ['--display-cop-names', '--display-style-guide', '--extra-details']
# Use Rubocop's Github Actions formatter if possible
task.formatters << 'github' if ENV['GITHUB_ACTIONS'] == 'true'
end
end