require 'zlib' require 'archive/tar/minitar' require 'rake/packagetask' require 'open-uri' require_relative 'toolbelt' include Tasks def bash(cmd) puts(cmd) system(cmd) end def inno_path @inno_path ||= ENV["INNO_DIR"] || File.join(windows_root, "Program Files (x86)\\Inno Setup 5\\") end def windows_root return @windows_root if defined?(@windows_root) # cygwin? if Dir.exists?('/cygdrive') @windows_root = '/cygdrive/c/' else @windows_root = "C:\\" end end namespace :quandl do namespace :release do desc "Build tarball, windows, and darwin and push to storage" task :all do |t, args| # build tarball Rake::Task["quandl:release:tarball"].execute args.to_hash # build windows exe Rake::Task["quandl:release:windows"].execute args.to_hash # build darwin pkg Rake::Task["quandl:release:darwin"].execute args.to_hash end desc "Build tarball and push to storage" task :tarball do revision = `git branch | grep '*'`.gsub("*", '').strip.rstrip args = {} args[:revision] = revision unless revision == 'master' # build package Rake::Task["quandl:build:tarball"].execute args # push package to s3 Rake::Task["quandl:push:tarball"].execute args end desc "Build darwin and push to storage" task :darwin do |t, args| # build package Rake::Task["quandl:build:darwin"].execute args.to_hash # push package to s3 Rake::Task["quandl:push:darwin"].execute args.to_hash end desc "Build windows executable and push to storage" task :windows do |t, args| revision = `git branch | grep '*'`.gsub("*", '').strip.rstrip args = {} args[:revision] = revision unless revision == 'master' # build tarball Rake::Task["quandl:build:tarball"].execute args.to_hash.merge({ platform: 'windows' }) # push tarball to s3 Rake::Task["quandl:push:tarball"].execute args.to_hash.merge( platform: 'windows' ) # prereleases should not build Quandl Setup unless args[:revision].present? # inno is required unless Dir.exists?( inno_path ) puts "Inno not found.\nExpected installation at: #{inno_path}\nDownload and install: http://jrsoftware.org/download.php/is.exe?site=1" puts "Cannot build 'Quandl Setup.exe'" else # create windows exe setup Rake::Task["quandl:build:windows"].execute # push windows-package to s3 input_file = File.join( Toolbelt.pkg_path, 'Quandl Setup.exe') # upload to s3 Toolbelt::Storage.create( 'Quandl Setup.exe', File.open(input_file) ) end end end task :installer do Toolbelt::Storage.create('install.sh', File.open( File.join( Toolbelt.root_path, 'scripts/install.sh')) ) end end namespace :build do task :windows do |t, args| Toolbelt::Build::Windows.execute args.to_hash end task :tarball, :revision, :platform do |t, args| Toolbelt::Build::Tarball.execute args.to_hash end task :darwin, :revision do |t, args| Toolbelt::Build::Darwin.execute args.to_hash end task :ruby do |t, args| Toolbelt::Build::Ruby.execute args.to_hash end task :clean do |t,args| rm_rf Toolbelt.tmp_path rm_rf Toolbelt.build_path mkdir Toolbelt.tmp_path mkdir Toolbelt.build_path end end namespace :push do task :tarball, :revision, :platform do |t,args| Toolbelt::Push.execute args.to_hash end task :darwin, :revision, :platform do |t,args| name = "quandl-toolbelt" name += "-#{args[:revision]}" if args[:revision].present? Toolbelt::Storage.create( "#{name}.pkg", File.open( File.join(Toolbelt.build_path, 'quandl-toolbelt.pkg') ) ) Toolbelt::Storage.create( "VERSION", File.open( File.join(Toolbelt.root_path, 'VERSION') ) ) end end end