ci: improve build commands
This commit is contained in:
parent
0d1e0d75bb
commit
c18a66ae95
2 changed files with 39 additions and 29 deletions
|
@ -6,26 +6,36 @@ echo "Building Plugin..."
|
|||
echo "Copying directories..."
|
||||
rm -rf dist/
|
||||
mkdir dist
|
||||
cp -r -t dist src/{class,languages,templates,img}/
|
||||
echo "Copying files..."
|
||||
cp -t dist ./{SECURITY.md,CHANGELOG.md,wpml-config.xml} src/{license.txt,readme.txt,includes.php}
|
||||
echo "Setting production flag..."
|
||||
sed "s/'PRODUCTION_ENV', false/'PRODUCTION_ENV', true/g" src/footnotes.php > dist/footnotes.php
|
||||
echo "Production flag set."
|
||||
rsync -av --progress --exclude css src/* dist
|
||||
echo "Setting production flag environment flag..."
|
||||
sed -i "s/'PRODUCTION_ENV' , false/'PRODUCTION_ENV' , true/g" ./dist/footnotes.php
|
||||
echo "Production environment flag set."
|
||||
|
||||
echo "Setting pre-release version tags..."
|
||||
grep " \* Version:" dist/footnotes.php | grep -Po "\d+\.\d+(\.\d+)?d$"
|
||||
if [ $? != 0 ]; then echo "Development version tag (`d`) not set!"; exit 1; fi
|
||||
PLUGIN_DEV_VERSION="$(grep " \* Version:" dist/footnotes.php | grep -Po "\d+\.\d+(\.\d+)?d$")"
|
||||
PLUGIN_PRE_VERSION="${PLUGIN_DEV_VERSION/d/p}"
|
||||
find dist -type f -exec sed -i "s/$PLUGIN_DEV_VERSION/$PLUGIN_PRE_VERSION/g" {} +
|
||||
if [ $? != 0 ]; then echo "Pre-release tag (`p`) could not be set!"; exit 1; fi
|
||||
echo "Pre-release version tags set."
|
||||
|
||||
# TODO: once automatic minification is implemented, this should handle that.
|
||||
# For now, we shall have to assume that this command is being run on a repo. with
|
||||
# minimised stylesheet files already in `dist/css/`.
|
||||
echo "Building stylesheets..."
|
||||
./_tools/build-stylesheets.sh -c
|
||||
if [ $? != 0 ]; then echo "Concatenation failed!"; exit 1; fi
|
||||
echo "Stylesheet build complete."
|
||||
|
||||
echo "Minifying CSS and JS..."
|
||||
mkdir -p dist/{css,js}
|
||||
npm run minify
|
||||
if [ $? != 0 ]; then echo "Minification failed!"; exit 1; fi
|
||||
echo "Deleting unminified files from `dist/`..."
|
||||
rm -r dist/**/*[^.min].{js,css}
|
||||
echo "Minification complete."
|
||||
|
||||
if [[ $1 == "-v" ]]; then
|
||||
rm -rf ../VVV/www/wordpress-one/public_html/wp-content/plugins/footnotes
|
||||
mv dist footnotes && mv footnotes ../VVV/www/wordpress-one/public_html/wp-content/plugins
|
||||
fi
|
||||
|
||||
echo "Build complete."
|
||||
exit 0
|
||||
|
|
Reference in a new issue