Before asking for help please read "How to request help" by clicking on that tab above here.
  • Page:
  • 1

TOPIC:

Custom module: notification when a new version is available on GitHub 6 days 22 hours ago #1

  • Sir Peter
  • Sir Peter's Avatar Topic Author
  • Offline
  • Junior Member
  • Junior Member
  • Posts: 110
Hello, I have a working custom module which shows its version in the control panel as 1.0.2. I created a new release 1.0.4 on GitHub. The module.php file on GitHub includes - amongst others - these 2 lines:
public const CUSTOM_VERSION = '1.0.4';
public const CUSTOM_LAST = 'https://github.com/<myUser>/<myRepository>/blob/main/latest-version.txt';
The file latest-version.txt on GitHub includes only a single line:
1.0.4
I *think* I have seen such a notification in the past for one of the other custom modules, but I can't remember which one.
  1. How to make a custom module show a notification to the webtrees administrator when a new version of that custom module is available on GitHub?
  2. How to make a custom module offer an update of that custom module to the webtrees administrator like it is done for the webtrees core?
  3. Are these features currently available for custom modules at all - or at least the first one?
  4. If not, are there any plans to implement these features?
Peter

Please Log in or Create an account to join the conversation.

Custom module: notification when a new version is available on GitHub 6 days 18 hours ago #2

  • ric2015
  • ric2015's Avatar
  • Offline
  • Junior Member
  • Junior Member
  • Posts: 212

Sir Peter wrote:

  1. How to make a custom module show a notification to the webtrees administrator when a new version of that custom module is available on GitHub?
  2. How to make a custom module offer an update of that custom module to the webtrees administrator like it is done for the webtrees core?
  3. Are these features currently available for custom modules at all - or at least the first one?
  4. If not, are there any plans to implement these features?


For 1., you just have to provide an url pointing to the latest version, like this:
public function customModuleLatestVersionUrl(): string
    {
        return 'https://www.example.com/latest-version.txt';
    }

(see the example module in the modules folder or here )

2. is not possible yet, see a related discussion here - unfortunately, it lead to nothing. Like other custom modules issues, it doesn't seem to have a high priority.
Richard

webtrees 2.0.10 at cissee.de/webtrees2
Vesta custom modules (Classic Look & Feel, Gov4Webtrees, Shared Places, Extended Relationships) available at cissee.de

Please Log in or Create an account to join the conversation.

Custom module: notification when a new version is available on GitHub 6 days 18 hours ago #3

  • photon flip
  • photon flip's Avatar
  • Offline
  • New Member
  • New Member
  • Posts: 34
I seem to remember the Vesta modules putting a new version available notification in the control panel.

Please Log in or Create an account to join the conversation.

Custom module: notification when a new version is available on GitHub 6 days 17 hours ago #4

  • Sir Peter
  • Sir Peter's Avatar Topic Author
  • Offline
  • Junior Member
  • Junior Member
  • Posts: 110
Thanks for your feedback and advice. In module.php I have:
public const CUSTOM_VERSION = '1.0.4';
public const CUSTOM_LAST = 'https://github.com/<myUser>/<myRepository>/blob/main/latest-version.txt';
public function customModuleVersion(): string
{
    return self::CUSTOM_VERSION;
}
public function customModuleLatestVersionUrl(): string
{
    return self::CUSTOM_LAST;
}
How often is this routine executed - whenever I call the module from the control panel or is there a schedule and I should be more patient?
Peter

Please Log in or Create an account to join the conversation.

Custom module: notification when a new version is available on GitHub 6 days 16 hours ago #5

  • ric2015
  • ric2015's Avatar
  • Offline
  • Junior Member
  • Junior Member
  • Posts: 212
It's called when you view the control panel, but the value is cached for 24 hours, unless you override this method . For the Vesta modules, I use an expiration of 1 hour instead. By the way, you also have to adjust this method if you use a different versioning scheme (other than 'major.minor.patch').
Richard

webtrees 2.0.10 at cissee.de/webtrees2
Vesta custom modules (Classic Look & Feel, Gov4Webtrees, Shared Places, Extended Relationships) available at cissee.de

Please Log in or Create an account to join the conversation.

Custom module: notification when a new version is available on GitHub 6 days 1 hour ago #6

  • Sir Peter
  • Sir Peter's Avatar Topic Author
  • Offline
  • Junior Member
  • Junior Member
  • Posts: 110
