Commit ee55ce8af623e5dcd34f6a08b703271f48025d09
1 parent
3678c50e
Exists in
master
and in
13 other branches
Rewrite release.sh as a Makefile
Showing
2 changed files
with
40 additions
and
55 deletions
Show diff stats
... | ... | @@ -0,0 +1,38 @@ |
1 | +PROJECT=gitlab | |
2 | +RELEASE_BUCKET=downloads-packages | |
3 | +RELEASE_BUCKET_REGION=eu-west-1 | |
4 | +SECRET_DIR:=$(shell openssl rand -hex 20) | |
5 | + | |
6 | +build: | |
7 | + OMNIBUS_APPEND_TIMESTAMP=0 bin/omnibus build project ${PROJECT} | |
8 | + | |
9 | +release: no_changes on_tag purge build sync | |
10 | + | |
11 | +no_changes: | |
12 | + git diff --quiet HEAD | |
13 | + | |
14 | +on_tag: | |
15 | + git describe --exact-match | |
16 | + | |
17 | +purge: | |
18 | + bin/omnibus clean --purge ${PROJECT} | |
19 | + mkdir -p pkg | |
20 | + (cd pkg && find . -delete) | |
21 | + | |
22 | +sync: remove_json move_ee_to_secret_dir md5 s3_sync | |
23 | + | |
24 | +remove_json: | |
25 | + find pkg/ -name '*.json' -delete | |
26 | + | |
27 | +move_ee_to_secret_dir: | |
28 | + if (git describe | grep -q -w ee); then \ | |
29 | + mv pkg ${SECRET_DIR} \ | |
30 | + && mkdir pkg \ | |
31 | + && mv ${SECRET_DIR} pkg/ \ | |
32 | + ; fi | |
33 | + | |
34 | +md5: | |
35 | + find pkg -type f -exec md5sum {} \; | |
36 | + | |
37 | +s3_sync: | |
38 | + aws s3 sync pkg/ s3://${RELEASE_BUCKET} --acl public-read --region ${RELEASE_BUCKET_REGION} | ... | ... |
release.sh
1 | -#!/bin/bash | |
2 | -PROJECT=gitlab | |
3 | -RELEASE_BUCKET=downloads-packages | |
4 | -RELEASE_BUCKET_REGION=eu-west-1 | |
5 | - | |
6 | -function error_exit | |
7 | -{ | |
8 | - echo "$0: fatal error: $1" 1>&2 | |
9 | - exit 1 | |
10 | -} | |
11 | - | |
12 | -if !(git diff --quiet HEAD); then | |
13 | - error_exit 'uncommited changes' | |
14 | -fi | |
15 | - | |
16 | -if !(git describe --exact-match); then | |
17 | - error_exit 'HEAD is not tagged' | |
18 | -fi | |
19 | - | |
20 | -if !(bin/omnibus clean --purge ${PROJECT}); then | |
21 | - error_exit 'clean failed' | |
22 | -fi | |
23 | - | |
24 | -if !(touch build.txt); then | |
25 | - error_exit 'failed to mark build start time' | |
26 | -fi | |
27 | - | |
28 | -if !(OMNIBUS_APPEND_TIMESTAMP=0 bin/omnibus build project ${PROJECT}); then | |
29 | - error_exit 'build failed' | |
30 | -fi | |
31 | - | |
32 | -release_package=$(find pkg/ -newer build.txt -type f -not -name '*.json') | |
33 | -if [[ -z ${release_package} ]]; then | |
34 | - error_exit 'could not find the release package' | |
35 | -fi | |
36 | - | |
37 | -if (git describe | grep -w ee); then | |
38 | - release_dir="$(openssl rand -hex 20)" | |
39 | - if [[ $? -ne 0 ]]; then | |
40 | - error_exit 'failed to generate release directory name' | |
41 | - fi | |
42 | - remote_package_path="s3://${RELEASE_BUCKET}/${release_dir}/${release_package#pkg/}" | |
43 | -else | |
44 | - remote_package_path="s3://${RELEASE_BUCKET}/${release_package#pkg/}" | |
45 | -fi | |
46 | - | |
47 | -echo | |
48 | -echo 'Package MD5:' | |
49 | -md5sum ${release_package} | |
50 | - | |
51 | -echo | |
52 | -echo 'Starting upload' | |
53 | -if !(aws s3 cp ${release_package} ${remote_package_path} --acl public-read --region ${RELEASE_BUCKET_REGION}); then | |
54 | - error_exit 'release upload failed' | |
55 | -fi | |
1 | +#!/bin/sh | |
2 | +make release | ... | ... |