A Bash Script to Automate the Publishing of Plugin Updates
Developed on macOS, the bash script described in this post is born from the need to automate some of the tasks a plugin developer has to routinely do to publish plugin updates on WordPress.org.
Developed on macOS, the bash script you are going to read about is born from the need to automate some of the tasks a plugin developer has to routinely do to publish plugin updates on WordPress.org.
What it Does
In chronological order, the following are all the tasks the script goes through:
- Checks whether or not the 'Stable tag' value in the
readme.txt
file matches the 'Version' value found in theplugin-name.php
file — in case they don't, it will ask you if the value in thereadme.txt
file must be updated. - Verifies that the current version of the plugin hasn't already been tagged, and so, published.
- If the plugin contains CSS or JavaScript files and you have uglifycss and uglifyjs installed on your Mac, it adds the compressed version of these files to the folder containing the original versions — the compressed version will have a
-min
suffix in the filename. - Synchronises the 'trunk' folder of the Working Copy with the plugin's folder, by leaving out the
.DS_Store
files and the.git
folder that there might be inside. - If needed, runs
svn add
andsvn delete
on the paths of the files respectively added to or deleted from the 'trunk' folder. - Makes a SVN copy of the 'trunk' folder to the
tags/current_version
subdirectory of the Working Copy. - And finally publishes the update on WordPress.org by committing the changes made to the Working Copy of the SVN repository.
The whole execution flows like a brook. The only times the script asks for your input, or stops altogether, it's when a check fails.
Publishing a Plugin Update
Before you can use the script, the config.json
file bundled with it needs to be filled in. Then, you can publish your next plugin update like so:
1$ path-to/publish-plugin-update.sh plugin-folder-name
The script can also be launched bare-bones, the parameter is optional.
If for some reason the script you download from GitHub isn't executable, you can make it so by running the following command:
1chmod +x path-to/publish-plugin-update.sh