-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathRakefile
40 lines (36 loc) · 1.23 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
PLUGIN_NAME = Dir['*.gemspec'][0].split('.')[0..-2].join('.')
require 'fileutils'
task :require_version do
unless ENV['VERSION']
puts "VERSION is required: rake build VERSION=X.Y.Z"
exit 1
end
end
task :build => [:require_version] do
split_version = ENV['VERSION'].to_s.split('.')
major = split_version[0]
minor = split_version[1]
if ENV['VERSION'] =~ /[a-zA-Z]+/
# Prerelease version
remainder = split_version[2..-1].join(".")
remainder.gsub!('-', '.pre.') # Rubygems replaces dashes with .pre.
remainder_split = remainder.split('.')
patch = remainder_split[0]
other = remainder_split[1..-1].join('.')
gem_version = "#{major}.#{minor}.#{patch}.#{other}"
else
gem_version = ENV['VERSION']
end
gem_name = PLUGIN_NAME + '-' + gem_version + '.gem'
# Build using sh built into Rake:
# https://rubydoc.info/gems/rake/FileUtils#sh-instance_method
if File.exist?("./microservices/CFDP/Gemfile.lock")
FileUtils.rm("./microservices/CFDP/Gemfile.lock")
end
sh('gem', 'build', PLUGIN_NAME)
sh("openc3cli validate #{gem_name}") do |ok, status|
if !ok && status.exitstatus == 127 # command not found
puts "Install the openc3 gem to validate! (gem install openc3)"
end
end
end