mirror of https://github.com/pulumi/pulumi.git
55 lines
1.4 KiB
Bash
Executable File
55 lines
1.4 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 containers..."
|
|
for container in pulumi actions; do
|
|
echo "- pulumi/${container}"
|
|
docker build --build-arg PULUMI_VERSION="${CLI_VERSION}" \
|
|
-t "pulumi/${container}:${CLI_VERSION}" \
|
|
-t "pulumi/${container}:latest" \
|
|
"${SCRIPT_DIR}/../dist/docker"
|
|
done
|
|
|
|
echo "Running container runtime tests..."
|
|
RUN_CONTAINER_TESTS=true go test tests/containers/...
|
|
|
|
echo "Publishing containers..."
|
|
for container in pulumi actions; do
|
|
echo "- pulumi/${container}"
|
|
docker push "pulumi/${container}:${CLI_VERSION}"
|
|
docker push "pulumi/${container}:latest"
|
|
done
|
|
|
|
docker logout
|