Import docker-gc-build branch
[docker-gc-build/.git] / release.sh
1 #!/bin/bash
2
3 set -e
4
5 DRY_RUN=' '
6
7 [ ! -f `which gpg` ] && {
8     echo 2>&1 "You need to install gnupg: brew install gnupg"
9     exit 2
10 }
11
12 [ ! -f `which deb-s3` ] && {
13     echo 2>&1 "You need to install deb-s3: gem install deb-s3"
14     exit 2
15 }
16
17 COMMIT=`git rev-parse --short HEAD`
18 VERSION="2:`cat version.txt`~${COMMIT}"
19 TAG="gonitro/docker-gc-build:${COMMIT}"
20 AWS_REGION=us-west-2
21 BUCKET=nitro-apt-repo
22 NITRO_GPG_KEY=C5075270
23
24 $DRY_RUN docker build \
25     -t ${TAG} \
26     --build-arg VERSION=${VERSION} \
27     --build-arg AWS_ACCESS_KEY_ID=${AWS_ACCESS_KEY_ID} \
28     --build-arg AWS_SECRET_ACCESS_KEY=${AWS_SECRET_ACCESS_KEY} \
29     -f ./Dockerfile .
30
31 $DRY_RUN docker run -v /tmp/:/tmp ${TAG} /bin/bash -c 'cp /docker-gc*.deb /tmp'
32
33 package=`ls /tmp/*.deb`
34 echo Debian Package generated into ${package}
35
36 $DRY_RUN deb-s3 upload \
37     --access-key-id=${AWS_ACCESS_KEY_ID} \
38     --secret-access-key=${AWS_SECRET_ACCESS_KEY} \
39     --s3-region=${AWS_REGION} \
40     --bucket=${BUCKET} \
41     --sign=${NITRO_GPG_KEY} ${package} || exit 1
42 echo Successfully uploaded package into ${BUCKET}
43
44 exit 0