From 90f90dbb9551e640f60a15f2bcfbb5831a485749 Mon Sep 17 00:00:00 2001 From: Jacob Vosmaer Date: Fri, 27 Jan 2017 18:39:10 +0100 Subject: [PATCH 1/2] WIP --- .gitignore | 1 + Makefile | 5 +++-- _support/s3-release | 30 ++++++++++++++++++++++++++++++ 3 files changed, 34 insertions(+), 2 deletions(-) create mode 100755 _support/s3-release diff --git a/.gitignore b/.gitignore index e6c07e38908..66bdc5e5d87 100644 --- a/.gitignore +++ b/.gitignore @@ -8,3 +8,4 @@ /_support/.bundle /*.zip /*.gem +/_support/release diff --git a/Makefile b/Makefile index 773492670bb..00f8634c0cd 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,7 @@ PKG=gitlab.com/gitlab-org/gitaly BUILD_DIR=$(shell pwd) PKG_BUILD_DIR:=${BUILD_DIR}/_build/src/${PKG} +DESTDIR = . CMDS:=$(shell cd cmd && ls) export GOPATH=${BUILD_DIR}/_build @@ -17,7 +18,7 @@ ${BUILD_DIR}/_build: build: clean-build ${BUILD_DIR}/_build $(shell find . -name '*.go' -not -path './vendor/*') cd ${PKG_BUILD_DIR} && $(foreach cmd,${CMDS},go build ./cmd/${cmd} && ) true - mv $(foreach cmd,${CMDS},${PKG_BUILD_DIR}/${cmd}) ${BUILD_DIR}/ + mv $(foreach cmd,${CMDS},${PKG_BUILD_DIR}/${cmd}) ${DESTDIR}/ test: clean-build ${BUILD_DIR}/_build fmt cd ${PKG_BUILD_DIR} && go test ./... @@ -27,7 +28,7 @@ fmt: _support/gofmt-all -n | awk '{ print } END { if (NR > 0) { print "Please run _support/gofmt-all -f"; exit 1 } }' package: build - ./_support/package/package ${CMDS} + ./_support/package/package $(foreach cmd,${CMDS},${BUILD_DIR}/${cmd}) clean: clean-build rm -rf client/testdata diff --git a/_support/s3-release b/_support/s3-release new file mode 100755 index 00000000000..0a4ef7ecf31 --- /dev/null +++ b/_support/s3-release @@ -0,0 +1,30 @@ +#!/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 -- GitLab From 54d8c4f2c55cb0b7d28736c9552e53585053afd2 Mon Sep 17 00:00:00 2001 From: Jacob Vosmaer Date: Fri, 27 Jan 2017 19:14:42 +0100 Subject: [PATCH 2/2] Build publishing script for S3 --- .gitignore | 1 + _support/s3-publish | 43 +++++++++++++++++++++++++++++++++++++++++++ _support/s3-release | 30 ------------------------------ 3 files changed, 44 insertions(+), 30 deletions(-) create mode 100755 _support/s3-publish delete mode 100755 _support/s3-release diff --git a/.gitignore b/.gitignore index 66bdc5e5d87..6b0d65f957d 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 00000000000..358de8fef34 --- /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 0a4ef7ecf31..00000000000 --- 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 -- GitLab