Update docker-gc submodule with upstream
[docker-gc-build/.git] / release.sh
CommitLineData
e9a368ec
SB
1#!/bin/bash
2
64e09ea0
SB
3set -o errexit
4set -o nounset
5set -o pipefail
e9a368ec 6
64e09ea0
SB
7die() {
8 echo "$1" >&2
e9a368ec
SB
9 exit 2
10}
11
64e09ea0
SB
12declare -a deps=(gpg deb-s3)
13
14for dep in ${deps[*]}
15do
16 [[ ! -f `which $dep` ]] && {
17 die "You need to install: $dep"
18 }
19done
e9a368ec 20
d9b1e27d
SB
21COMMIT=`(cd docker-gc && git rev-parse --short HEAD)`
22VERSION="2:`cat ${PWD}/docker-gc/version.txt`~${COMMIT}"
e9a368ec
SB
23TAG="gonitro/docker-gc-build:${COMMIT}"
24AWS_REGION=us-west-2
25BUCKET=nitro-apt-repo
24f134a7 26NITRO_GPG_KEY=`gpg --batch --search-keys --with-colons infra-guild@gonitro.com 2>&1| sed -E -n 's/^pub:.*(........):.*:.*:.*::/\1/p'`
e9a368ec 27
d9b1e27d
SB
28printf "[+] Using GPG %s for package signature\n" ${NITRO_GPG_KEY}
29
e9a368ec
SB
30$DRY_RUN docker build \
31 -t ${TAG} \
32 --build-arg VERSION=${VERSION} \
33 --build-arg AWS_ACCESS_KEY_ID=${AWS_ACCESS_KEY_ID} \
34 --build-arg AWS_SECRET_ACCESS_KEY=${AWS_SECRET_ACCESS_KEY} \
35 -f ./Dockerfile .
36
37$DRY_RUN docker run -v /tmp/:/tmp ${TAG} /bin/bash -c 'cp /docker-gc*.deb /tmp'
38
d9b1e27d
SB
39package=`ls /tmp/*.deb || :`
40printf "[+] Debian Package generated into '%s'\n" ${package}
e9a368ec
SB
41
42$DRY_RUN deb-s3 upload \
43 --access-key-id=${AWS_ACCESS_KEY_ID} \
44 --secret-access-key=${AWS_SECRET_ACCESS_KEY} \
45 --s3-region=${AWS_REGION} \
46 --bucket=${BUCKET} \
47 --sign=${NITRO_GPG_KEY} ${package} || exit 1
d9b1e27d 48printf "[+] Successfully uploaded package into %s\n" ${BUCKET}
e9a368ec
SB
49
50exit 0