]> sbz's 6dev Repos - docker-gc-build/.git/blob - release.sh
Do not hardcode the GPG key id fetch it from online SKS servers
[docker-gc-build/.git] / release.sh
1 #!/bin/bash
2
3 set -e
4
5 [ ! -f `which gpg` ] && {
6     echo 2>&1 "You need to install gnupg: brew install gnupg"
7     exit 2
8 }
9
10 [ ! -f `which deb-s3` ] && {
11     echo 2>&1 "You need to install deb-s3: gem install deb-s3"
12     exit 2
13 }
14
15 COMMIT=`(cd docker-gc && git rev-parse --short HEAD)`
16 VERSION="2:`cat ${PWD}/docker-gc/version.txt`~${COMMIT}"
17 TAG="gonitro/docker-gc-build:${COMMIT}"
18 AWS_REGION=us-west-2
19 BUCKET=nitro-apt-repo
20 NITRO_GPG_KEY=`gpg --batch --search-keys  --with-colons infra-guild@gonitro.com 2>&1| sed -E -n 's/^pub:.*(........):.*:.*:.*::/\1/p'`
21
22 printf  "[+] Using GPG %s for package signature\n" ${NITRO_GPG_KEY}
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 printf "[+] Debian Package generated into '%s'\n" ${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 printf "[+] Successfully uploaded package into %s\n" ${BUCKET}
43
44 exit 0