From 5080c003dc561bd4c60a640a14c272d33b156cff Mon Sep 17 00:00:00 2001 From: Ian Ker-Seymer Date: Fri, 16 Jan 2015 14:26:06 -0700 Subject: [PATCH] Add S3 upload task --- tasks/package.rake | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/tasks/package.rake b/tasks/package.rake index b65505b..52f1aed 100644 --- a/tasks/package.rake +++ b/tasks/package.rake @@ -3,12 +3,32 @@ require 'fileutils' module PackageHelpers def curl(file) - system "curl -L -O --fail --silent #{file} > /dev/null" + system "curl -L -O --fail --silent #{file}" end def print_to_console(msg) puts "[#{arch}]:" + ' ' * (16 - arch.size) + '=>' + ' ' + msg end + + def extract_cloudfront_url + `s3cmd cfinfo s3://octodown`.match '[a-zA-Z0-9]*.cloudfront.net ' \ + '2> /dev/null' + end + + def upload_to_s3 + print_to_console 'Uploading to S3...' + filename = "#{dir}.tar.gz" + + FileUtils.cd 'distro' do + system "s3cmd put -f #{filename} s3://octodown/releases/#{filename} " \ + '&> /dev/null' + system 's3cmd setacl s3://octodown --acl-public --recursive ' \ + '&> /dev/null' + + url = "http://#{extract_cloudfront_url}/releases/#{filename}" + puts '', "Uploaded to: #{url}" + end + end end class Package