Luigi Cavalieri - Full-stack Developer

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.

A Bash Script to Automate the Publishing of Plugin Updates

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.

GitHub Repo

What it Does

In chronological order, the following are all the tasks the script goes through:

  1. Checks whether or not the 'Stable tag' value in the readme.txt file matches the 'Version' value found in the plugin-name.php file — in case they don't, it will ask you if the value in the readme.txt file must be updated.
  2. Verifies that the current version of the plugin hasn't already been tagged, and so, published.
  3. 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.
  4. 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.
  5. If needed, runs svn add and svn delete on the paths of the files respectively added to or deleted from the 'trunk' folder.
  6. Makes a SVN copy of the 'trunk' folder to the tags/current_version subdirectory of the Working Copy.
  7. 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