Open eli-alvarado opened 3 months ago
As far as I know (and I could be wrong about this), GitHub has a single, global release list for the entire repository. Technically, there's nothing like "releases for branch client-name
". The API docs also don't seem to mention any way to filter releases by branch. So you can't really do what you're describing with GitHub releases.
(You might be able to filter by target_commitish
manually, but I suspect it's only set if you create a tag as part of creating a release, and you would potentially have to scan a lot of releases to find a match.)
However, if you set the branch to something other than master
or main
, PUC should ignore releases and only look at the specified branch for updates. Whenever the version number in the branch changes, that will be considered an update. This means you can use different branches for different clients, though you don't get the convenience of releases.
Alternatively, you could use a custom release filter and filter releases by a version suffix as you suggested. In this case, you'll need to create and combine some PUC objects manually instead of just calling buildUpdateChecker()
. Here's a basic example:
$api = new \YahnisElsts\PluginUpdateChecker\v5p4\Vcs\GitHubApi(
'https://github.com/user/repo'
);
$api->setReleaseFilter(
function($version, $releaseObject) {
return str_contains($version, '-client-name');
},
\YahnisElsts\PluginUpdateChecker\v5p4\Vcs\Api::RELEASE_FILTER_SKIP_PRERELEASE,
50 //Max number of releases to look at.
);
$updateChecker = new YahnisElsts\PluginUpdateChecker\v5p4\Vcs\PluginUpdateChecker(
$api,
__FILE__,
'plugin-slug'
);
I created a plugin that multiple clients of ours will be using, however there are cases when a client wants to customize the plugin. to account for this I am using the
master
branch for the default "global" plugin and then I wanted to create branches for each client that wanted a customized version of the plugin. this way, since most clients are using the "global" plugin, I can update the master branch and they will all receive the updates and if a client with the customized plugin wants a change, then it wouldn't effect the "global" plugin. however I found that when I create a new branch for the customized plugin, if I make updates and create a release then go to one of the sites that's using the "global" plugin, aka themaster
branch, it says there is an update available which is for the release I did for the customized plugin. I'm not exactly sure why the master branch is picking up what I'm doing in the other branches if it's completely separate.I tried adjusting the PHP header version to include a unique suffix. so the global plugin has
Version: 2.5.1
and the customized version hasVersion: 2.5.3-client-name
. Same thing with the release and the tag names, I followed the same naming convention to create separation but nothing seems to work.I also set the branch that contains the stable release accordingly. for master branch (global plugin) I have
$myUpdateChecker->setBranch('master');
for client-name branch (customized plugin) I have$myUpdateChecker->setBranch('client-name');
.Please let me know how I can achieve this. for now I am just going to create separate repositories for each client that wants customizations.