Automatically generate new releases (#59)

* 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>
This commit is contained in:
Ben Goldsworthy 2021-03-12 17:53:49 +00:00 committed by GitHub
parent 5c9e611837
commit e8d6dbe13d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
12 changed files with 189 additions and 74 deletions

31
.distignore Normal file
View file

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

46
.github/workflows/release-handler.yml vendored Normal file
View file

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

1
.gitignore vendored
View file

@ -1,5 +1,6 @@
.phpdoc/ .phpdoc/
vendor/ vendor/
dist/
*.bak *.bak
authors.txt authors.txt

View file

@ -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 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`) - 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 ## Updating Documentation
1. Install [phpDocumentor](https://phpdoc.org/) 1. Install [phpDocumentor](https://phpdoc.org/)

82
_tools/build-stylesheets.sh Executable file
View file

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

9
_tools/build.sh Executable file
View file

@ -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/`.

0
_tools/setup.sh Normal file → Executable file
View file

View file

@ -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": { "require-dev": {
"dealerdirect/phpcodesniffer-composer-installer": "^0.7.1", "dealerdirect/phpcodesniffer-composer-installer": "^0.7.1",
"wp-coding-standards/wpcs": "^2.3" "wp-coding-standards/wpcs": "^2.3"
},
"scripts": {
"post-install-cmd": [
"bash _tools/setup.sh"
]
} }
} }

2
composer.lock generated
View file

@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically" "This file is @generated automatically"
], ],
"content-hash": "3a147d50695956de52f7cbf827b47830", "content-hash": "0d4821c9dd1b0f00e1204cc22488f77f",
"packages": [], "packages": [],
"packages-dev": [ "packages-dev": [
{ {

View file

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