YahnisElsts / plugin-update-checker

A custom update checker for WordPress plugins. Useful if you don't want to host your project in the official WP repository, but would still like it to support automatic updates. Despite the name, it also works with themes.
MIT License
2.22k stars 403 forks source link

git release and version in filename #509

Closed liedekef closed 1 year ago

liedekef commented 1 year ago

When using git releases, it creates a zip file plugin-X.Y.Z.zip with content plugin-X.Y.2 (X.Y.Z being the version). Now in wordpress, you have the plugins without versioning. Can this be achieved too? Reason is to find a way to replace a (now closed) plugin that was on wordpress with github releases without causing loss of data for the user. I could of course create a one-time zip for existing wp users to use ...

YahnisElsts commented 1 year ago

If the update checker is working and configured correctly, it should automatically rename the plugin directory from "plugin-X.Y.Z" to just "plugin" when installing the update. More precisely, it will rename the directory to match the directory name of the already installed version. So if the plugin is installed in /wp-content/plugins/abc, it will rename "plugin-X.Y.Z" to "abc".

This feature was added exactly for situations like this where people don't have direct control over the file/directory names generated by GitHub or similar tools.

liedekef commented 1 year ago

But what for a new installation? I tried installing the zip from GitHub and it created a directory plugin-1.1.1 When then updating on GitHub (new release), the new release was installed also in pkugin-1.1.1 (even though the version was changed). It seems the plugin keeps the name of the directory where installed, but for new installations that is with a version attached to the name ...

Franky

YahnisElsts commented 1 year ago

Right, that update checker feature doesn't affect new installations. It can't work for new installations because the plugin - and, by extension, the plugin update checker - isn't actually running while someone is installing it.

If you want to change the directory name for new installations, that's outside the scope of this library. It can't really do that, not even theoretically.

liedekef commented 1 year ago

Well, it could be done if somehow we could influence the GitHub created release zip file :-) So it seems I'm looking for guidance there ... And I realize that might be beyond your support, so it's ok if you can not give me a hint 😉

YahnisElsts commented 1 year ago

As far as I know, GitHub doesn't provide the option to change the file name(s) of the automatically generated ZIP files. Maybe there's a way to do it if you create releases using GitHub Actions - you could probably add a custom release asset, at least - but I'm not really familiar with that topic (that is, I haven't used GitHub Actions at all).

liedekef commented 1 year ago

Ok, I think I have a workaround by using release assets and $myUpdateChecker->getVcsApi()->enableReleaseAssets(); Although it requires me to download the source zip, unzip, rename, zip and upload to github again. But all that can be achieved with a script using "gh". While today is not the moment to test this, I'll test it next week for sure! Keep you posted (and happy Xmas)!

liedekef commented 1 year ago

Ok, it works fine as said: