Add cli commands to list packages into the bucket
[docker-gc-build/.git] / release.sh
CommitLineData
e9a368ec
SB
1#!/bin/bash
2
3set -e
4
e9a368ec
SB
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
d9b1e27d
SB
15COMMIT=`(cd docker-gc && git rev-parse --short HEAD)`
16VERSION="2:`cat ${PWD}/docker-gc/version.txt`~${COMMIT}"
e9a368ec
SB
17TAG="gonitro/docker-gc-build:${COMMIT}"
18AWS_REGION=us-west-2
19BUCKET=nitro-apt-repo
24f134a7 20NITRO_GPG_KEY=`gpg --batch --search-keys --with-colons infra-guild@gonitro.com 2>&1| sed -E -n 's/^pub:.*(........):.*:.*:.*::/\1/p'`
e9a368ec 21
d9b1e27d
SB
22printf "[+] Using GPG %s for package signature\n" ${NITRO_GPG_KEY}
23
e9a368ec
SB
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
d9b1e27d
SB
33package=`ls /tmp/*.deb || :`
34printf "[+] Debian Package generated into '%s'\n" ${package}
e9a368ec
SB
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
d9b1e27d 42printf "[+] Successfully uploaded package into %s\n" ${BUCKET}
e9a368ec
SB
43
44exit 0