Skip to content
This repository has been archived by the owner on Aug 16, 2024. It is now read-only.

Commit

Permalink
Merge pull request #21 from PizzaFactory/prp-update-to-the-upstream
Browse files Browse the repository at this point in the history
Update to the upstream
  • Loading branch information
monaka authored Feb 1, 2020
2 parents 263ffbf + 706b7a1 commit c940b9d
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 31 deletions.
61 changes: 39 additions & 22 deletions RELEASE.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ done
usage ()
{
echo "Usage: $0 --repo [GIT REPO TO EDIT] --version [VERSION TO RELEASE] [--trigger-release]"
echo "Example: $0 --repo [email protected]:eclipse/che-devfile-registry --version 7.7.0 --trigger-release"; echo
echo "Example: $0 --repo [email protected]:eclipse/che-subproject --version 7.7.0 --trigger-release"; echo
}

if [[ ! ${VERSION} ]] || [[ ! ${REPO} ]]; then
Expand All @@ -28,21 +28,30 @@ fi
# derive branch from version
BRANCH=${VERSION%.*}.x

# if doing a .0 release, use master; if doing a .z release, use $BRANCH
if [[ ${VERSION} == *".0" ]]; then
BASEBRANCH="master"
else
BASEBRANCH="${BRANCH}"
fi

# work in tmp dir
TMP=$(mktemp -d); pushd "$TMP" > /dev/null || exit 1

# get sources from master branch
# get sources from ${BASEBRANCH} branch
echo "Check out ${REPO} to ${TMP}/${REPO##*/}"
git clone "${REPO}" -q
cd "${REPO##*/}" || exit 1
git fetch origin master:master
git checkout master
git fetch origin "${BASEBRANCH}":"${BASEBRANCH}"
git checkout "${BASEBRANCH}"

# create new branch off master (or check out latest commits if branch already exists), then push to origin
git branch "${BRANCH}" || git checkout "${BRANCH}" && git pull origin "${BRANCH}"
git push origin "${BRANCH}"
git fetch origin "${BRANCH}:${BRANCH}"
git checkout "${BRANCH}"
# create new branch off ${BASEBRANCH} (or check out latest commits if branch already exists), then push to origin
if [[ "${BASEBRANCH}" != "${BRANCH}" ]]; then
git branch "${BRANCH}" || git checkout "${BRANCH}" && git pull origin "${BRANCH}"
git push origin "${BRANCH}"
git fetch origin "${BRANCH}:${BRANCH}"
git checkout "${BRANCH}"
fi

# change VERSION file + commit change into .x branch
echo "${VERSION}" > VERSION
Expand All @@ -63,22 +72,30 @@ if [[ $TRIGGER_RELEASE -eq 1 ]]; then
git push origin "${VERSION}"
fi

# now update master to the new snapshot version
git fetch origin master:master
git checkout master

# change VERSION file + commit change into master branch
[[ $BRANCH =~ ^([0-9]+)\.([0-9]+).x ]] && BASE=${BASH_REMATCH[1]}; NEXT=${BASH_REMATCH[2]}; (( NEXT=NEXT+1 )) # for BRANCH=7.10.x, get BASE=7, NEXT=11
echo "${BASE}.${NEXT}.0-SNAPSHOT" > VERSION
BRANCH=master
COMMIT_MSG="[release] Bump to ${BASE}.${NEXT}.0-SNAPSHOT in ${BRANCH}"
# now update ${BASEBRANCH} to the new snapshot version
git fetch origin "${BASEBRANCH}":"${BASEBRANCH}"
git checkout "${BASEBRANCH}"

# change VERSION file + commit change into ${BASEBRANCH} branch
if [[ "${BASEBRANCH}" != "${BRANCH}" ]]; then
# bump the y digit
[[ $BRANCH =~ ^([0-9]+)\.([0-9]+)\.x ]] && BASE=${BASH_REMATCH[1]}; NEXT=${BASH_REMATCH[2]}; (( NEXT=NEXT+1 )) # for BRANCH=7.10.x, get BASE=7, NEXT=11
NEXTVERSION="${BASE}.${NEXT}.0-SNAPSHOT"
else
# bump the z digit
[[ $VERSION =~ ^([0-9]+)\.([0-9]+)\.([0-9]+) ]] && BASE="${BASH_REMATCH[1]}.${BASH_REMATCH[2]}"; NEXT="${BASH_REMATCH[3]}"; (( NEXT=NEXT+1 )) # for VERSION=7.7.1, get BASE=7.7, NEXT=2
NEXTVERSION="${BASE}.${NEXT}-SNAPSHOT"
fi
echo "${NEXTVERSION}" > VERSION
BRANCH=${BASEBRANCH}
COMMIT_MSG="[release] Bump to ${NEXTVERSION} in ${BRANCH}"
git commit -s -m "${COMMIT_MSG}" VERSION
git pull origin ${BRANCH}
git pull origin "${BRANCH}"

