Commit 6a4aa088 authored by Tommy Meier's avatar Tommy Meier
Browse files

Update other deployment files

parent d38a6b31
Pipeline #2519 canceled with stages
PLUGIN_NAME="NetiNextToolKit"
#EXCLUDES=( "exclude dir" "exclude file" )
#PLUGINS_BUILD=( "npm-install" "npm-build" )
#PLUGINS_DIST=( "detect-license-check" )
#NPM_INSTALL=( "npm app dir" )
#NPM_BUILD=( "npm app dir" )
### 1. Why is this change necessary?
<!--
Here you can simply write if this change is a bug or a feature.
If the change is a feature please provide a small description of what is being improved.
If the change is a bug please provide a small description of what the actual bug is.
-->
### 2. What does this change do, exactly?
<!--
In this section you need to inform about the exact changes you have made in the plugin.
Examples:
- I have added a new plugin config
- I changed the behavior of a storefront javascript plugin, because of a functional change
- I have removed file X because of Y
-->
### 3. Describe each step to reproduce the issue or behavior.
<!--
The following description should be dummy-proof.
You need to inform the reviewer exactly how to test your changes.
Examples:
- You need to re-import the snippets
- You have to create several entities in the administration to get to the changed mask/behavior
Then the reviewer can use his own imagination to test edge cases, too.
-->
### 4. Please link to the relevant issues (if any).
<!--
In general, there will be a link to the Redmine ticket.
For every link, you have to write a single line.
-->
### 5. Checklist
<!--
This is the general checklist for this MR.
You should not assign the MR to a reviewer before checking all of these todos.
Sometimes a todo is not necessary for the current requirement, then you can ignore it.
As a reviewer, you must make sure the author did all of the todos correctly.
If you have additional todos, which are not in the default list, go ahead and add them to your MRs description.
-->
- [ ] I have updated the plugin version and changelog
- [ ] I have updated the manual / created a manual update merge request
- [ ] I have updated the shopware store information
- [ ] I can confirm the code style fits our requirements
- [ ] I can confirm that no debug output is generated anywhere
### 6. Release Notes
<!--
In case you want to inform the release master about important notes for releasing this MR, write it down here.
If you don't have any "release note" remove this section for better clarity.
-->
# 4.0.0
- [#38671] Erste Veröffentlichung
# 4.0.0
- [#38671] Initial release
#!/bin/bash
SCRIPT_VERSION='1.0.0'
CURRENT_DIR=$(pwd)
WORKING_DIR=$(cd $(dirname $0) && pwd)
BUILD_DIR="${WORKING_DIR}/.build"
PLUGIN_DIR="${BUILD_DIR}/plugins"
TEMP_DIR="${BUILD_DIR}/tmp"
UPDATE=1
PLUGIN_NAME=""
PLUGINS_BUILD=()
PLUGINS_DIST=()
TARGET_DIR=${CURRENT_DIR}
usage() {
echo "Usage: $0 [-h] [-n] [-t <string>]" 1>&2;
exit 1;
}
while getopts "hnt:" opt; do
case "${opt}" in
h)
usage
;;
n)
UPDATE=0
;;
t)
TARGET_DIR=${OPTARG}
;;
*)
usage
;;
esac
done
shift $((OPTIND-1))
if [[ "/" != "${TARGET_DIR:0:1}" ]]; then
TARGET_DIR="${WORKING_DIR}/${TARGET_DIR}"
fi
if [[ ! -d ${TARGET_DIR} ]]; then
echo "ERROR: Target dir doesn't exist"
exit 2
fi
if [[ ! -w ${TARGET_DIR} ]]; then
echo "ERROR: Can't write to target dir"
exit 2
fi
TARGET_DIR=$(cd "${TARGET_DIR}" && pwd)
cleanup() {
echo "INFO: Cleanup ${1}"
rm -Rf ${1}
}
selfUpdate() {
echo "INFO: Run self update process"
UPDATE_DIR="${BUILD_DIR}/update"
git clone --quiet ssh://git@gitlab.netinventors.de:2202/shopware6/build-script.git ${UPDATE_DIR}
cp -Rp ${UPDATE_DIR}/.build/plugins ${WORKING_DIR}/.build
cp -p ${UPDATE_DIR}/build.sh ${WORKING_DIR}
cleanup ${UPDATE_DIR}
}
runPlugins() {
if [[ -z ${@} ]]; then
return 0
fi
for PLUGIN in "${@}"; do
EXECUTABLE="${PLUGIN_DIR}/${PLUGIN}.sh"
if [[ -r "${EXECUTABLE}" ]]; then
echo "INFO: Run plugin ${PLUGIN}"
source "${EXECUTABLE}"
__FN="__$(sed -r 's/(\-)([a-z])/\U\2/g' <<< "${PLUGIN}")"
${__FN}
__RETURN=$?
if [[ 2 -eq ${__RETURN} ]]; then
echo "ERROR: A plugin stops the build process"
cleanup ${TEMP_DIR}
exit 2
fi
else
echo "WARNING: Plugin executable ${EXECUTABLE} not found"
fi
done
}
build() {
mkdir -p ${BUILD_DIR}
if [[ 1 -eq ${UPDATE} ]]; then
selfUpdate
bash -c "$0 -n -t \"${TARGET_DIR}\""
exit $?
fi
echo "INFO: Start build script version ${SCRIPT_VERSION}"
if [[ ! -r "${BUILD_DIR}/build.cfg" ]]; then
echo "ERROR: Unable to load build configuration file ${BUILD_DIR}/build.cfg"
exit 2
fi
# Load build configuration file
source "${BUILD_DIR}/build.cfg"
if [[ -z "${PLUGIN_NAME}" ]]; then
echo 'ERROR: Unable to resolve plugin name'
exit 2
fi
if [[ ! -r "${WORKING_DIR}/composer.json" ]]; then
echo "ERROR: Plugin describing file ${WORKING_DIR}/composer.json not found"
exit 2
fi
DIST_DIR="${BUILD_DIR}/tmp/${PLUGIN_NAME}"
VERSION=$(php -r "echo json_decode(file_get_contents('${WORKING_DIR}/composer.json'), true)['version'];")
EXCLUDES=( ".build" ".idea" "build.sh" ".git" ".gitignore" "${EXCLUDES[@]}" )
ZIP_FILE="${TARGET_DIR}/${PLUGIN_NAME}-${VERSION}.zip"
if [[ -z "$VERSION" ]]; then
echo 'ERROR: Unable to resolve plugin version from composer.json'
exit 2
fi
# Remove existing package file
if [[ -w "${ZIP_FILE}" ]]; then
rm "${ZIP_FILE}"
fi
if [[ -f "${ZIP_FILE}" ]]; then
echo "ERROR: Cannot override existing build file ${ZIP_FILE}"
exit 2
fi
RSYNC_EXCLUDES=( --exclude="${PLUGIN_NAME}-*.zip" )
cd ${WORKING_DIR}
runPlugins "${PLUGINS_BUILD[@]}"
for EXCLUDE in "${EXCLUDES[@]}"; do
RSYNC_EXCLUDES+=( --exclude="${EXCLUDE}" )
done
# Remove old temp dir
if [[ -d ${TEMP_DIR} ]]; then
rm -Rf ${TEMP_DIR}
fi
# Create temporary build folder
mkdir -p ${DIST_DIR}
# Copy all files from source folder to temporary folder
rsync -avzq "${RSYNC_EXCLUDES[@]}" . ${DIST_DIR}
# Step into the temporary build folder
cd ${DIST_DIR}
runPlugins "${PLUGINS_DIST[@]}"
if [ $(uname -s) == "Linux" ]; then
# Replace __SECRET__ in plugin bootstrap to detect manipulations
SECRET=$(head -c 1000 /dev/urandom | tr -dc 'A-Za-z0-9%,!_;:#@' | fold -w 32 | head -n 1)
sed -i "s/__SECRET__/${SECRET}/g" "src/${PLUGIN_NAME}.php"
# Create md5.json file including the md5 checksum of every file in the package and the plugin __SECRET__
echo "<?php return [" > md5checksum.php
for FILE in $(find -type f -printf '%P\n'); do
echo "'${FILE}' => '$(md5sum ${FILE} | awk '{ print $1 }')'," >> md5checksum.php
done;
echo "'__SECRET__' => '${SECRET}'," >> md5checksum.php
echo "];" >> md5checksum.php
fi
cd ${TEMP_DIR}
# Zip temporary folder contents to package file in plugin folder
zip -qr "${ZIP_FILE}" $(basename ${DIST_DIR})
echo "INFO: Created build package is located in ${ZIP_FILE}"
cleanup ${TEMP_DIR}
cd ${CURRENT_DIR}
}
build
# 4.0.0
- [#38720] Erste Veröffentlichung
\ No newline at end of file
# 4.0.0
- [#38720] Initial release
\ No newline at end of file
!!!include(../CHANGELOG_de-DE.md)!!!
!!!include(../changelog/de/4.0.0.md)!!!
!!!include(../CHANGELOG_en-GB.md)!!!
!!!include(../changelog/en/4.0.0.md)!!!
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment