Skip to content

Commit

Permalink
Merge pull request apache#9506: [BEAM-8105] Docker images release scr…
Browse files Browse the repository at this point in the history
…ipts
  • Loading branch information
markflyhigh committed Sep 11, 2019
2 parents cd7b025 + 7ddb127 commit da2fec3
Show file tree
Hide file tree
Showing 3 changed files with 121 additions and 1 deletion.
43 changes: 42 additions & 1 deletion release/src/main/scripts/build_release_candidate.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@
# 1. Build and stage java artifacts
# 2. Stage source release on dist.apache.org
# 3. Stage python binaries
# 4. Create a PR to update beam-site
# 4. Stage SDK docker images
# 5. Create a PR to update beam-site

set -e

Expand All @@ -44,6 +45,7 @@ PYTHON_ARTIFACTS_DIR=python
BEAM_ROOT_DIR=beam
WEBSITE_ROOT_DIR=beam-site

PYTHON_VER=("python2.7" "python3.5" "python3.6" "python3.7")

echo "================Setting Up Environment Variables==========="
echo "Which release version are you working on: "
Expand Down Expand Up @@ -198,6 +200,45 @@ if [[ $confirmation = "y" ]]; then
rm -rf ~/${PYTHON_ARTIFACTS_DIR}
fi

echo "[Current Step]: Stage SDK docker images"
echo "Do you want to proceed? [y|N]"
read confirmation
if [[ $confirmation = "y" ]]; then
echo "============Staging SDK docker images on docker hub========="
cd ~
if [[ -d ${LOCAL_PYTHON_STAGING_DIR} ]]; then
rm -rf ${LOCAL_PYTHON_STAGING_DIR}
fi
mkdir -p ${LOCAL_PYTHON_STAGING_DIR}
cd ${LOCAL_PYTHON_STAGING_DIR}

echo '-------------------Cloning Beam Release Branch-----------------'
git clone ${GIT_REPO_URL}
cd ${BEAM_ROOT_DIR}
git checkout ${RELEASE_BRANCH}

echo '-------------------Generating and Pushing Python images-----------------'
./gradlew :sdks:python:container:buildAll -Pdocker-tag=${RELEASE}_rc${RC_NUM}
for ver in "${PYTHON_VER[@]}"; do
docker push apachebeam/${ver}_sdk:${RELEASE}_rc${RC_NUM} &
done

echo '-------------------Generating and Pushing Java images-----------------'
./gradlew :sdks:java:container:dockerPush -Pdocker-tag=${RELEASE}_rc${RC_NUM}

echo '-------------------Generating and Pushing Go images-----------------'
./gradlew :sdks:go:container:dockerPush -Pdocker-tag=${RELEASE}_rc${RC_NUM}

rm -rf ~/${PYTHON_ARTIFACTS_DIR}

echo '-------------------Clean up images at local-----------------'
for ver in "${PYTHON_VER[@]}"; do
docker rmi -f apachebeam/${ver}_sdk:${RELEASE}_rc${RC_NUM}
done
docker rmi -f apachebeam/java_sdk:${RELEASE}_rc${RC_NUM}
docker rmi -f apachebeam/go_sdk:${RELEASE}_rc${RC_NUM}
fi

echo "[Current Step]: Update beam-site"
echo "Do you want to proceed? [y|N]"
read confirmation
Expand Down
77 changes: 77 additions & 0 deletions release/src/main/scripts/publish_docker_images.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
#!/bin/bash
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

# This script will generate and publish docker images for each language version to Docker Hub:
# 1. Generate images tagged with :{RELEASE}
# 2. Publish images tagged with :{RELEASE}
# 3. Tag images with :latest tag and publish.
# 4. Clearn up images.

set -e

source release/src/main/scripts/build_release_candidate.sh

