Skip to content

Commit

Permalink
Make operator tag compliant with tags on other repositories (#417)
Browse files Browse the repository at this point in the history
* Make operator tag  compliant with tags on other repositories

Signed-off-by: Anatolii Bazko <abazko@redhat.com>
  • Loading branch information
tolusha committed Aug 28, 2020
1 parent 97f22ce commit 69b308a
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 17 deletions.
15 changes: 8 additions & 7 deletions make-release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ set -e
init() {
RELEASE="$1"
BRANCH=$(echo $RELEASE | sed 's/.$/x/')
RELEASE_BRANCH="${RELEASE}-release"
GIT_REMOTE_UPSTREAM="git@github.com:eclipse/che-operator.git"
RUN_RELEASE=false
PUSH_OLM_FILES=false
Expand Down Expand Up @@ -84,7 +85,7 @@ checkoutToReleaseBranch() {
resetChanges master
git push origin master:$BRANCH
fi
git checkout -B $RELEASE
git checkout -B $RELEASE_BRANCH
}

getPropertyValue() {
Expand Down Expand Up @@ -219,23 +220,23 @@ pushOlmFilesToQuayIo() {
}

pushGitChanges() {
echo "[INFO] Pushing git changes into $RELEASE branch"
git push origin $RELEASE
git tag -a v$RELEASE -m $RELEASE
echo "[INFO] Pushing git changes into $RELEASE_BRANCH branch"
git push origin $RELEASE_BRANCH
git tag -a $RELEASE -m $RELEASE
git push --tags origin
}

createPRToXBranch() {
echo "[INFO] Creating pull request into ${BRANCH} branch"
hub pull-request --base ${BRANCH} --head ${RELEASE} -m "Release version ${RELEASE}"
hub pull-request --base ${BRANCH} --head ${RELEASE_BRANCH} -m "Release version ${RELEASE}"
}

createPRToMasterBranch() {
echo "[INFO] Creating pull request into master branch to copy csv"
resetChanges master
local tmpBranch="update-images-to-master"
local tmpBranch="copy-csv-to-master"
git checkout -B $tmpBranch
git diff refs/heads/${BRANCH}...refs/heads/${RELEASE} ':(exclude)deploy/operator-local.yaml' ':(exclude)deploy/operator.yaml' | git apply -3
git diff refs/heads/${BRANCH}...refs/heads/${RELEASE_BRANCH} ':(exclude)deploy/operator-local.yaml' ':(exclude)deploy/operator.yaml' | git apply -3
. ${RELEASE_DIR}/replace-images-tags.sh nightly master
git add -A
git commit -m "Copy "$RELEASE" csv to master" --signoff
Expand Down
20 changes: 10 additions & 10 deletions replace-images-tags.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@
# - deploy/operator.yaml
# - deploy/operator-local.yaml
# Usage:
# ./release-operator-code.sh <RELEASE> <CHE_RELEASE_BRANCH>
# ./release-operator-code.sh <RELEASE_TAG> <CHE_RELEASE_BRANCH>

set -e

function init() {
BASE_DIR=$(cd "$(dirname "$0")"; pwd)
RELEASE="$1"
RELEASE_TAG="$1"
CHE_RELEASE_BRANCH="$2"
}

Expand Down Expand Up @@ -48,10 +48,10 @@ replaceImagesTags() {
PLUGIN_BROKER_METADATA_IMAGE_RELEASE=$(cat /tmp/che.properties| grep "che.workspace.plugin_broker.metadata.image" | cut -d = -f2)
PLUGIN_BROKER_ARTIFACTS_IMAGE_RELEASE=$(cat /tmp/che.properties | grep "che.workspace.plugin_broker.artifacts.image" | cut -d = -f2)
JWT_PROXY_IMAGE_RELEASE=$(cat /tmp/che.properties | grep "che.server.secure_exposer.jwtproxy.image" | cut -d = -f2)
CHE_SERVER_IMAGE_REALEASE=$(replaceImageTag "${lastDefaultCheServerImage}" "${RELEASE}")
KEYCLOAK_IMAGE_RELEASE=$(replaceImageTag "${lastDefaultKeycloakImage}" "${RELEASE}")
PLUGIN_REGISTRY_IMAGE_RELEASE=$(replaceImageTag "${lastDefaultPluginRegistryImage}" "${RELEASE}")
DEVFILE_REGISTRY_IMAGE_RELEASE=$(replaceImageTag "${lastDefaultDevfileRegistryImage}" "${RELEASE}")
CHE_SERVER_IMAGE_REALEASE=$(replaceImageTag "${lastDefaultCheServerImage}" "${RELEASE_TAG}")
KEYCLOAK_IMAGE_RELEASE=$(replaceImageTag "${lastDefaultKeycloakImage}" "${RELEASE_TAG}")
PLUGIN_REGISTRY_IMAGE_RELEASE=$(replaceImageTag "${lastDefaultPluginRegistryImage}" "${RELEASE_TAG}")
DEVFILE_REGISTRY_IMAGE_RELEASE=$(replaceImageTag "${lastDefaultDevfileRegistryImage}" "${RELEASE_TAG}")
rm /tmp/che.properties

NEW_OPERATOR_YAML="${OPERATOR_YAML}.new"
Expand All @@ -61,8 +61,8 @@ replaceImagesTags() {
eval head -10 "${OPERATOR_LOCAL_YAML}" > ${NEW_OPERATOR_LOCAL_YAML}

cat "${OPERATOR_YAML}" | \
yq -ryY "( .spec.template.spec.containers[] | select(.name == \"che-operator\") | .image ) = \"quay.io/eclipse/che-operator:${RELEASE}\"" | \
yq -ryY "( .spec.template.spec.containers[] | select(.name == \"che-operator\").env[] | select(.name == \"CHE_VERSION\") | .value ) = \"${RELEASE}\"" | \
yq -ryY "( .spec.template.spec.containers[] | select(.name == \"che-operator\") | .image ) = \"quay.io/eclipse/che-operator:${RELEASE_TAG}\"" | \
yq -ryY "( .spec.template.spec.containers[] | select(.name == \"che-operator\").env[] | select(.name == \"CHE_VERSION\") | .value ) = \"${RELEASE_TAG}\"" | \
yq -ryY "( .spec.template.spec.containers[] | select(.name == \"che-operator\").env[] | select(.name == \"RELATED_IMAGE_che_server\") | .value ) = \"${CHE_SERVER_IMAGE_REALEASE}\"" | \
yq -ryY "( .spec.template.spec.containers[] | select(.name == \"che-operator\").env[] | select(.name == \"RELATED_IMAGE_keycloak\") | .value ) = \"${KEYCLOAK_IMAGE_RELEASE}\"" | \
yq -ryY "( .spec.template.spec.containers[] | select(.name == \"che-operator\").env[] | select(.name == \"RELATED_IMAGE_plugin_registry\") | .value ) = \"${PLUGIN_REGISTRY_IMAGE_RELEASE}\"" | \
Expand All @@ -75,8 +75,8 @@ replaceImagesTags() {
mv "${NEW_OPERATOR_YAML}" "${OPERATOR_YAML}"

cat "${OPERATOR_LOCAL_YAML}" | \
yq -ryY "( .spec.template.spec.containers[] | select(.name == \"che-operator\") | .image ) = \"quay.io/eclipse/che-operator:${RELEASE}\"" | \
yq -ryY "( .spec.template.spec.containers[] | select(.name == \"che-operator\").env[] | select(.name == \"CHE_VERSION\") | .value ) = \"${RELEASE}\"" | \
yq -ryY "( .spec.template.spec.containers[] | select(.name == \"che-operator\") | .image ) = \"quay.io/eclipse/che-operator:${RELEASE_TAG}\"" | \
yq -ryY "( .spec.template.spec.containers[] | select(.name == \"che-operator\").env[] | select(.name == \"CHE_VERSION\") | .value ) = \"${RELEASE_TAG}\"" | \
yq -ryY "( .spec.template.spec.containers[] | select(.name == \"che-operator\").env[] | select(.name == \"RELATED_IMAGE_che_server\") | .value ) = \"${CHE_SERVER_IMAGE_REALEASE}\"" | \
yq -ryY "( .spec.template.spec.containers[] | select(.name == \"che-operator\").env[] | select(.name == \"RELATED_IMAGE_keycloak\") | .value ) = \"${KEYCLOAK_IMAGE_RELEASE}\"" | \
yq -ryY "( .spec.template.spec.containers[] | select(.name == \"che-operator\").env[] | select(.name == \"RELATED_IMAGE_plugin_registry\") | .value ) = \"${PLUGIN_REGISTRY_IMAGE_RELEASE}\"" | \
Expand Down

0 comments on commit 69b308a

Please sign in to comment.