Open pdcastro opened 4 years ago
Some reference Javascript code
I.e., a Javascript version of this trick:
One Liner to Download the Latest Release from Github Repo https://gist.github.com/steinwaywhw/a4cd19cda655b8249d908261a62687f8
Connects-to: balena-io/docs/pull/2064
Independently of having an autoupdate feature (#1669), there are use cases of dynamically generating a download link to the latest CLI executable installer or zip package, for use in web pages or scripts (
curl
/wget
command lines), including users' CI scripts.For example, the getting started guide / reference docs include several links to the CLI installation instructions or the releases page:
There are 4 links to the CLI documentation/releases above. Considering the document is a getting started guide for first-time users, it would be desirable to replace the 4 links with 1 or 2 links, one of them being a direct link to an
.exe
or.pkg
file for Windows / macOS respectively. Something like:(More about this in issue #1711.)
For this to be possible, the docs / getting started guide would need to dynamically generate the download link to the latest available CLI release, for the required platform.
So we need a couple of things on the CLI side:
balena update
This may be doable via some GitHub or
npm
registry HTTP API (hopefully public, non authenticated) that fetches available releases, otherwise we might need to publish/store CLI release information somewhere (like the balenaCloud API, but consider also users of openBalena and even standalone balenaOS images, which are configurable using the CLI, who are in principle not required to have a balenaCloud user account).Regarding the
balena update
command, it was discussed before in CLI check-ins (Shaun). The command's purpose is to manually initiate a CLI update, not generate download URLs. However, it may be reasonable (?) to introduce the URL generation functionality first. For example:The description of the
balena update print-url
subcommand above is just an idea I've had. It would be good to discuss it a bit more widely (Scott, Shaun, Cameron, Thodoris, Page...) before starting the implementation.