WordPress Plugin Dev – How to test your plugin upgrade process

How to use the alternative package url plugin: https://gitlab.com/nikelone/wp-plugin-alternative-package-url

result wordpress plugin update process testing plugin
Result after installation of plugin.

I am relatively new to wordpress plugin development. As I started adding plugins to the wordpress plugin repository, I wanted to test the upgrade process. I spent some time on recherche, found nothing suitable and moved on. This was not a problem, as my plugins were new and after installation or update there was no clean up to do.

This changed while the plugins evolved. So I spent more time in recherche, how to test the update process.

I found plugins were you can update directly from your git repo, like:

https://github.com/afragen/github-updater

or

https://github.com/krafit/wp-gitlab-updater

or

https://wppusher.com/ (free for one public repo)

These are all good solutions but were not that simple solution as I was looking for. So I developed this small helper plugin:

https://gitlab.com/nikelone/wp-plugin-alternative-package-url

This plugin is so simple, because you have to manage the deployment of the zip file from your repo by yourself. This gives you a greater flexibility and better loading times in your test wordpress installation. And with the great gitlab CI/CD feature it is fairly easy.

An example how you can deploy your plugin with every push to your repo as .gitlab-ci.yml file:

upload:
  image: ubuntu:18.04
  script:
    - apt-get update -qy
    - apt-get install -y lftp
    - apt-get install -y zip
    - mv src MY_PLUGIN
    - zip -r MY_PLUGIN.ZIP MY_PLUGIN
    - lftp -e "set ftp:ssl-allow false; put MY_PLUGIN.ZIP; exit;" -u $FTP_USERNAME,$FTP_PASSWORD $FTP_HOST
  only:
    - branches

You have to replace „src“ „MY_PLUGIN“ and „MY_PLUGIN.ZIP“ with the values for your plugin.

$FTP_USERNAME, $FTP_PASSWORD, $FTP_HOST are environment variables in gitlab. You can set them in your gitlab repository under Settings > CI/CD > Variables.

When the plugin is installed and you deploy your plugin code with every push to the desired location, you will see an update notification for your plugin. If you click update it will install the latest zip file.

You can do this forever as long you configured in Alternative Package Url Plugin a higher version, then the version you update to actual is.

Always thankful for feedback.

Happy testing!