pulumi/scripts/build-and-publish-docker
Matt Ellis e20d72ff6e Only skip publishing docker images for -alpha builds.
Previously, we only published docker images for non-prerelease
builds. However, on our move to 1.0.0, we will be publishing a few
`-beta` (and perhaps one or more `-rc`) builds. These are high quality
builds we want folks to use. So, we will publish them to DockerHub and
update the `latest` tag, similar to what we do for NPM and PyPI.

I will manually publish 1.0.0-beta.2, but landing these changes means
that future releases will be published automatically

Fixes #3092
2019-08-16 11:02:42 -07:00

53 lines
1.5 KiB
Bash
Executable file

#!/bin/bash
# Usage build-and-publish-docker [cli-version]
set -o nounset
set -o errexit
set -o pipefail
readonly SCRIPT_DIR="$( cd "$( dirname "${0}" )" && pwd )"
if [ -z "${1:-}" ]; then
>&2 echo "error: missing version to publish"
exit 1
fi
if [ -z "${DOCKER_HUB_USER:-}" ]; then
>&2 echo "error: 'DOCKER_HUB_USER' should be defined"
exit 1
fi
if [ -z "${DOCKER_HUB_PASSWORD:-}" ]; then
>&2 echo "error: 'DOCKER_HUB_PASSWORD' should be defined"
exit 1
fi
CLI_VERSION="${1}"
# We only want to push docker images for stable versions of Pulumi. So if there is a -alpha
# pre-release tag, skip publishing.
if [[ "${CLI_VERSION}" == *-alpha* ]]; then
>&2 echo "Skipping docker publishing for ${CLI_VERSION} since it is a pre-release"
exit 0
fi
docker login -u "${DOCKER_HUB_USER}" -p "${DOCKER_HUB_PASSWORD}"
echo "Building and publishing pulumi/pulumi:${CLI_VERSION}"
docker build --build-arg PULUMI_VERSION="${CLI_VERSION}" \
-t "pulumi/pulumi:${CLI_VERSION}" \
-t "pulumi/pulumi:latest" \
"${SCRIPT_DIR}/../dist/docker"
docker push "pulumi/pulumi:${CLI_VERSION}"
docker push "pulumi/pulumi:latest"
# Pulumi container optimized for GitHub Actions.
echo "Building and publishing pulumi/actions:${CLI_VERSION}"
docker build --build-arg PULUMI_VERSION="${CLI_VERSION}" \
-t "pulumi/actions:${CLI_VERSION}" \
-t "pulumi/actions:latest" \
"${SCRIPT_DIR}/../dist/actions"
docker push "pulumi/actions:${CLI_VERSION}"
docker push "pulumi/actions:latest"
docker logout