Sha256: ad5acf08c6490d23b53fecee723ffdcc863cbd2806fd00cd69ce3b041b181bcc

Contents?: true

Size: 1.99 KB

Versions: 20

Compression:

Stored size: 1.99 KB

Contents

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

Version data entries

20 entries across 20 versions & 1 rubygems

Version Path
helm-rb-0.3.0-x64-mswin64 Rakefile
helm-rb-0.3.0-s390x-linux Rakefile
helm-rb-0.3.0-ppc64le-linux Rakefile
helm-rb-0.3.0-x86-linux Rakefile
helm-rb-0.3.0-aarch64-linux Rakefile
helm-rb-0.3.0-arm64-linux Rakefile
helm-rb-0.3.0-arm-linux Rakefile
helm-rb-0.3.0-x86_64-linux Rakefile
helm-rb-0.3.0-arm64-darwin Rakefile
helm-rb-0.3.0-x86_64-darwin Rakefile
helm-rb-0.2.1-x64-mswin64 Rakefile
helm-rb-0.2.1-s390x-linux Rakefile
helm-rb-0.2.1-ppc64le-linux Rakefile
helm-rb-0.2.1-x86-linux Rakefile
helm-rb-0.2.1-aarch64-linux Rakefile
helm-rb-0.2.1-arm64-linux Rakefile
helm-rb-0.2.1-arm-linux Rakefile
helm-rb-0.2.1-x86_64-linux Rakefile
helm-rb-0.2.1-arm64-darwin Rakefile
helm-rb-0.2.1-x86_64-darwin Rakefile