mustang-im / mustang

Mustang - New full-featured desktop email, chat and video conference client
https://mustang.im
Other
7 stars 1 forks source link

Auto-Update latest.yml files for Mustang *and* Parula #151

Closed benbucksch closed 3 weeks ago

benbucksch commented 1 month ago

Part of #142 Please see #147 for background.

Problem

Given that we have Mustang and Parula brands, in the same repo, during a release, both are trying to write the latest.yml files. Whoever is last wins and overwrites the other one.

Artifacts

Here are the 2 versions: latest-linux.yml before re-run latest-linux.yml after re-run

Solution idea

Separate repo for Parula release

One option would be that we make another repo for parula, called mustang-im/parula, and add the Parula GitHub actions there, and set it up so that either:

  1. these Actions trigger on changes to another repo (I don't know whether GitHub actions allow that, but I think I saw something like that) (that's the preferred option), or whether
  2. we keep the parula repo in sync with the mustang repo.

Either way, we need to make sure that electron-updater uses the right repo for Parula.

This option is rather cumbersome.

Merge files

Somehow find a way to write the contents of both files together into the same file. This is assuming that the auto-update is smart enough to know its own app name and picks the right entries from the file.

Given that the upload is automatic and part of electron-builder, it might need some trickery to merge the files.

Other idea

Maybe you have other, even simpler ideas how to fix it?

benbucksch commented 1 month ago

@jermy-c thanks for the PR #154, which implements the idea 1 "Separate repo" above.

benbucksch commented 1 month ago

Rename files

Rename latest.yam to latest-parula.yaml and latest-mustang.yaml

@jermy-c Could you please investigate whether that is possible? Is the "latest" configurable? If not, can you make a PR for electron-builder and electron-update to support that?

jermy-c commented 1 month ago

It's not possible to rename the update files because electron-builder relies on the naming to determine the channel, os and architecture. The latest is only configurable through changing the channels.

To support renaming files would take a lot of changes because the electron-builder and electron-updater. It uses the format {channel}{os}{architecture}.yml generate and search for the correct update file.

Should I continue with it?

benbucksch commented 1 month ago

Using channels (release, beta, alpha) might be an option? Does that result in different filenames? Are the channel names configurable?

jermy-c commented 1 month ago

Yes, it does change the fileanme. If you set

publish:
  - provider: github
    protocol: https
    releaseType: release
    channel: parula

It creates:

parula.yml
parula-mac.yml
parula-linux.yml
benbucksch commented 1 month ago

Oh, perfect! Can we do that for Mustang as well? Can you test it and make a PR? This looks great! Exactly what I had hoped for! Well done!

benbucksch commented 1 month ago

Works beautifully, at least the files: https://github.com/mustang-im/mustang/releases/tag/v0.5.7

benbucksch commented 1 month ago

Unfortunately, the updater still uses "latest" as filename: Error: Error: Cannot find latest-linux.yml in the latest release artifacts (https://github.com/mustang-im/mustang/releases/download/v0.5.8/latest-linux.yml): HttpError: 404

benbucksch commented 1 month ago

The update client still uses the old filename "latest".

Given that already the file fetch fails (which is before mac signature verification), and we have the correct files on the server, you should be able to test locally. you just need to lower the version number of your local build to 0.5.1. It should find and download the update. If it fails to verify the signature, then we're a step further. make sure that the automated release builds then create the build like this.

jermy-c commented 1 month ago

(property) AppUpdater.channel: string | null Get the update channel. Not applicable for GitHub. Doesn't return channel from the update configuration, only if was previously set. Set the update channel. Not applicable for GitHub. Overrides channel in the update configuration.

Setting the channel doesn't change the channel in the GitHubProvider update fetcher. It's available in electron-builder.yml but only sets the filename for the latest.yml but it doesn't nothing in the AppUpdater.

https://github.com/electron-userland/electron-builder/blob/977acaf0732f3833f583ad3e920c6b0217f78db5/packages/electron-updater/src/providers/GitHubProvider.ts#L139

benbucksch commented 1 month ago

Can you make a PR to fix it, please? getCustomChannelName() sounds promising.

jermy-c commented 1 month ago

Ok, will do.

jermy-c commented 1 month ago

I created an Issue and another dev made a PR for the issue. https://github.com/electron-userland/electron-builder/issues/8388

jermy-c commented 3 weeks ago

Auto-update is still not working. The update is downloaded but it is not installed when all windows are closed or when the app is quit. I'm not sure if it's supposed to install when the app is quit or when all windows are closed. If the condition to install the update when the all windows are closed it may be because the backend is still running. But the notification message says it will install when the app is quit.

benbucksch commented 3 weeks ago

The update is downloaded

Did you check both Parula and Mustang? Is the right version being downloaded? If so, then it means that this bug is fixed.

I've re-opened #142 for the other issue, to be debugged.

jermy-c commented 3 weeks ago

The updater is downloading the wrong version i.e. it is downloading the windows version.

Files downloaded:

  1. mustang-0.5.10-setup.exe
  2. update-info.json

Download dir: ~/Library/Caches/mustang-updater

The root cause might be the incorrect OS version.

benbucksch commented 3 weeks ago

Ah, that's funny. Of course that wouldn't work.

Does it fetch mustang.yml (which is Windows - that would explain the bug) or mustang-mac.yml (correct) or something else to find the latest version?

jermy-c commented 3 weeks ago

My bad. We just need to update the electron-updater package to 6.3.3 which includes the custom channel feature for GitHub. We're currently still on the stable version 6.2.1. That's going to fix it.

benbucksch commented 3 weeks ago

@jermy-c That's great! I've just upgraded it. Let's see whether this fixes it.