Skip to content

Commit

Permalink
Address suggestions from PR discussion
Browse files Browse the repository at this point in the history
  • Loading branch information
cimbalek committed May 23, 2024
1 parent ef3bd22 commit 193099a
Showing 1 changed file with 17 additions and 68 deletions.
85 changes: 17 additions & 68 deletions .ci/jenkins/scripts/bash/zip-sources-all.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,34 +22,32 @@

#VERSION="10.0.0"
#BRANCH_DEFAULT="main"
# Configuration in format "repository-id;repository_name;branch(if-override-needed)"
# - eg.not all repositories have main branch
#REPOS="drools-repo;incubator-kie-drools
#kogito-runtimes-repo;incubator-kie-kogito-runtimes
#kogito-apps-repo;incubator-kie-kogito-apps
#kogito-images-repo;incubator-kie-kogito-images
#optaplanner-repo;incubator-kie-optaplanner
#kogito-serverless-operator-repo;incubator-kie-kogito-serverless-operator
#optaplanner-quickstarts-repo;incubator-kie-optaplanner-quickstarts;development
#kogito-examples-repo;incubator-kie-kogito-examples
#kie-tools-repo;incubator-kie-tools
#kie-sandbox-quarkus-accelerator-repo;incubator-kie-sandbox-quarkus-accelerator
#kogito-online-repo;incubator-kie-kogito-online"
#REPO_ORGANIZATION="apache"
#
## Configuration in format "repository_name;branch(if-override-needed)"
## - eg.not all repositories have main branch
#REPOSITORIES="incubator-kie-drools
#incubator-kie-kogito-runtimes
#incubator-kie-kogito-apps
#incubator-kie-kogito-images
#incubator-kie-optaplanner
#incubator-kie-tools
#incubator-kie-sandbox-quarkus-accelerator"

function zip_sources() {
SOURCES_DIRECTORY_NAME="sources"
REPO_ORGANIZATION="apache"

while read line; do
BRANCH=${BRANCH_DEFAULT}
#get rid of carriage return character if present
line="$(echo $line | sed 's#\r##g')"

#Clone
echo "Clone $( echo $line | awk -F';' '{ print $1 }' | sed 's\-repo\\g' )"
REPO_NAME=$( echo $line | awk -F';' '{print $2 }' )
echo "Clone $( echo $line | awk -F';' '{ print $1 }' | sed 's\incubator-\\g' )"
REPO_NAME=$( echo $line | awk -F';' '{print $1 }' )
REPO_DIRECTORY=${SOURCES_DIRECTORY_NAME}/${REPO_NAME}
REPO_BRANCH=$( echo $line | awk -F';' '{print $3}' )
#Leaving branch specifying functionality here in case we need to specify branch for any repo in the future
REPO_BRANCH=$( echo $line | awk -F';' '{print $2}' )
if [[ ! -z ${REPO_BRANCH} ]]; then
BRANCH=$REPO_BRANCH
fi
Expand All @@ -75,68 +73,19 @@ function zip_sources() {
ls -lha
popd

#Creating ZIP
pushd ${SOURCES_DIRECTORY_NAME}
ZIP_FILE_NAME="${REPO_NAME}-sources-${VERSION}.zip"
echo "Creating ${ZIP_FILE_NAME}"
zip -ry ${ZIP_FILE_NAME} ${REPO_NAME} # eventually we can avoid having also parent folder zipped, this way
if [[ ! -f ${ZIP_FILE_NAME} ]]; then
echo "${ZIP_FILE_NAME} has not been created."
exit 2
fi
ls -lha ${ZIP_FILE_NAME}
popd
rm -rf ${REPO_DIRECTORY}

done <<< $REPOSITORIES
}

function zip_container_sources() {
SOURCES_DIRECTORY_NAME="container-sources"
REPO_ORGANIZATION="apache"
REPO_KOGITO_TOOLS="incubator-kie-tools"
BRANCH="main"

#Clone
echo "Clone ${REPO_KOGITO_TOOLS}"
REPO_DIRECTORY=${SOURCES_DIRECTORY_NAME}/${REPO_KOGITO_TOOLS}
git clone --branch ${BRANCH} --depth 1 "https://github.com/${REPO_ORGANIZATION}/${REPO_KOGITO_TOOLS}.git" ${REPO_DIRECTORY}
STATE=$?
if [[ ${STATE} != 0 ]]; then
echo "Clonning of ${REPO_KOGITO_TOOLS} was NOT successfull. Failing"
exit 1
fi

#Remove unnecessary dirs
pushd ${REPO_DIRECTORY}/packages
CURRENT_DIRECTORY=$(pwd)
echo "Current directory is ${CURRENT_DIRECTORY}"
echo "Before cleanup"
ls -lha
echo "Removing directories other than container sources"
for filename in $PWD/*; do
[[ $filename != *image ]] || continue
rm -rf $filename
done
echo "After cleanup"
ls -lha
popd


#Creating ZIP
pushd ${SOURCES_DIRECTORY_NAME}
ZIP_FILE_NAME="container-sources-${VERSION}.zip"
ZIP_FILE_NAME="incubator-kie-${VERSION}-sources.zip"
echo "Creating ${ZIP_FILE_NAME}"
( cd ${REPO_KOGITO_TOOLS}/packages/ && zip -ry ../../${ZIP_FILE_NAME} * )
zip -ry ${ZIP_FILE_NAME} *
if [[ ! -f ${ZIP_FILE_NAME} ]]; then
echo "${ZIP_FILE_NAME} has not been created."
exit 2
fi
ls -lha ${ZIP_FILE_NAME}
popd
rm -rf ${REPO_DIRECTORY}

}

zip_sources
zip_container_sources

0 comments on commit 193099a

Please sign in to comment.