Skip to content
This repository has been archived by the owner on Apr 4, 2023. It is now read-only.

Commit

Permalink
Make it possible to build Che Theia based on upstream Theia commit (#737
Browse files Browse the repository at this point in the history
)

* Make it possible to build Che Theia based on upstream Theia commit

Signed-off-by: Artem Zatsarynnyi <azatsary@redhat.com>
  • Loading branch information
azatsarynnyy authored May 6, 2020
1 parent 4b6341d commit 1879602
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 50 deletions.
4 changes: 0 additions & 4 deletions RELEASE.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,3 @@ Launch the [release script](make-release.sh) and wait until [CI Job](https://ci.
```
./make-release.sh --repo git@github.com:eclipse/che-theia --version <VERSION_TO_RELEASE> --trigger-release
```

**NOTE:** before doing a minor release (x.y.0), update [`THEIA_VERSION`](THEIA_VERSION) file with a required version of Eclipse Theia.

Go to [npm registry](https://www.npmjs.com/package/@theia/core) and pick the latest `next` Theia version, e.g. `0.15.0-next.15995cd0`
1 change: 0 additions & 1 deletion THEIA_VERSION

This file was deleted.

5 changes: 3 additions & 2 deletions build.include
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ set -u
IMAGE_TAG="next"
THEIA_VERSION="master"
THEIA_BRANCH="master"
THEIA_COMMIT_SHA=
THEIA_GIT_REFS="refs\\/heads\\/master"
THEIA_DOCKER_IMAGE_VERSION=

Expand Down Expand Up @@ -78,8 +79,8 @@ buildImages() {
GITHUB_TOKEN_ARG="GITHUB_TOKEN=${GITHUB_TOKEN:-}"
echo "Building image in ${image_dir}"
if [ "$image_dir" == "dockerfiles/theia" ]; then
bash $(pwd)/$image_dir/build.sh --build-args:${GITHUB_TOKEN_ARG},THEIA_VERSION=${THEIA_VERSION} --tag:${IMAGE_TAG} --branch:${THEIA_BRANCH} --git-ref:${THEIA_GIT_REFS} ${FILTERED_ARGS}
elif [ "$image_dir" == "dockerfiles/theia-dev" ]; then
bash $(pwd)/$image_dir/build.sh --build-args:${GITHUB_TOKEN_ARG},THEIA_VERSION=${THEIA_VERSION},THEIA_COMMIT_SHA=${THEIA_COMMIT_SHA} --tag:${IMAGE_TAG} --branch:${THEIA_BRANCH} --git-ref:${THEIA_GIT_REFS} ${FILTERED_ARGS}
elif [ "$image_dir" == "dockerfiles/theia-dev" ]; then
bash $(pwd)/$image_dir/build.sh --build-arg:${GITHUB_TOKEN_ARG} --tag:${IMAGE_TAG} ${FILTERED_ARGS}
else
bash $(pwd)/$image_dir/build.sh --build-arg:${GITHUB_TOKEN_ARG} --tag:${IMAGE_TAG} ${FILTERED_ARGS}
Expand Down
2 changes: 2 additions & 0 deletions dockerfiles/theia/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ ARG THEIA_GITHUB_REPO=eclipse-theia/theia
# Define upstream version of theia to use
ARG THEIA_VERSION=master

ARG THEIA_COMMIT_SHA=''

ENV NODE_OPTIONS="--max-old-space-size=4096"

#{IF:DO_REMOTE_CHECK}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
# Clone theia and keep source code in home
RUN git clone --branch ${GIT_BRANCH_NAME} --single-branch --depth 1 https://github.com/${THEIA_GITHUB_REPO} ${HOME}/theia-source-code
RUN git clone --branch ${GIT_BRANCH_NAME} --single-branch https://github.com/${THEIA_GITHUB_REPO} ${HOME}/theia-source-code && \
cd ${HOME}/theia-source-code && git checkout ${THEIA_COMMIT_SHA}
3 changes: 2 additions & 1 deletion dockerfiles/theia/docker/ubi8/builder-clone-theia.dockerfile
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
# Clone theia and keep source code in home
RUN git clone --branch ${GIT_BRANCH_NAME} --single-branch --depth 1 https://github.com/${THEIA_GITHUB_REPO} ${HOME}/theia-source-code
RUN git clone --branch ${GIT_BRANCH_NAME} --single-branch https://github.com/${THEIA_GITHUB_REPO} ${HOME}/theia-source-code && \
cd ${HOME}/theia-source-code && git checkout ${THEIA_COMMIT_SHA}
49 changes: 8 additions & 41 deletions make-release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -66,67 +66,34 @@ if [[ "${BASEBRANCH}" != "${BRANCH}" ]]; then
fi

apply_files_edits () {
read THEIA_VERSION < THEIA_VERSION
THEIA_VERSION=$(curl --silent http://registry.npmjs.org/-/package/@theia/core/dist-tags | sed 's/.*"next":"\(.*\)".*/\1/')
if [[ ! ${THEIA_VERSION} ]]; then
echo "THEIA_VERSION file is not found"; echo
echo "Failed to get Theia next version from npmjs.org"; echo
exit 1
fi

# Che Theia release may depend on Theia next or latest
if [[ ${THEIA_VERSION} == *"-next."* ]]; then
THEIA_PATCHES_DIR=master
THEIA_BRANCH=master
THEIA_GIT_REFS=refs\\\\\\\\/heads\\\\\\\\/master
else
THEIA_PATCHES_DIR=${THEIA_VERSION}
THEIA_BRANCH=v${THEIA_VERSION}
THEIA_GIT_REFS=refs\\\\\\\\/tags\\\\\\\\/v${THEIA_VERSION}
fi

# update config for Che Theia generator
sed -i che-theia-init-sources.yml -e "/checkoutTo:/s/master/${BRANCH}/"

# set the variables for an image build
# set the variables for building the images
sed -i build.include \
-e 's/IMAGE_TAG="..*"/IMAGE_TAG="latest"/' \
-e 's/THEIA_VERSION="..*"/THEIA_VERSION="'${THEIA_PATCHES_DIR}'"/' \
-e 's/THEIA_BRANCH="..*"/THEIA_BRANCH="'${THEIA_BRANCH}'"/' \
-e 's#THEIA_GIT_REFS="..*"#THEIA_GIT_REFS="'${THEIA_GIT_REFS}'"#' \
-e 's/^THEIA_COMMIT_SHA=$/THEIA_COMMIT_SHA="'${THEIA_VERSION##*.}'"/' \
-e 's/THEIA_DOCKER_IMAGE_VERSION=.*/THEIA_DOCKER_IMAGE_VERSION="'${VERSION}'"/'

# Update extensions/plugins package.json files:
# - set packages' version
# - update versions of Theia dependencies
# - update versions of Che dependencies
# - update versions of Theia and Che dependencies
for m in "extensions/*" "plugins/*"; do
sed -i ./${m}/package.json \
-r -e 's/("version": )(".*")/\1"'$VERSION'"/' \
-r -e '/plugin-packager/!s/("@theia\/..*": )(".*")/\1"'${THEIA_VERSION}'"/' \
-r -e '/@eclipse-che\/api|@eclipse-che\/workspace-client|@eclipse-che\/workspace-telemetry-client/!s/("@eclipse-che\/..*": )(".*")/\1"'$VERSION'"/'
done

if [[ ${THEIA_BRANCH} == master ]]; then
THEIA_COMMIT_SHA=${THEIA_VERSION##*.}

if [[ ${VERSION} == *".0" ]]; then
# if depending on Theia next (from master), need to checkout to the corresponding commit
for m in "dockerfiles/theia/docker/alpine/builder-clone-theia.dockerfile" "dockerfiles/theia/docker/ubi8/builder-clone-theia.dockerfile"; do
sed -i ./${m} \
-e 's/ --depth 1//' \
-e '/RUN git clone/s#$# \&\& cd ${HOME}/theia-source-code \&\& git checkout '${THEIA_COMMIT_SHA}'#'
done

sed -i dockerfiles/theia/docker/ubi8/builder-clone-theia.dockerfile \
-e '/RUN git clone/s#$# \&\& cd ${HOME} \&\& tar zcf ${HOME}/theia-source-code.tgz theia-source-code#'
else
# Doing a .z release. So, both (alpine/ubi8) builder-clone-theia.dockerfile are already patched.
# Just need to ensure that using a correct $THEIA_COMMIT_SHA
# as .z release may be based on a different Theia version comparing to a .0 release.
sed -i dockerfiles/theia/docker/alpine/builder-clone-theia.dockerfile \
-r -e 's/( git checkout )(.*)/\1'${THEIA_COMMIT_SHA}'/'
sed -i dockerfiles/theia/docker/ubi8/builder-clone-theia.dockerfile \
-r -e 's/( git checkout )(.*)( \&\& cd )/\1'${THEIA_COMMIT_SHA}'\3/'
fi
if [[ ${VERSION} == *".0" ]]; then
sed -i dockerfiles/theia/docker/ubi8/builder-clone-theia.dockerfile \
-e '$ a RUN cd ${HOME} \&\& tar zcf ${HOME}/theia-source-code.tgz theia-source-code'
fi
}

Expand Down

0 comments on commit 1879602

Please sign in to comment.