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

Generate download link to latest CLI release ("balena update") #1716

Open
pdcastro opened this issue Apr 13, 2020 · 3 comments
Open

Generate download link to latest CLI release ("balena update") #1716

pdcastro opened this issue Apr 13, 2020 · 3 comments

Comments

@pdcastro
Copy link
Contributor

pdcastro commented Apr 13, 2020

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:

The recommended way to deploy code is to install the balena CLI. The easiest way to do this is to use the installer for your OS available on the releases page. Choose the latest release of the installer for your OS, and follow the installation instructions.
Note: You may also install the balena CLI via npm on a system running NodeJS, as explained in NPM Installation.

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:

Click here to download and install the CLI for Windows
Note: Additional platforms and installation options are available, including the ability to choose specific CLI versions to install -- read more about the installation options.

(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:

  • Some reference Javascript code, ideally executable on a web page (not just Node.js), that generates a download link to the latest CLI executable installer or zip package.
  • A CLI command that does the same: 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:

$ balena update print-url --platform windows --type executable
https://github.com/balena-io/balena-cli/releases/download/v11.30.17/balena-cli-v11.30.17-windows-x64-installer.exe

$ balena update print-url --platform macos --type executable --version 11.30.10
https://github.com/balena-io/balena-cli/releases/download/v11.30.10/balena-cli-v11.30.10-macOS-x64-installer.pkg

$ balena update print-url --platform linux --type standalone
https://github.com/balena-io/balena-cli/releases/download/v11.30.17/balena-cli-v11.30.17-linux-x64-standalone.zip

$ balena update print-url --type source-zip
https://github.com/balena-io/balena-cli/archive/v11.30.17.zip

$ balena update
→ Causes `balena help update` to be printed, including an explanation like:

The `balena update` command is intended to check for available CLI releases and
initiate an update installation. At the moment, only the `print-url` subcommand
is implemented. It can be used to print URLs to CLI installers for use in your
own scripts. 

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.

@pdcastro pdcastro added this to the Ordered Backlog milestone Apr 14, 2020
@pdcastro
Copy link
Contributor Author

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

@pdcastro
Copy link
Contributor Author

Connects-to: balena-io/docs/pull/2064

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

No branches or pull requests

1 participant