Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: update macOS asset matching #169

Open
wants to merge 16 commits into
base: main
Choose a base branch
from

Conversation

setchy
Copy link

@setchy setchy commented Oct 7, 2024

Resolves #168, #140, #166, #113

Updates the macOS (darwin) asset matching logic to

  1. Add support for electron-builder arm64 asset naming convention
  2. Add support for electron-builder universal asset naming convention
  3. Fallback to universal build if no specific macOS release found (ie: arm64 or x64), or universal asset is deemed more recent.
  4. Ignore assets that don't end with .zip (eg: blockmap assets)
  5. Ensure that suggested latest assets do indeed have a newer version than that currently running

@setchy setchy requested a review from a team as a code owner October 7, 2024 01:45
@setchy setchy changed the title fix: support latest electron builder default macOS release names feat: update macOS asset regex to support electron-builder naming convention, universal builds and exclude blockmaps Oct 7, 2024
@setchy setchy changed the title feat: update macOS asset regex to support electron-builder naming convention, universal builds and exclude blockmaps feat: update macOS asset regex matching (electron-builder, universal builds, exclude non zips) Oct 7, 2024
@setchy
Copy link
Author

setchy commented Oct 8, 2024

Some before and after examples

Scenario Current Response PR Response
http://localhost:56669/gitify-app/gitify/darwin-arm64/5.14.0 No updates found (needs asset matching (mac|darwin|osx).(-arm).*.zip in public repository) {name: "v1.5.0", url: "https://github.com/setchy/atlassify/releases/download/v1.5.0/Atlassify-1.5.0-arm64-mac.zip"}
http://localhost:56669/setchy/atlassify/darwin-arm64/1.4.0 No updates found (needs asset matching (mac|darwin|osx).(-arm).*.zip in public repository) {name: "v5.15.0", url: "https://github.com/gitify-app/gitify/releases/download/v5.15.0/Gitify-5.15.0-universal-mac.zip"}

src/updates.js Outdated
@@ -210,6 +224,7 @@ class Updates {
for (const release of releases) {
if (
!semver.valid(release.tag_name) ||
semver.lt(release.tag_name, version) ||
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change in behavior seems unrelated? Can you explain this change and why it's needed in this PR

Copy link
Author

@setchy setchy Oct 8, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the review @MarshallOfSound - apologies for not calling out this change.

This change was important to ensure that assets from previous releases weren't being matched.

For example, without this change http://localhost:62178/gitify-app/gitify/darwin-x64/5.14.0 and http://localhost:62178/gitify-app/gitify/darwin-arm64/5.14.0 were both finding the "latest" assets from a really old release https://github.com/gitify-app/gitify/releases/tag/v4.2.1 (the last time we published non-universal artifacts).

This then causes the following empty response and inaccurate log message

} else if (semver.lte(latest.version, version)) {
log.debug({ account, repository, platform, version }, "up to date");
noContent(res);
} else {

Adding in the above check ensures that only newer versions are considered eligible for the latest assets object

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This isn't an issue with your other changes in this PR right, i.e. you don't need this now that you've added universal fallback?

The regex changes seem safe at a glance, but changing this lte from it's original defense location would require more thinking. If you remove this lt change reviewing this PR will be much easier and will be more likely it lands.

Copy link
Author

@setchy setchy Oct 8, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, this change is required as part of this PR for it to work.

Without it, latest is not null, therefore it never falls back to checking if the universal release is newer.

eg:
latest === {name: "v4.2.1", ...}
latestUniversal === {name: "v5.15.0", ...}

Copy link
Author

@setchy setchy Oct 8, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This logic can either be where I've placed it, or in the universal release block (ie: semver.gt(universal.version, latest.version)...

I went with the former since that is where the other asset tags are skipped over (prerelease, draft, invalid semver)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm, can we modify the fallback logic from: "get x64/arm64, if not exists get universal" or just consider unviersal builds arm64/x64 builds by default if no arm64/x64 specific build is present. i.e. it's a fallback within get asset, rather than a separate call?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i.e. in here

return latest && latest[platform];

Just do effective if (!latest[platform] && platform === A_DARWIN_PLATFORM && latest[universal]) return latest[universal]

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed the lt check and changes where the latestUniversal replacement occurs


if (
latestUniversal &&
semver.gt(latestUniversal.version, latest.version)
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@MarshallOfSound - moved the semver check here to be part of the universal replacement logic

@setchy
Copy link
Author

setchy commented Oct 8, 2024

Now with added unit tests for the new universal logic

Copy link

@afonsojramos afonsojramos left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great addition, wasn't aware this wasn't supported yet! We're standing on the shoulders of giants!!

@setchy setchy changed the title feat: update macOS asset regex matching (electron-builder, universal builds, exclude non zips) feat: update macOS asset matching Oct 11, 2024
@setchy
Copy link
Author

setchy commented Oct 15, 2024

@MarshallOfSound - any further feedback you have re: this enhancement proposal? Really looking forward to my two user groups getting back on the auto-upgrade pathway

src/asset-platform.js Outdated Show resolved Hide resolved
@setchy
Copy link
Author

setchy commented Nov 15, 2024

@MarshallOfSound @erickzhao @dsanders11 - any additional feedback you may offer? If not, could we look to have this enhancement released 🙏

@erickzhao erickzhao self-requested a review November 15, 2024 20:54
Copy link
Member

@erickzhao erickzhao left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall this LGTM.

I see that this does disallow the edge case where the file ZIP is just called mac.zip but the regex for win32 still seems to accept something like win32.zip.

Maybe a good follow-up PR to this would be to add the leading - to the Windows regex patterns as well to get parity between platforms.

@setchy
Copy link
Author

setchy commented Nov 24, 2024

@erickzhao - thanks for the review 🙏

I can certainly raise a separate PR for the windows regex.

For this PR, what are the next steps to have this change merged and released?

@erickzhao
Copy link
Member

For this PR, what are the next steps to have this change merged and released?

I was going to ask other maintainers if they had feedback but otherwise I don't think there's anything to do on your end!

Copy link
Member

@VerteDinde VerteDinde left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed the code and it looks reasonable - changes asked for in the PR discussions also seem to be addressed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Error: Update check failed. The server sent an invalid response. Try again later.
5 participants