require "rake" require "fileutils" require "dtc_rake/config" require "dtc_rake/product" require "dtc_rake/ui" require "dtc_rake/util" include DtcRake::UI product = DtcRake::Product.instance config = DtcRake::Config.instance if config.upload_readme namespace :upload do desc <<-DESC.gsub(/^ {4}/, '') Uploads README.md or README.txt to appbox artifact; requires path to password file. rake upload:readme DTC_RAKE_PASSWD=12-345-6 ("~/.uu/12-345-6" will be used) rake upload:readme DTC_RAKE_PASSWD=/path/to/12-345-6 (password file from the specified path will be used) DESC task :readme do error("Specify password file in env variable DTC_RAKE_PASSWD, e.g. rake upload:readme DTC_RAKE_PASSWD=12-345-6") unless ENV["DTC_RAKE_PASSWD"] readme_dir = File.expand_path(File.join(config.root_dir, "..")) readme = File.join(readme_dir, "README.md") unless File.file?(readme) readme = File.join(readme_dir, "README.txt") unless File.file?(readme) error("Neither README.md nor README.txt found in #{readme_dir}") end end art_uri = product.appbox_uri attch_code = product.readme_attachment_code announce "Uploading #{readme} to #{art_uri}:#{attch_code}..." attch_uri = DtcRake.upload_pack( file: readme, appbox_uri: art_uri, attachment_code: attch_code, credentials: ENV["DTC_RAKE_PASSWD"] ) success "File #{readme} uploaded to #{attch_uri}" end end end