ci: improve build commands

This commit is contained in:
Ben Goldsworthy 2021-04-26 11:46:42 +01:00
parent 0d1e0d75bb
commit c18a66ae95
2 changed files with 39 additions and 29 deletions

View file

@ -14,31 +14,31 @@ echo "Running $(dirname "$0")/build-stylesheets.sh"
if [[ $1 == "-c" ]]; then
echo "Concatenating files and placing in \`tmp/css/\`..."
echo "Concatenating files and placing in \`dist/css/\`..."
mkdir -p ./tmp/css
cat ./src/css/dev-common.css > ./tmp/css/footnotes-nottbrpl0.css
mkdir -p ./dist/css
cat ./src/css/dev-common.css > ./dist/css/footnotes-nottbrpl0.css
cat ./src/css/dev-{common,layout-reference-container}.css > ./tmp/css/footnotes-nottbrpl1.css
cat ./src/css/dev-{common,layout-entry-content}.css > ./tmp/css/footnotes-nottbrpl2.css
cat ./src/css/dev-{common,layout-main-content}.css > ./tmp/css/footnotes-nottbrpl3.css
cat ./src/css/dev-{common,layout-reference-container}.css > ./dist/css/footnotes-nottbrpl1.css
cat ./src/css/dev-{common,layout-entry-content}.css > ./dist/css/footnotes-nottbrpl2.css
cat ./src/css/dev-{common,layout-main-content}.css > ./dist/css/footnotes-nottbrpl3.css
cat ./src/css/dev-{common,tooltips}.css > ./tmp/css/footnotes-jqttbrpl0.css
cat ./src/css/dev-{common,tooltips,layout-reference-container}.css > ./tmp/css/footnotes-jqttbrpl1.css
cat ./src/css/dev-{common,tooltips,layout-entry-content}.css > ./tmp/css/footnotes-jqttbrpl2.css
cat ./src/css/dev-{common,tooltips,layout-main-content}.css > ./tmp/css/footnotes-jqttbrpl3.css
cat ./src/css/dev-{common,tooltips}.css > ./dist/css/footnotes-jqttbrpl0.css
cat ./src/css/dev-{common,tooltips,layout-reference-container}.css > ./dist/css/footnotes-jqttbrpl1.css
cat ./src/css/dev-{common,tooltips,layout-entry-content}.css > ./dist/css/footnotes-jqttbrpl2.css
cat ./src/css/dev-{common,tooltips,layout-main-content}.css > ./dist/css/footnotes-jqttbrpl3.css
cat ./src/css/dev-{common,tooltips,tooltips-alternative}.css > ./tmp/css/footnotes-alttbrpl0.css
cat ./src/css/dev-{common,tooltips,tooltips-alternative,layout-reference-container}.css > ./tmp/css/footnotes-alttbrpl1.css
cat ./src/css/dev-{common,tooltips,tooltips-alternative,layout-entry-content}.css > ./tmp/css/footnotes-alttbrpl2.css
cat ./src/css/dev-{common,tooltips,tooltips-alternative,layout-main-content}.css > ./tmp/css/footnotes-alttbrpl3.css
cat ./src/css/dev-{common,tooltips,tooltips-alternative}.css > ./dist/css/footnotes-alttbrpl0.css
cat ./src/css/dev-{common,tooltips,tooltips-alternative,layout-reference-container}.css > ./dist/css/footnotes-alttbrpl1.css
cat ./src/css/dev-{common,tooltips,tooltips-alternative,layout-entry-content}.css > ./dist/css/footnotes-alttbrpl2.css
cat ./src/css/dev-{common,tooltips,tooltips-alternative,layout-main-content}.css > ./dist/css/footnotes-alttbrpl3.css
cat ./src/css/dev-{common,tooltips,amp-tooltips}.css > ./tmp/css/footnotes-amptbrpl0.css
cat ./src/css/dev-{common,tooltips,amp-tooltips,layout-reference-container}.css > ./tmp/css/footnotes-amptbrpl1.css
cat ./src/css/dev-{common,tooltips,amp-tooltips,layout-entry-content}.css > ./tmp/css/footnotes-amptbrpl2.css
cat ./src/css/dev-{common,tooltips,amp-tooltips,layout-main-content}.css > ./tmp/css/footnotes-amptbrpl3.css
cat ./src/css/dev-{common,tooltips,amp-tooltips}.css > ./dist/css/footnotes-amptbrpl0.css
cat ./src/css/dev-{common,tooltips,amp-tooltips,layout-reference-container}.css > ./dist/css/footnotes-amptbrpl1.css
cat ./src/css/dev-{common,tooltips,amp-tooltips,layout-entry-content}.css > ./dist/css/footnotes-amptbrpl2.css
cat ./src/css/dev-{common,tooltips,amp-tooltips,layout-main-content}.css > ./dist/css/footnotes-amptbrpl3.css
cat ./src/css/settings.css > ./tmp/css/settings.css
cat ./src/css/settings.css > ./dist/css/settings.css
echo "Stylesheet concatenation complete."
exit 0

View file

@ -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