-
Notifications
You must be signed in to change notification settings - Fork 2
/
Rakefile
65 lines (54 loc) · 1.99 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
61
62
63
64
65
require 'bundler/setup'
require 'rspec/core/rake_task'
require 'fileutils'
DISTRIBUTIONS = [
{ rb_platform: 'x86_64-darwin', filename: 'darwin-amd64.tar.gz' },
{ rb_platform: 'arm64-darwin', filename: 'darwin-arm64.tar.gz'},
{ rb_platform: 'x86_64-linux', filename: 'linux-amd64.tar.gz' },
{ rb_platform: 'arm-linux', filename: 'linux-arm.tar.gz' },
{ rb_platform: 'arm64-linux', filename: 'linux-arm64.tar.gz' },
{ rb_platform: 'aarch64-linux', filename: 'linux-arm64.tar.gz' },
{ rb_platform: 'x86-linux', filename: 'linux-386.tar.gz' },
{ rb_platform: 'ppc64le-linux', filename: 'linux-ppc64le.tar.gz' },
{ rb_platform: 's390x-linux', filename: 'linux-s390x.tar.gz' },
{ rb_platform: 'x64-mswin64', filename: 'windows-amd64.zip' }
]
task :build do
require 'rubygems/package'
require 'open-uri'
require 'helm-rb/version'
FileUtils.mkdir_p('pkg')
DISTRIBUTIONS.each do |distro|
FileUtils.rm_rf('vendor')
FileUtils.mkdir('vendor')
url = "https://get.helm.sh/helm-v#{HelmRb::HELM_VERSION}-#{distro[:filename]}"
ext = distro[:filename][distro[:filename].index('.')..-1]
distro_name = distro[:filename].chomp(ext)
archive = "helm#{ext}"
File.write(archive, URI.open(url).read)
FileUtils.mkdir('helm')
system("tar -C helm -xzvf #{archive}")
FileUtils.rm(archive)
Dir.glob(File.join('helm', distro_name, 'helm*')).each do |exe|
system("chmod +x #{exe}")
File.chmod(0755, exe)
FileUtils.cp(exe, 'vendor')
end
FileUtils.rm_rf('helm')
gemspec = eval(File.read('helm-rb.gemspec'))
gemspec.platform = distro[:rb_platform]
package = Gem::Package.build(gemspec)
FileUtils.mv(package, 'pkg')
end
end
task :publish do
DISTRIBUTIONS.each do |distro|
package_file = File.join('pkg', "helm-rb-#{HelmRb::VERSION}-#{distro[:rb_platform]}.gem")
system "gem push #{package_file}"
end
end
task default: :spec
desc 'Run specs'
RSpec::Core::RakeTask.new do |t|
t.pattern = './spec/**/*_spec.rb'
end