A Bash Script to Automate the Publishing of Plugin Updates

Post updated on No Comments

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.

Peruse it on GitHub

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.
  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 uglify-js installed on your Mac, it adds a compressed version of these files in the same folder as the original version. 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 might be present.
  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 is when a check fails. For example, it might ask you whether or not it should update the 'Stable tag' value for you, or if it must go on with the execution in case 'uglifycss' or 'uglifyjs' are not installed.

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:

$ path-to/publish-plugin-update.sh plugin-folder-name

The script can also be launched bare-bones however, 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:

chmod +x path-to/publish-plugin-update.sh