diff --git a/.gitignore b/.gitignore index e6c07e38908edb3c2cd997c2451f4787a969e0db..6b0d65f957d1f713e1222aee91cd6958e25dff58 100644 --- a/.gitignore +++ b/.gitignore @@ -8,3 +8,5 @@ /_support/.bundle /*.zip /*.gem +/_support/release +/*.tar.gz diff --git a/Makefile b/Makefile index 773492670bb3623bc785327ca08f5a3d137f0f9e..00f8634c0cd0234ae9fdc02d98702cdf6062ec83 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-publish b/_support/s3-publish new file mode 100755 index 0000000000000000000000000000000000000000..358de8fef34c43f1f77152c9dbe786bc3158fead --- /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