2019-08-09 12:51:42 +00:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
|
2020-02-09 21:55:12 +00:00
|
|
|
set -eo pipefail
|
|
|
|
|
|
2021-01-01 10:26:31 +00:00
|
|
|
image_name="babashka/babashka"
|
2020-02-09 21:55:12 +00:00
|
|
|
image_tag=$(cat resources/BABASHKA_VERSION)
|
2019-08-09 12:51:42 +00:00
|
|
|
latest_tag="latest"
|
|
|
|
|
|
|
|
|
|
if [[ $image_tag =~ SNAPSHOT$ ]]; then
|
|
|
|
|
echo "This is a snapshot version"
|
|
|
|
|
snapshot="true"
|
|
|
|
|
else
|
|
|
|
|
echo "This is a non-snapshot version"
|
|
|
|
|
snapshot="false"
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
if [ -z "$CIRCLE_PULL_REQUEST" ] && [ "$CIRCLE_BRANCH" = "master" ]; then
|
|
|
|
|
echo "Building Docker image $image_name:$image_tag"
|
|
|
|
|
echo "$DOCKERHUB_PASS" | docker login -u "$DOCKERHUB_USER" --password-stdin
|
2021-03-12 09:16:39 +00:00
|
|
|
tar zxvf "/tmp/release/babashka-${image_tag}-linux-amd64.tar.gz"
|
2021-01-02 15:00:28 +00:00
|
|
|
docker build -t "$image_name" -f Dockerfile.ci .
|
2019-08-09 12:51:42 +00:00
|
|
|
docker tag "$image_name:$latest_tag" "$image_name:$image_tag"
|
2021-01-03 13:18:34 +00:00
|
|
|
rm -f bb
|
2021-01-03 14:57:30 +00:00
|
|
|
if [[ $snapshot == "false" ]]; then
|
2021-04-10 15:22:44 +00:00
|
|
|
tar zxvf "/tmp/release/babashka-${image_tag}-linux-amd64-static.tar.gz"
|
2021-01-03 14:57:30 +00:00
|
|
|
docker build -t "$image_name:alpine" -f Dockerfile.alpine .
|
|
|
|
|
docker tag "$image_name:alpine" "$image_name:$image_tag-alpine"
|
|
|
|
|
fi
|
2019-08-09 12:51:42 +00:00
|
|
|
# we only update latest when it's not a SNAPSHOT version
|
|
|
|
|
if [ "false" = "$snapshot" ]; then
|
|
|
|
|
echo "Pushing image $image_name:$latest_tag"
|
|
|
|
|
docker push "$image_name:$latest_tag"
|
2021-01-03 14:57:30 +00:00
|
|
|
echo "Pushing image $image_name:alpine"
|
|
|
|
|
docker push "$image_name:alpine"
|
2019-08-09 12:51:42 +00:00
|
|
|
fi
|
|
|
|
|
# we update the version tag, even if it's a SNAPSHOT version
|
|
|
|
|
echo "Pushing image $image_name:$image_tag"
|
|
|
|
|
docker push "$image_name:$image_tag"
|
2021-01-03 14:57:30 +00:00
|
|
|
if [[ $snapshot == "false" ]]; then
|
|
|
|
|
docker push "$image_name:$image_tag-alpine"
|
|
|
|
|
fi
|
2019-08-09 12:51:42 +00:00
|
|
|
else
|
|
|
|
|
echo "Not publishing Docker image"
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
exit 0;
|