PUSH_TRY="$(git push origin ${BRANCH})"
PUSH_TRY="$(git push origin "${BRANCH}")"
# shellcheck disable=SC2181
if [[ $? -gt 0 ]] || [[ $PUSH_TRY == *"protected branch hook declined"* ]]; then
PR_BRANCH=pr-master-to-${BASE}.${NEXT}.0-SNAPSHOT
PR_BRANCH=pr-master-to-${NEXTVERSION}
# create pull request for master branch, as branch is restricted
git branch "${PR_BRANCH}"
git checkout "${PR_BRANCH}"
Expand All @@ -93,4 +110,4 @@ fi
# cleanup tmp dir
cd /tmp && rm -fr "$TMP"

popd > /dev/null
popd > /dev/null || exit
4 changes: 2 additions & 2 deletions arbitrary-users-patch/build_images.sh
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ while read -r line; do
base_image_name=$(echo "$line" | tr -s ' ' | cut -f 1 -d ' ')
base_image=$(echo "$line" | tr -s ' ' | cut -f 2 -d ' ')
echo "Building ${NAME_FORMAT}/${base_image_name}:${TAG} based on $base_image ..."
docker build -t "${NAME_FORMAT}/${base_image_name}:${TAG}" --no-cache --build-arg FROM_IMAGE="$base_image" "${SCRIPT_DIR}"/
docker build -t "${NAME_FORMAT}/${base_image_name}:${TAG}" --no-cache --build-arg FROM_IMAGE="$base_image" "${SCRIPT_DIR}"/ | cat
if ${PUSH_IMAGES}; then
echo "Pushing ${NAME_FORMAT}/${base_image_name}:${TAG}" to remote registry
docker push "${NAME_FORMAT}/${base_image_name}:${TAG}"
docker push "${NAME_FORMAT}/${base_image_name}:${TAG}" | cat
fi
done < "${SCRIPT_DIR}"/base_images
4 changes: 2 additions & 2 deletions arbitrary-users-patch/happy-path/build_happy_path_image.sh
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ if [ "$1" == "--push" ]; then
fi

# Build image for happy-path tests with precashed mvn dependencies
docker build -t "${NAME_FORMAT}/happy-path:${TAG}" --no-cache --build-arg TAG="${TAG}" "${SCRIPT_DIR}"/
docker build -t "${NAME_FORMAT}/happy-path:${TAG}" --no-cache --build-arg TAG="${TAG}" "${SCRIPT_DIR}"/ | cat
if ${PUSH_IMAGES}; then
echo "Pushing ${NAME_FORMAT}/happy-path:${TAG}" to remote registry
docker push "${NAME_FORMAT}/happy-path:${TAG}"
docker push "${NAME_FORMAT}/happy-path:${TAG}" | cat
fi
10 changes: 5 additions & 5 deletions cico_functions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,9 @@ function install_deps() {
/usr/sbin/setenforce 0 || true

# Get all the deps in
yum install -y yum-utils device-mapper-persistent-data lvm2
yum install -d1 -y yum-utils device-mapper-persistent-data lvm2
yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
yum install -y docker-ce \
yum install -d1 -y docker-ce \
git

service docker start
Expand All @@ -64,7 +64,7 @@ function set_nightly_tag() {
function tag_push() {
local TARGET=$1
docker tag "${IMAGE}" "$TARGET"
docker push "$TARGET"
docker push "$TARGET" | cat
}

# Set appropriate environment variables and login to the docker registry
Expand Down Expand Up @@ -99,7 +99,7 @@ function setup_environment() {
# Build, tag, and push devfile registry, tagged with ${TAG} and ${GIT_COMMIT_TAG}
function build_and_push() {
# Let's build and push image to 'quay.io' using git commit hash as tag first
docker build -t ${IMAGE} -f ${DOCKERFILE_PATH} --target registry .
docker build -t ${IMAGE} -f ${DOCKERFILE_PATH} --target registry . | cat
tag_push "${REGISTRY}/${ORGANIZATION}/${IMAGE}:${GIT_COMMIT_TAG}"
echo "CICO: '${GIT_COMMIT_TAG}' version of images pushed to '${REGISTRY}/${ORGANIZATION}' organization"

Expand All @@ -117,7 +117,7 @@ function build_and_push_release() {
echo "CICO: building release '${TAG}' / '${GIT_COMMIT_TAG}' version of devfile registry"
docker build -t ${IMAGE} -f ${DOCKERFILE_PATH} . \
--build-arg PATCHED_IMAGES_TAG=${TAG} \
--target registry
--target registry | cat

echo "CICO: '${GIT_COMMIT_TAG}' version of devfile registry built"
tag_push "${REGISTRY}/${ORGANIZATION}/${IMAGE}:${GIT_COMMIT_TAG}"
Expand Down

0 comments on commit c940b9d

Please sign in to comment.