forked from iberianpig/fusuma
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRakefile
More file actions
113 lines (93 loc) · 3.18 KB
/
Rakefile
File metadata and controls
113 lines (93 loc) · 3.18 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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
# frozen_string_literal: true
require "rspec/core/rake_task"
RSpec::Core::RakeTask.new(:spec)
if RUBY_VERSION >= "3.1.0"
task default: [:spec, "rbs:generate", "rbs:validate", "rbs:check"]
else
task default: :spec
end
desc "bump version and generate CHANGELOG with the version"
task :bump, :type do |_, args|
require "bump"
label = args[:type]
unless %w[major minor patch pre no].include?(label)
raise "Usage: rake bump[LABEL] (LABEL: ['major', 'minor', 'patch', 'pre', 'no'])"
end
next_version = if label == "no"
Bump::Bump.current
else
Bump::Bump.next_version(label)
end
require "github_changelog_generator/task"
GitHubChangelogGenerator::RakeTask.new :changelog do |config|
gemspec_path = Dir.glob(File.join(File.dirname(File.expand_path(__FILE__)), "*.gemspec")).first
gemspec = Gem::Specification.load(gemspec_path)
config.user = gemspec.authors.first
config.project = gemspec.name
config.exclude_labels = ["duplicate", "question", "invalid", "wontfix", "Duplicate", "Question", "Invalid", "Wontfix", "Meta: Exclude From Changelog", "cannot reproduce"]
config.future_release = "v#{next_version}"
end
Rake::Task[:changelog].execute
puts "update CHANGELOG"
`git add CHANGELOG.md`
if label == "no"
puts "No bump version"
`git commit -m "update CHANGELOG"`
else
puts "Bump version to #{label}"
Bump::Bump.run(label)
end
puts 'Next step: "bundle exec rake release_tag"'
end
desc "Create and Push tag"
task :release_tag do
require "bundler/gem_tasks"
Rake::Task["release:source_control_push"].invoke
end
if RUBY_VERSION >= "3.1.0"
namespace :rbs do
desc "Generate RBS files for Fusuma"
task generate: %i[clean collection prototype inline subtract]
desc "Clean up RBS files"
task :clean do
sh "rm", "-rf", "sig/generated/"
sh "rm", "-rf", "sig/prototype/"
sh "rm", "-rf", ".gem_rbs_collection/"
end
desc "Install RBS collection"
task :collection do
sh "rbs", "collection", "install"
end
desc "Generate RBS files for Fusuma"
task :prototype do
sh "rbs", "prototype", "rb", "--out-dir=sig/prototype", "--base-dir=.", "lib"
end
desc "Generate inline RBS files"
task :inline do
# output rbs files from inline to sig/generated
# $ bundle exec rbs-inline --opt-out --output --base=. lib
sh "rbs-inline", "--opt-out", "--output", "--base=.", "lib"
end
desc "Subtract RBS files to create a minimal signature"
task :subtract do
if Dir.exist?("sig/generated")
sh "rbs", "subtract", "--write", "sig/prototype", "sig/generated"
# rbs subtract --write sig/prototype sig/generated
prototype_path = "sig/prototype"
generated_path = "sig/generated"
subtrahends = Dir["sig/*"]
.reject { |path| path == prototype_path || path == generated_path }
.map { |path| "--subtrahend=#{path}" }
sh "rbs", "subtract", "--write", "sig/prototype", "sig/generated", *subtrahends
end
end
desc "Validate RBS files"
task :validate do
sh "rbs", "-Isig", "validate"
end
desc "Type check with Steep"
task :check do
sh "steep check"
end
end
end