Skip to content

Create latest.json build artefact for updater endpoint#351

Closed
Serophots wants to merge 18 commits intocrabnebula-dev:mainfrom
Serophots:main
Closed

Create latest.json build artefact for updater endpoint#351
Serophots wants to merge 18 commits intocrabnebula-dev:mainfrom
Serophots:main

Conversation

@Serophots
Copy link
Copy Markdown

@Serophots Serophots commented Jul 4, 2025

This PR will have cargo-packager automatically build a latest.json artefact which summarises all of the other artefacts to be consumed as an updater endpoint. This makes using cargo-packager through Github actions and Github releases fully automated by allowing the updater endpoint to be a statically hosted latest.json file accessible through https://github.com/org/repo/releases/latest/download/latest.json. This closes #350

Changes to Packager config

  /// When set, a summary `latest.json` build artefact will be generated which can be
  /// hosted alongside other build artefacts as an endpoint for the updater, including
  /// meta data about the version and URL's to point at each of the other build artefacts.
  ///
  /// Specifically, this URL specifies where these build artefacts are hosted. For example,
  /// a using Github Releases: `https://github.com/org/repo/releases/download/v{{version}}/{{artefact}}`
  ///
  /// Each endpoint optionally could have `{{version}}` or `{{artefact}}`
  /// which will be detected and replaced with the appropriate value
  ///
  /// - `{{version}}`: The version of the app which is being packaged
  /// - `{{artefact}}`: The file name of the particular build artefact
  ///     One URL is produced per build artefact.
  pub endpoint: Option<Url>,

Example latest.json

Here is an example of a latest.json generated by this PR. The schema is compatible with the existing Updater crate.

{
  "version": "4.0.0",
  "notes": null,
  "pub_date": "2025-07-04T14:12:24.096236Z",
  "platforms": {
    "aarch64-apple-darwin": {
      "url": "https://github.com/org/repo/org/download/v4.0.0/app_4.0.0_aarch64.dmg",
      "signature": "dW50cnVzdGVkIGNvbW1lbnQ6IHNpZ25hdHVyZSBmcm9tIGNhcmdvLXBhY2thZ2VyIHNlY3JldCBrZXkKUlVSRC82M0RjS29jcTNETVJGblAybzRtTmJlTUVZQjlBcXJPUzlUSHVDYWtSYlVTc3FzeUdBd0VWVDFEdXFrdnBqek9WT3ZrV01XcmtrZk1NYlVJNGpHSm5OTWFyRmJDRUFJPQp0cnVzdGVkIGNvbW1lbnQ6IHRpbWVzdGFtcDoxNzUxNjM4MzQ0CWZpbGU6VW5pRmx5XzQuMC4wX2FhcmNoNjQuZG1nCnR3aXFqZFMzOHIxbGJOcCtKK3QxMzVreEg1VUFvUE5qa1FsTUxHalMzNWd6NzNabkV3cGJGOWZNQ29aSXVmemZVamorRmppSG9Fa3RXSytUVkNvb0J3PT0K",
      "format": "dmg"
    }
  }
}

Caveats

  1. I have not implemented any of this for the NodeJS part of the updater, but I expect that should be fairly do-able
  2. When a particular packager format produces multiple build artefacts I have not included any logic to determine which build artefact the latest.json should point to, so currently those packager formats are excluded from the latest.json.
  3. This assumes the updates are hosted at a single (github) endpoint, whilst the updater has support for fetching from potentially multiple endpoints. I think this is passable because I assume Github releases already has its own redundancy.

@FabianLars-crabnebula
Copy link
Copy Markdown
Contributor

Thank you for the PR! Since it's a bit of a larger change it will likely take a while for us to review (at this point we can take over in case you're unavailable).
One thing before that though, your first commit isn't signed, i'd appreciate if you could fix that so that github allows me to merge the PR :)

@Serophots
Copy link
Copy Markdown
Author

Hi, I appreciate you looking at this. This is my first PR and I'm not very good with git and my attempts to go back and sign that first commit seem to just be piling on more commits to the PR.. Apologies for this. Would it be okay if I created a brand new PR with all of the changes in one signed commit?

@FabianLars-crabnebula
Copy link
Copy Markdown
Contributor

yes of course! and no worries, signing past commits is absolute hell, i couldn't tell you how to do it right now either 🙃

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.

Feature Request: Updater export json RemoteRelease as build artefact

2 participants