Automatic Updater with GitHub API for WordPress Plugin
A composer library for self-hosted WordPress plugin on GitHub with automatic update.
$ composer require miya/gh-auto-updater
<?php
// Autoload
require_once( dirname( __FILE__ ) . '/vendor/autoload.php' );
add_action( 'init', 'activate_autoupdate' );
function activate_autoupdate() {
$plugin_slug = plugin_basename( __FILE__ ); // e.g. `hello/hello.php`.
$gh_user = 'miya0001'; // The user name of GitHub.
$gh_repo = 'gh-auto-updater-example'; // The repository name of your plugin.
// Activate automatic update.
new Miya\WP\GH_Auto_Updater( $plugin_slug, $gh_user, $gh_repo );
}
You can use personal access token.
define( 'GITHUB_ACCESS_TOKEN', 'xxxxxxxx' );
To release the new version, please do as follows:
$ git tag 1.1.0
$ git push origin 1.1.0
1.0.0
is a version number, it have to be same with version number in your WordPress plugin.vendor
directory in your plugin.Also, you can use automatic release.
Following is an example of the .travis.yml
for automatic release.
https://github.com/miya0001/miya-gallery/blob/master/.travis.yml
You can generate deploy:
section by The Travis Client like following.
$ travis setup releases
Please install old version of following projects, then you can see update notice.
These projects deploy new releases automatically with Travis CI.
$ travis setup releases
Please check .travis.yml
and documentation.
Notification on "Plugins" screen in WordPress dashboard.
"Details" screen in WordPress dashboard. You can see release note on GitHub as changelog.
"WordPress Updates" screen.
GPL v2