From e8d6dbe13d81b5c9fbb0cfaa49cbce3907dfc43b Mon Sep 17 00:00:00 2001 From: Rumperuu Date: Fri, 12 Mar 2021 17:53:49 +0000 Subject: [PATCH] Automatically generate new releases (#59) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Adapt after the 2.5.9d1 accident. * Corrections to changelog. * Also added @‌revision and @‌timestamp PHPDOC tags @‌revision and @‌timestamp used for SVN refs. Full enumeration of added custom PHPDOC tags: @‌accountable, @‌bib, @‌biblio, @‌callback, @‌commit, @‌committer, @‌contributor, @‌courtesy, @‌date, @‌datetime, @‌lastmodified, @‌modified, @‌publisher, @‌reporter, @‌revision, @‌timestamp, @‌user.Some tags like @‌reporter and @‌contributor are more used than others. * Readme header upgrade. * Create deploy-to-wordpress.org.yml * Add distignore * Comment out `build` command, replace npm with composer * Remove placeholder comments * Add build commands * Fix typo * Fix version number bug * Make zip without top-level directory * Append tag name to plugin zip * Clean up a bit * Rename workflow config * Fix upload paths * Append tag name to artifact * Fix paths * Revert path fix * Try again * Add wplm-config.xml to buildfiles * Fix indentation * Rename development/csscat.sh to css/csscat.sh * Rename development/customized-documentation-schema.txt to customized-documentation-schema.txt * Rename development/customized-template-stack.txt to customized-template-stack.txt * Version number related fixes before pull request. * Move csscat script to tools dir * Rename csscat * Refactor script * Update customized-documentation-schema.txt * Replace empty lines in help output * Escape empty lines. * Delete 3 items from `.distignore` As mentioned, CONTRIBUTING.md and README.md should be included in distributions. - As an invitation to the Community. - As a tangible proof of goodwill after the 2.5.9d1 accident. Also SECURITY.md so Footnotes users see that we’re concerned, and can reach out without transiting via GitHub. * Include CONTRIBUTING.md README.md SECURITY.md * Update sync w/ 5.7 tested. * Update * Update composerfiles Co-authored-by: pewgeuges <73141620+pewgeuges@users.noreply.github.com> --- .distignore | 31 +++++++ .github/workflows/release-handler.yml | 46 +++++++++++ .gitignore | 1 + README.md | 12 +++ _tools/build-stylesheets.sh | 82 +++++++++++++++++++ _tools/build.sh | 9 ++ _tools/setup.sh | 0 composer.json | 12 +-- composer.lock | 2 +- ...txt => customized-documentation-schema.txt | 0 ...stack.txt => customized-template-stack.txt | 0 development/csscat.sh | 68 --------------- 12 files changed, 189 insertions(+), 74 deletions(-) create mode 100644 .distignore create mode 100644 .github/workflows/release-handler.yml create mode 100755 _tools/build-stylesheets.sh create mode 100755 _tools/build.sh mode change 100644 => 100755 _tools/setup.sh rename development/customized-documentation-schema.txt => customized-documentation-schema.txt (100%) rename development/customized-template-stack.txt => customized-template-stack.txt (100%) delete mode 100755 development/csscat.sh diff --git a/.distignore b/.distignore new file mode 100644 index 0000000..30128dd --- /dev/null +++ b/.distignore @@ -0,0 +1,31 @@ +# A set of files you probably don't want in your WordPress.org distribution +.distignore +.editorconfig +.git +.gitignore +.gitlab-ci.yml +.travis.yml +.DS_Store +Thumbs.db +behat.yml +bin +circle.yml +composer.json +composer.lock +Gruntfile.js +package.json +phpunit.xml +phpunit.xml.dist +multisite.xml +multisite.xml.dist +phpcs.ruleset.xml +LICENSE +wp-cli.local.yml +tests +vendor +node_modules +*.sql +*.tar.gz +*.zip +authors.txt +composer.* diff --git a/.github/workflows/release-handler.yml b/.github/workflows/release-handler.yml new file mode 100644 index 0000000..6ccd91d --- /dev/null +++ b/.github/workflows/release-handler.yml @@ -0,0 +1,46 @@ +name: Release Handler + +# Action runs when a new release is published. +on: + release: + types: [published] + +jobs: + release-new: + name: Issue new release + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v2 + + - name: Build Plugin + run: | + composer install --no-dev --optimize-autoloader + composer run build + + - name: Create release archive + uses: montudor/action-zip@v0.1.0 + with: + args: zip -X -r dist/footnotes-${{ github.event.release.tag_name }}.zip dist + + - name: Upload archive as artifact + uses: actions/upload-artifact@v2 + with: + name: footnotes-${{ github.event.release.tag_name }} + path: dist/footnotes-${{ github.event.release.tag_name }}.zip + + - name: Upload archive to release + uses: JasonEtco/upload-to-release@master + with: + args: dist/footnotes-${{ github.event.release.tag_name }}.zip application/zip + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + #- name: Deploy release to Wordpress.org + # uses: 10up/action-wordpress-plugin-deploy@stable + # with: + # generate-zip: true + # env: + # SVN_USERNAME: ${{ secrets.SVN_USERNAME }} + # SVN_PASSWORD: ${{ secrets.SVN_PASSWORD }} diff --git a/.gitignore b/.gitignore index de46eb3..494168f 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,6 @@ .phpdoc/ vendor/ +dist/ *.bak authors.txt diff --git a/README.md b/README.md index f55c285..e24b6ac 100644 --- a/README.md +++ b/README.md @@ -30,6 +30,18 @@ Featured on [wpmudev](http://premium.wpmudev.org/blog/12-surprisingly-useful-wor - You can run either across the entire project by adding the argument `--ignore=*/vendor/*` and targetting the file `./**/*.php` - You may have to enable double-wildcards in your console first (`shopt -s globstar`) +## Building + +1. Run `_tools/build-stylesheets.sh -c` to concatenate stylesheets +1. Manually minify the output files in `css/tmp/`, saving them as `.min.css` files + - The intention is to replace this with automated minification, meaning that + all of these steps can be rolled into a single `build` command. +1. Run `_tools/build-stylesheets.sh -d` to deploy the minified files to `dist/` + - **this will delete any existing `dist/` folder** +1. Run `composer run build` to move over the remaining files to `dist/` + - Currently, the files to include in a distribution are hard-coded in `_tools/build.sh` + - The intention is to replace this with a proper parsing of the `.distignore` file + ## Updating Documentation 1. Install [phpDocumentor](https://phpdoc.org/) diff --git a/_tools/build-stylesheets.sh b/_tools/build-stylesheets.sh new file mode 100755 index 0000000..146db4e --- /dev/null +++ b/_tools/build-stylesheets.sh @@ -0,0 +1,82 @@ +#!/bin/bash + +# Concatenates, minifies (TODO) and deploys stylesheets for distribution. +# +# 12 unified stylesheets are concatenated out of these files: +# - `dev-common.css` +# - `dev-tooltips.css` +# - `dev-tooltips-alternative.css` +# - `dev-layout-reference-container.css` +# - `dev-layout-entry-content.css` +# - `dev-layout-main-content.css` + +echo "Running $(dirname "$0")/build-stylesheets.sh" + +if [[ $1 == "-c" ]]; then + + echo "Concatenating files and placing in \`css/tmp/\`." + mkdir -p ./css/tmp + cat ./css/dev-common.css > ./css/tmp/footnotes-nottbrpl0.css + cat ./css/dev-{common,layout-reference-container}.css > ./css/tmp/footnotes-nottbrpl1.css + cat ./css/dev-{common,layout-entry-content}.css > ./css/tmp/footnotes-nottbrpl2.css + cat ./css/dev-{common,layout-main-content}.css > ./css/tmp/footnotes-nottbrpl3.css + cat ./css/dev-{common,tooltips}.css > ./css/tmp/footnotes-jqttbrpl0.css + cat ./css/dev-{common,tooltips,layout-reference-container}.css > ./css/tmp/footnotes-jqttbrpl1.css + cat ./css/dev-{common,tooltips,layout-entry-content}.css > ./css/tmp/footnotes-jqttbrpl2.css + cat ./css/dev-{common,tooltips,layout-main-content}.css > ./css/tmp/footnotes-jqttbrpl3.css + cat ./css/dev-{common,tooltips,tooltips-alternative}.css > ./css/tmp/footnotes-alttbrpl0.css + cat ./css/dev-{common,tooltips,tooltips-alternative,layout-reference-container}.css > ./css/tmp/footnotes-alttbrpl1.css + cat ./css/dev-{common,tooltips,tooltips-alternative,layout-entry-content}.css > ./css/tmp/footnotes-alttbrpl2.css + cat ./css/dev-{common,tooltips,tooltips-alternative,layout-main-content}.css > ./css/tmp/footnotes-alttbrpl3.css + cat ./css/settings.css > ./css/tmp/settings.css + echo "Done." + +elif [[ $1 == "-m" ]]; then + + # TODO: this should automatically minifiy all files, outputting into `.min.css` + # files and deleting the original concatenated `.css` files in `css/tmp/`. + # Once that's done, we can change the `rm -r` command in the deploy step to + # `rmdir`, which will throw us an error if we have any minified files that + # haven't been moved over to `dist/css/` for whatever reason. As it currently + # stands, we have no error checking in place. + echo "Minifying files (TODO)..." + mkdir -p ./dist/css + for f in ./css/tmp/*.css; do + filename=$(basename $f .css) + echo $filename + # TODO: automated minification + echo $filename Done + done + echo "Done." + +elif [[ $1 == "-d" ]]; then + + echo "Deploying minified files to \`dist/css/\`..." + rm -r ./dist + mkdir -p ./dist/css + for f in ./css/tmp/*.min.css; do + filename=$(basename $f .css) + echo Moving $filename + mv $f ./dist/css + echo $filename Moved + done + echo "Deleting temporary files..." + rm -r ./css/tmp + echo "Done." + +else + + echo -e "Concatenates, minifies (TODO) and deploys stylesheets for distribution.\n" + echo -e "12 unified style sheets are concatenated out of these files:\n" + echo "\`dev-common.css\`" + echo "\`dev-tooltips.css\`" + echo "\`dev-tooltips-alternative.css\`" + echo "\`dev-layout-reference-container.css\`" + echo "\`dev-layout-entry-content.css\`" + echo -e "\`dev-layout-main-content.css\`\n" + echo "Command: \`-c\`: Concatenate \`dev-*\` CSS files into temporary directory." + echo "Command: \`-m\`: Minify files (TODO)." + echo "Command: \`-d\`: Deploy minified files to \`dist/css/\` and remove temporary files." + echo "No command, \"--help\", or anything else: Output this help section." + +fi diff --git a/_tools/build.sh b/_tools/build.sh new file mode 100755 index 0000000..13a7def --- /dev/null +++ b/_tools/build.sh @@ -0,0 +1,9 @@ +#!/bin/sh + +# Moves everything except the stylesheets over to `dist/` + +cp -r -t dist class/ js/ img/ languages/ templates/ +cp -t dist features.txt license.txt readme.txt footnotes.php includes.php wpml-config.xml customized-documentation-schema.txt customized-template-stack.txt CONTRIBUTING.md README.md SECURITY.md +# 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/`. diff --git a/_tools/setup.sh b/_tools/setup.sh old mode 100644 new mode 100755 diff --git a/composer.json b/composer.json index 85ecd48..27eab43 100644 --- a/composer.json +++ b/composer.json @@ -1,11 +1,13 @@ { + "name": "markcheret/footnotes", + "description": "footnotes aims to be the all-in-one solution for displaying an automatically-generated list of references on your WordPress Page or Post.", + "license": "GPL-3.0-or-later", + "scripts": { + "build": "./_tools/build.sh", + "post-install-cmd": "./_tools/setup.sh" + }, "require-dev": { "dealerdirect/phpcodesniffer-composer-installer": "^0.7.1", "wp-coding-standards/wpcs": "^2.3" - }, - "scripts": { - "post-install-cmd": [ - "bash _tools/setup.sh" - ] } } diff --git a/composer.lock b/composer.lock index 9e0ee7c..ceae236 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "3a147d50695956de52f7cbf827b47830", + "content-hash": "0d4821c9dd1b0f00e1204cc22488f77f", "packages": [], "packages-dev": [ { diff --git a/development/customized-documentation-schema.txt b/customized-documentation-schema.txt similarity index 100% rename from development/customized-documentation-schema.txt rename to customized-documentation-schema.txt diff --git a/development/customized-template-stack.txt b/customized-template-stack.txt similarity index 100% rename from development/customized-template-stack.txt rename to customized-template-stack.txt diff --git a/development/csscat.sh b/development/csscat.sh deleted file mode 100755 index 1d5c453..0000000 --- a/development/csscat.sh +++ /dev/null @@ -1,68 +0,0 @@ -#!/bin/bash -# 2021-02-15T1839+0100 -# Last modified: 2021-02-16T0155+0100 -# csscat.sh -# Concatenates CSS files; deletes the concatenations after they’ve been minified. -# -# 12 unified style sheets are concatenated out of these files: -# dev-common.css -# dev-tooltips.css -# dev-tooltips-alternative.css -# dev-layout-reference-container.css -# dev-layout-entry-content.css -# dev-layout-main-content.css -# -echo "Running $(dirname "$0")/csscat.sh" -if [[ $1 == "c" ]]; then -echo "Concatenate in csscat/ for minification:" -cd ../css -mkdir csscat -cat dev-common.css > csscat/footnotes-nottbrpl0.css -cat dev-common.css dev-layout-reference-container.css > csscat/footnotes-nottbrpl1.css -cat dev-common.css dev-layout-entry-content.css > csscat/footnotes-nottbrpl2.css -cat dev-common.css dev-layout-main-content.css > csscat/footnotes-nottbrpl3.css -cat dev-common.css dev-tooltips.css > csscat/footnotes-jqttbrpl0.css -cat dev-common.css dev-tooltips.css dev-layout-reference-container.css > csscat/footnotes-jqttbrpl1.css -cat dev-common.css dev-tooltips.css dev-layout-entry-content.css > csscat/footnotes-jqttbrpl2.css -cat dev-common.css dev-tooltips.css dev-layout-main-content.css > csscat/footnotes-jqttbrpl3.css -cat dev-common.css dev-tooltips.css dev-tooltips-alternative.css > csscat/footnotes-alttbrpl0.css -cat dev-common.css dev-tooltips.css dev-tooltips-alternative.css dev-layout-reference-container.css > csscat/footnotes-alttbrpl1.css -cat dev-common.css dev-tooltips.css dev-tooltips-alternative.css dev-layout-entry-content.css > csscat/footnotes-alttbrpl2.css -cat dev-common.css dev-tooltips.css dev-tooltips-alternative.css dev-layout-main-content.css > csscat/footnotes-alttbrpl3.css -echo "Done." -elif [[ $1 == "d" ]]; then -echo "Move minified to css/ and delete concatenations and their temp dir:" -cd ../css/csscat -mv footnotes-nottbrpl0.min.css .. -mv footnotes-nottbrpl1.min.css .. -mv footnotes-nottbrpl2.min.css .. -mv footnotes-nottbrpl3.min.css .. -mv footnotes-jqttbrpl0.min.css .. -mv footnotes-jqttbrpl1.min.css .. -mv footnotes-jqttbrpl2.min.css .. -mv footnotes-jqttbrpl3.min.css .. -mv footnotes-alttbrpl0.min.css .. -mv footnotes-alttbrpl1.min.css .. -mv footnotes-alttbrpl2.min.css .. -mv footnotes-alttbrpl3.min.css .. -cd .. -rm -r csscat -echo "Done." -else -echo "Concatenates CSS files; deletes the concatenations after they’ve been minified." -echo "" -echo "12 unified style sheets are concatenated out of these files:" -echo "" -echo "dev-common.css" -echo "" -echo "dev-tooltips.css" -echo "dev-tooltips-alternative.css" -echo "" -echo "dev-layout-reference-container.css" -echo "dev-layout-entry-content.css" -echo "dev-layout-main-content.css" -echo "" -echo "Command: c: Concatenate temporary files waiting for minification." -echo "Command: d: Move the minified files to css/, delete the temporary." -echo "No command, \"--help\", or anything else: Output this help section." -fi