From c6e35b53a96fc1f3692c2b6b781b0b0bf0ed4ee7 Mon Sep 17 00:00:00 2001 From: Steven Arcangeli Date: Sat, 9 Oct 2021 21:53:57 -0700 Subject: [PATCH] Rework build script to support publishing too --- build.sh | 31 +++++++++++++++++++------------ 1 file changed, 19 insertions(+), 12 deletions(-) diff --git a/build.sh b/build.sh index 80c2bda..a0ad724 100755 --- a/build.sh +++ b/build.sh @@ -1,16 +1,23 @@ #!/bin/bash -set -e +set -e -o pipefail -# Helper for building the images locally - -branch="$1" -if [ -z "$branch" ]; then - branch="$(git branch --no-color | grep \* | cut -d ' ' -f2)" -fi ./cp-static.sh +tag=$(git describe --tags) +echo "Building $tag" -for base in alpine baseimage; do - cd "py3-$base" - docker build . -t "stevearc/pypicloud:$branch-$base" -t "stevearc/pypicloud:local-$base" - cd .. -done +docker build --pull py3-baseimage -t "stevearc/pypicloud:latest" -t "stevearc/pypicloud:$tag" +docker build --pull py3-alpine -t "stevearc/pypicloud:latest-alpine" -t "stevearc/pypicloud:$tag-alpine" + +if [ "$1" == '--publish' ]; then + if [ -n "$(git status --porcelain)" ]; then + git status + echo "" + echo "Repo is not clean. Refusing to publish." + exit 1 + fi + git describe --tags --exact-match + docker push "stevearc/pypicloud:latest" + docker push "stevearc/pypicloud:$tag" + docker push "stevearc/pypicloud:latest-alpine" + docker push "stevearc/pypicloud:$tag-alpine" +fi