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

sources generated by gitlab are in sources, not in links #505

Closed jihaisse closed 1 year ago

jihaisse commented 1 year ago

Hello,

Sources links are stored into the sources, not links when build via the pipeline or when a tag is created.

Here is an export of the $release variable from the debugger :

(
    [name] => 0.3.1
    [tag_name] => 0.3.1
    [description] => ## [0.3.1](https://gitlab.example.com/wordpress/plugins/mon-plugin/compare/0.3.0...0.3.1) (2022-11-03)

### Bug Fixes

* **JS:** suppression du fichier Dockerfile ([35edeed](https://gitlab.example.com/wordpress/plugins/mon-plugin/commit/35edeed5eddc4a8e8eb38388075bba69d23ac63b))

    [created_at] => 2022-11-03T15:30:14.242Z
    [released_at] => 2022-11-03T15:30:14.242Z
    [upcoming_release] => 
    [author] => stdClass Object
        (
            [id] => 7
            [username] => jsmansart
            [name] => Jean-Sebastien Mansart
            [state] => active
            [avatar_url] => https://gitlab.example.com/uploads/-/system/user/avatar/7/avatar.png
            [web_url] => https://gitlab.example.com/jsmansart
        )

    [commit] => stdClass Object
        (
            [id] => eff21a05e37eb4002062b65e4be3981697d7c34a
            [short_id] => eff21a05
            [created_at] => 2022-11-03T15:30:12.000+00:00
            [parent_ids] => Array
                (
                    [0] => 82ecc0a22753761ec91b77d1f6ed72ce0a96ccf6
                )

            [title] => RELEASE: 0.3.1
            [message] => RELEASE: 0.3.1

            [author_name] => semantic-release-bot
            [author_email] => semantic-release-bot@martynus.net
            [authored_date] => 2022-11-03T15:30:12.000+00:00
            [committer_name] => semantic-release-bot
            [committer_email] => semantic-release-bot@martynus.net
            [committed_date] => 2022-11-03T15:30:12.000+00:00
            [trailers] => stdClass Object
                (
                )

            [web_url] => https://gitlab.example.com/wordpress/plugins/mon-plugin/-/commit/eff21a05e37eb4002062b65e4be3981697d7c34a
        )

    [commit_path] => /wordpress/plugins/mon-plugin/-/commit/eff21a05e37eb4002062b65e4be3981697d7c34a
    [tag_path] => /wordpress/plugins/mon-plugin/-/tags/0.3.1
    [assets] => stdClass Object
        (
            [count] => 4
            [sources] => Array
                (
                    [0] => stdClass Object
                        (
                            [format] => zip
                            [url] => https://gitlab.example.com/wordpress/plugins/mon-plugin/-/archive/0.3.1/mon-plugin-0.3.1.zip
                        )

                    [1] => stdClass Object
                        (
                            [format] => tar.gz
                            [url] => https://gitlab.example.com/wordpress/plugins/mon-plugin/-/archive/0.3.1/mon-plugin-0.3.1.tar.gz
                        )

                    [2] => stdClass Object
                        (
                            [format] => tar.bz2
                            [url] => https://gitlab.example.com/wordpress/plugins/mon-plugin/-/archive/0.3.1/mon-plugin-0.3.1.tar.bz2
                        )

                    [3] => stdClass Object
                        (
                            [format] => tar
                            [url] => https://gitlab.example.com/wordpress/plugins/mon-plugin/-/archive/0.3.1/mon-plugin-0.3.1.tar
                        )

                )

            [links] => Array
                (
                )

        )

    [evidences] => Array
        (
            [0] => stdClass Object
                (
                    [sha] => 0abf7729a61f7b0a2951429b912bf1c66561b53ff08d
                    [filepath] => https://gitlab.example.com/wordpress/plugins/mon-plugin/-/releases/0.3.1/evidences/22.json
                    [collected_at] => 2022-11-03T15:30:14.389Z
                )

        )

    [_links] => stdClass Object
        (
            [self] => https://gitlab.example.com/wordpress/plugins/mon-plugin/-/releases/0.3.1
            [edit_url] => https://gitlab.example.com/wordpress/plugins/mon-plugin/-/releases/0.3.1/edit
        )

)

Thanks for the library !

YahnisElsts commented 1 year ago

I did some testing and it looks like a release can have both "links" and "sources" on the same release. I think PUC should also support both. If someone puts in the additional effort to add custom asset links to their release(s), they might want to use those links for updates.

I have refactored the GitLab release asset logic so that the update checker will use "sources" by default, and it will try to use "links" if you call enableReleaseAssets(). When using "sources", it will choose the first source where format is zip.

With those changes, I think this PR is no longer needed. Please try the patched version in the master branch. If it doesn't work for your use case, please open a new issue.

jihaisse commented 1 year ago

Thanks for the refactoring, it works great. I'm working on a way to have alpha, beta or other prerelease working with PUC, I will propose something in this way soon, you surely have to rewrite that, but it may be inspiritionnal.

Thanks again for the work