echo "Publish SDK docker images to Docker Hub."
echo "Do you want to proceed? [y|N]"
read confirmation
if [[ $confirmation = "y" ]]; then
echo "============Publishing SDK docker images on docker hub========="
cd ~
if [[ -d ${LOCAL_PYTHON_STAGING_DIR} ]]; then
rm -rf ${LOCAL_PYTHON_STAGING_DIR}
fi
mkdir -p ${LOCAL_PYTHON_STAGING_DIR}
cd ${LOCAL_PYTHON_STAGING_DIR}

echo '-------------------Cloning Beam Release Branch-----------------'
git clone ${GIT_REPO_URL}
cd ${BEAM_ROOT_DIR}
git checkout ${RELEASE_BRANCH}

echo '-------------------Generating and Pushing Python images-----------------'
./gradlew :sdks:python:container:buildAll -Pdocker-tag=${RELEASE}
for ver in "${PYTHON_VER[@]}"; do
docker push apachebeam/${ver}_sdk:${RELEASE}
docker tag apachebeam/${ver}_sdk:${RELEASE} apachebeam/${ver}_sdk:latest
docker push apachebeam/${ver}_sdk:latest
done

echo '-------------------Generating and Pushing Java images-----------------'
./gradlew :sdks:java:container:dockerPush -Pdocker-tag=${RELEASE}
docker tag apachebeam/java_sdk:${RELEASE} apachebeam/java_sdk:latest
docker push apachebeam/java_sdk:latest

echo '-------------------Generating and Pushing Go images-----------------'
./gradlew :sdks:go:container:dockerPush -Pdocker-tag=${RELEASE}
docker tag apachebeam/go_sdk:${RELEASE} apachebeam/go_sdk:latest
docker push apachebeam/go_sdk:latest

rm -rf ~/${PYTHON_ARTIFACTS_DIR}

echo "-------------------Clean up SDK docker images at local-------------------"
for ver in "${PYTHON_VER[@]}"; do
docker rmi -f apachebeam/${ver}_sdk:${RELEASE}
docker rmi -f apachebeam/${ver}_sdk:latest
done

docker rmi -f apachebeam/java_sdk:${RELEASE}
docker rmi -f apachebeam/java_sdk:latest

docker rmi -f apachebeam/go_sdk:${RELEASE}
docker rmi -f apachebeam/go_sdk:latest
fi
2 changes: 2 additions & 0 deletions release/src/main/scripts/set_version.sh
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ if [[ -z "$IS_SNAPSHOT_VERSION" ]] ; then
sed -i -e "s/version=.*/version=$TARGET_VERSION/" gradle.properties
sed -i -e "s/project.version = .*/project.version = '$TARGET_VERSION'/" buildSrc/src/main/groovy/org/apache/beam/gradle/BeamModulePlugin.groovy
sed -i -e "s/^__version__ = .*/__version__ = '${TARGET_VERSION}'/" sdks/python/apache_beam/version.py
sed -i -e "s/python_sdk_version=.*/python_sdk_version=$TARGET_VERSION/" gradle.properties
# TODO: [BEAM-4767]
sed -i -e "s/'dataflow.container_version' : .*/'dataflow.container_version' : 'beam-${RELEASE}'/" runners/google-cloud-dataflow-java/build.gradle
else
Expand All @@ -78,6 +79,7 @@ else
sed -i -e "s/version=.*/version=$TARGET_VERSION-SNAPSHOT/" gradle.properties
sed -i -e "s/project.version = .*/project.version = '$TARGET_VERSION'/" buildSrc/src/main/groovy/org/apache/beam/gradle/BeamModulePlugin.groovy
sed -i -e "s/^__version__ = .*/__version__ = '${TARGET_VERSION}.dev'/" sdks/python/apache_beam/version.py
sed -i -e "s/python_sdk_version=.*/python_sdk_version=$TARGET_VERSION.dev/" gradle.properties
sed -i -e "s/'dataflow.container_version' : .*/'dataflow.container_version' : 'beam-master-.*'/" runners/google-cloud-dataflow-java/build.gradle
fi

0 comments on commit da2fec3

Please sign in to comment.