-
Notifications
You must be signed in to change notification settings - Fork 4
/
build
executable file
·72 lines (61 loc) · 2.2 KB
/
build
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#!/bin/bash
set -eEu
set -o pipefail
################################################################################
# Build the awscli docker image.
# Invoke as "ci/build" from the top-level of the git repo.
################################################################################
. ci/bootstrap
# We usually want to install the latest version of awscli, but
# allow to override by running `VERSION=1.11.27 ci/build`.
VERSION=${VERSION:-latest}
# Too bad the Dockerfile cannot contain something like this:
# LABEL version=$(aws --version 2>&1 | awk '{print $1}' | cut -d/ -f2)
# Therefore we have to discover the version before we build the image
# in order to put the version into a LABEL.
if [[ ${VERSION} == latest ]] && command -v pypi &>/dev/null; then
VERSION="$(pypi info awscli | awk '/^Latest release/ {print $NF}')"
fi
UP2DATE=false
declare -r AUTOBUILD=${AUTOBUILD:-false}
docker_hub_version() {
# Query for the version of the image on Docker Hub.
for _ in {1..3}; do
if microbadger -name jumanjiman/aws | awk '/version/ {print $NF}'; then
return 0
else
sleep 30s
fi
done
return 1
}
# AUTOBUILD is defined through parameterized builds.
# See ci/autobuild directory for details.
if [[ ${AUTOBUILD} == true ]]; then
# On circleci, we use https://github.com/jumanjihouse/cci
# to provide the microbadger and pypi commands.
pypi_latest=$(pypi info awscli | awk '/^Latest release/ {print $NF}')
dock_latest="$(docker_hub_version)"
VERSION=${pypi_latest}
info "pypi version is \"${pypi_latest}\" according to pypi."
info "dock version is \"${dock_latest}\" according to microbadger."
if [[ ${pypi_latest} == "${dock_latest}" ]]; then
UP2DATE=true
fi
fi
cat >ci/vars <<-EOF
# shellcheck shell=bash
declare -rx VERSION=${VERSION}
declare -rx UP2DATE=${UP2DATE}
declare -rx BUILD_DATE=$(date +%Y%m%dT%H%M)
declare -rx VCS_REF=$(git rev-parse --short HEAD)
declare -rx TAG=\${VERSION}-\${BUILD_DATE}-git-\${VCS_REF}
EOF
. ci/vars
if [[ ${UP2DATE} == true ]]; then
info "Image is up-to-date on docker hub; nothing to do."
else
run docker-compose build
run docker inspect jumanjiman/aws
run docker images | grep -E -e '^REPOSITORY' -e '^jumanjiman/aws' -e 'RUN'
fi