diff options
author | Jacob Vosmaer <jacob@gitlab.com> | 2017-01-27 21:14:42 +0300 |
---|---|---|
committer | Jacob Vosmaer <jacob@gitlab.com> | 2017-01-27 21:14:42 +0300 |
commit | 54d8c4f2c55cb0b7d28736c9552e53585053afd2 (patch) | |
tree | a9a3315dd95fd291735bb452f1e771cad422ac07 | |
parent | 90f90dbb9551e640f60a15f2bcfbb5831a485749 (diff) |
Build publishing script for S3s3-publish
-rw-r--r-- | .gitignore | 1 | ||||
-rwxr-xr-x | _support/s3-publish | 43 | ||||
-rwxr-xr-x | _support/s3-release | 30 |
3 files changed, 44 insertions, 30 deletions
diff --git a/.gitignore b/.gitignore index 66bdc5e5d..6b0d65f95 100644 --- a/.gitignore +++ b/.gitignore @@ -9,3 +9,4 @@ /*.zip /*.gem /_support/release +/*.tar.gz diff --git a/_support/s3-publish b/_support/s3-publish new file mode 100755 index 000000000..358de8fef --- /dev/null +++ b/_support/s3-publish @@ -0,0 +1,43 @@ +#!/usr/bin/env ruby +require 'digest' +require 'fileutils' +require_relative 'run.rb' + +BUILD_DIR = '_support/release' +BUILD_ID = capture!(%w[git log -1 --format=%H]).chomp +TARBALL = "gitaly-#{BUILD_ID}.tar.gz" +S3_BUCKET = ENV.fetch('S3_BUCKET') + +def main + FileUtils.rm_rf(BUILD_DIR) + [ + %w[linux amd64], + %w[darwin amd64], + ].each do |platform| + build_platform(*platform) + end + print_sha256 + FileUtils.mkdir_p(BUILD_DIR) + run!(%W[tar -zcf #{File.join(Dir.pwd, TARBALL)} .], BUILD_DIR) + run!(%W[aws s3 cp --acl public-read #{TARBALL} s3://#{File.join(S3_BUCKET, BUILD_ID[0, 2], TARBALL)}]) +end + +def build_platform(os, arch) + destdir = File.join(BUILD_DIR, os, arch) + FileUtils.mkdir_p(destdir) + run!(%W[make GOOS=#{os} GOARCH=#{arch} DESTDIR=#{destdir}]) +end + +def print_sha256 + puts + Dir.chdir(BUILD_DIR) do + Dir["**/*"].each do |entry| + next if File.directory?(entry) + sha = Digest::SHA256.file(entry) + puts "#{sha} #{entry}" + end + end + puts +end + +main diff --git a/_support/s3-release b/_support/s3-release deleted file mode 100755 index 0a4ef7ecf..000000000 --- a/_support/s3-release +++ /dev/null @@ -1,30 +0,0 @@ -#!/usr/bin/env ruby -require 'fileutils' -require_relative 'run.rb' - -RELEASE_DIR = '_support/release' -RELEASE_ID = capture!(%w[git log -1 --format=%H]).chomp - -def main - clean_release_dir - [ - %w[linux amd64], - %w[darwin amd64], - ].each do |platform| - build_platform(*platform) - end - FileUtils.cp('NOTICE', RELEASE_DIR) - run!(%W[tar -zxvf gitaly-#{RELEASE_ID}.tar.gz]) -end - -def clean_release_dir - FileUtils.rm_rf(RELEASE_DIR) -end - -def build_platform(os, arch) - destdir = File.join(RELEASE_DIR, os, arch) - FileUtils.mkdir_p(destdir) - run!(%W[make GOOS=#{os} GOARCH=#{arch} DESTDIR=#{destdir}]) -end - -main |