|
1 | 1 | require 'aws-sdk'
|
| 2 | +require 'pathname' |
2 | 3 |
|
3 | 4 | desc "Deploy a Rubinius release"
|
4 | 5 | task :deploy do
|
5 |
| - s3 = Aws::S3::Resource.new(region: "us-west-2") |
| 6 | + s3 = Aws::S3::Client.new(region: "us-west-2") |
| 7 | + file_exts = ["", ".md5", ".sha1", ".sha512"] |
| 8 | + |
| 9 | + # TODO: extract the name to a method |
| 10 | + basename = "rubinius-#{rbx_version}.tar.bz2" |
6 | 11 |
|
7 | 12 | # Build and upload the release tarball to S3.
|
8 | 13 | if ENV["TRAVIS_OS_NAME"] == "linux" and ENV["CC"] == "clang" and ENV["RVM"] == "rbx-2"
|
9 |
| - # TODO: extract the name to a method |
10 |
| - basename = "rubinius-#{rbx_version}.tar.bz2" |
11 |
| - |
12 | 14 | puts "Deploying release tarball #{basename}..."
|
13 | 15 |
|
14 | 16 | Rake::Task['release'].invoke
|
15 | 17 |
|
16 |
| - ["", ".md5", ".sha1", ".sha512"].each do |ext| |
| 18 | + bucket = "rubinius-releases-rubinius-com" |
| 19 | + |
| 20 | + index = "index.txt" |
| 21 | + index_list = s3.get_object(bucket: bucket, key: index).body.read |
| 22 | + |
| 23 | + file_exts.each do |ext| |
| 24 | + name = basename + ext |
| 25 | + s3.put_object bucket: bucket, key: name, body: File.read(name) |
| 26 | + |
| 27 | + index_list << name << "\n" unless index_list =~ /#{name}/ |
| 28 | + end |
| 29 | + |
| 30 | + s3.put_object bucket: bucket, key: index, body: index_list |
| 31 | + end |
| 32 | + |
| 33 | + # Build and upload a binary to S3. |
| 34 | + if ENV["RVM"] == "rbx-2" |
| 35 | + puts "Deploying Travis binary #{basename}..." |
| 36 | + |
| 37 | + Rake::Task['package:binary'].invoke |
| 38 | + |
| 39 | + url_prefix = "https://rubinius-binaries-rubinius-com.s3-us-west-2.amazonaws.com/" |
| 40 | + bucket = "rubinius-binaries-rubinius-com" |
| 41 | + |
| 42 | + if ENV["TRAVIS_OS_NAME"] == "linux" |
| 43 | + path_prefix = "ubuntu/12.04/x86_64/" |
| 44 | + else |
| 45 | + path_prefix = "osx/10.9/x86_64/" |
| 46 | + end |
| 47 | + |
| 48 | + index_list = s3.get_object(bucket: bucket, key: index).body.read |
| 49 | + |
| 50 | + file_exts.each do |ext| |
17 | 51 | name = basename + ext
|
18 |
| - obj = s3.bucket("rubinius-releases-rubinius-com").object(name) |
19 |
| - obj.upload_file(name) |
| 52 | + key = prefix + name |
| 53 | + s3.put_object bucket: bucket, key: key, body: File.read(name) |
| 54 | + |
| 55 | + path = url_prefix + key |
| 56 | + index_list << path << "\n" unless index_list =~ /#{path}/ |
20 | 57 | end
|
| 58 | + |
| 59 | + s3.put_object bucket: bucket, key: index, body: index_list |
21 | 60 | end
|
22 | 61 | end
|
0 commit comments