Thanks. I don't want to change that method. 24 hours would be ok. I *think* I've got everything right now and created another release. I will exercise patience and see what happens.
Peter

Please Log in or Create an account to join the conversation.

Last edit: by Sir Peter.

Custom module: notification when a new version is available on GitHub 5 days 23 hours ago #7

This section of the module define the version. When there is a new version it will flag it on the control panel.
/**
     * The version of this module.
     *
     * @return string  e.g. '1.2.3'
     */
    public function customModuleVersion(): string
    {
        return '1.0.8';
    }
Rob
www.skatekey.net ( beta GitHub)
PHP 7.4.6, MariaDB 10.1.44, Apache 2.4.43,
Hosted at tigertech.net

Please Log in or Create an account to join the conversation.

Last edit: by makitso.

Custom module: notification when a new version is available on GitHub 5 days 5 hours ago #8

  • magic-sunday
  • magic-sunday's Avatar
  • Offline
  • New Member
  • New Member
  • Posts: 59
If you are using github there is no need for a separate version file. Instead use the information provided by github itself. Inside the JSON response of e.g. api.github.com/repos/magicsunday/webtree...hart/releases/latest you will find an entry called "tag_name" pointing to the latest release verion. Those of course requires naming tags with version numbers, which should be the normal way of a module. In order to prevent the need to override the customModuleLatestVersion method, a small extend to the method is required to be merged in the master branch: github.com/fisharebest/webtrees/pull/3661 . This way it would be possible to extract the version information from a different place without duplicating core code in a custom module.

So customModuleLatestVersionUrl should point to the github URL instead of a latest-version.txt file which must be maintained too.
webtrees, latest dev
PHP 7.4

Please Log in or Create an account to join the conversation.

Last edit: by magic-sunday.
Do you need a web hosting solution for your webtrees site?
If you prefer a host that specialises in webtrees, the following page lists some suppliers able to provide one for you: 

Custom module: notification when a new version is available on GitHub 4 days 37 minutes ago #9

  • Sir Peter
  • Sir Peter's Avatar Topic Author
  • Offline
  • Junior Member
  • Junior Member
  • Posts: 110

magic-sunday wrote: Inside the JSON response ... you will find an entry called "tag_name" pointing to the latest release version. ...
So customModuleLatestVersionUrl should point to the github URL instead of a latest-version.txt file which must be maintained too.


Thanks! Your hint to the GitHub api made me aware that while my versioning - following a GitHub recommendation - began with v as in v1.0.4, webtrees update notifications seem to work for versioning without the v only.

I moved to a new repository (for a different reason) and created new releases 1.0.6 and 1.0.7 instead of v1.0.6 and v1.0.7 and now hope that webtrees will notify me about the newer 1.0.7 version within 24 hours.
Peter

Please Log in or Create an account to join the conversation.

Custom module: notification when a new version is available on GitHub 4 days 17 minutes ago #10

  • ric2015
  • ric2015's Avatar
  • Offline
  • Junior Member
  • Junior Member
  • Posts: 212

Sir Peter wrote: webtrees update notifications seem to work for versioning without the v only.


See also my earlier remark "By the way, you also have to adjust this method if you use a different versioning scheme (other than 'major.minor.patch')."

In particular, you can use any other versioning scheme if you adjust or remove this line .
Richard

webtrees 2.0.10 at cissee.de/webtrees2
Vesta custom modules (Classic Look & Feel, Gov4Webtrees, Shared Places, Extended Relationships) available at cissee.de

Please Log in or Create an account to join the conversation.

Custom module: notification when a new version is available on GitHub 1 day 3 hours ago #11

  • Sir Peter
  • Sir Peter's Avatar Topic Author
  • Offline
  • Junior Member
  • Junior Member
  • Posts: 110
I finally resolved the issue with webtrees not notifying the administrator about an update for my custom module by replacing "blob" with "raw" in the link to the latest-version.txt file, e. g.

replace
public const CUSTOM_LAST = 'https://github.com/<myUser>/<myRepository>/blob/main/latest-version.txt';
with
public const CUSTOM_LAST = 'https://github.com/<myUser>/<myRepository>/raw/main/latest-version.txt';

And after deleting the webtrees cache via the control panel the update was shown immediately. I am now looking forward to the implementation of www.webtrees.net/index.php/en/forum/help...n-github/reply#83439 so that I can get rid of the latest-version.txt file completely. Thanks for all your support!
Peter

Please Log in or Create an account to join the conversation.

  • Page:
  • 1
Powered by Kunena Forum