CLI installer script: support versions with and without "v"; print installed version; print URL if download failed
We have a tag, say, v4.0.0-alpha.5
and want to install specific CLI version.
This now won't work:
nik@niks-air ~ % export DBLAB_CLI_VERSION=v4.0.0-alpha.5
nik@niks-air ~ % curl -sSL dblab.sh | bash
Detected OS: darwin, architecture: arm64
curl: (22) The requested URL returned error: 404
dblab setup failure – cannot download binaries
If we remove v
manually, it works:
nik@niks-air ~ % export DBLAB_CLI_VERSION=4.0.0-alpha.5
nik@niks-air ~ % curl -sSL dblab.sh | bash
Detected OS: darwin, architecture: arm64
888 888 888 888
888 888 888 888
888 888 888 888
.d88888 88888b. 888 8888b. 88888b.
d88" 888 888 "88b 888 "88b 888 "88b
888 888 888 888 888 .d888888 888 888
Y88b 888 888 d88P 888 888 888 888 d88P
"Y88888 88888P" 888 "Y888888 88888P"
::::::::::::::::::::::::::::::::::::::::
SUCCESS! DLE CLI ("dblab") downloaded to:
~/.dblab/dblab
Add it to $PATH or move manually:
sudo mv ~/.dblab/dblab /usr/local/bin/dblab
::::::::::::::::::::::::::::::::::::::::
To start, run:
dblab init
Users can easily try to use the full tag value, with v
. So let's support both formats here.
In this MR:
- support version with and without leading
v
- print downloaded version
- in case root, correct wording
- for non-root, provide explicit snippet to patch
$PATH
- if download fails, print URL to help with troubleshooting
New behavior:
nik@niks-air ~ % export DBLAB_CLI_VERSION=v4.0.0-alpha.5
nik@niks-air ~ % curl -sSL https://gitlab.com/postgres-ai/database-lab/-/raw/nik-cli-setup-remove-v/engine/scripts/cli_install.sh | bash
Detected OS: darwin, architecture: arm64
888 888 888 888
888 888 888 888
888 888 888 888
.d88888 88888b. 888 8888b. 88888b.
d88" 888 888 "88b 888 "88b 888 "88b
888 888 888 888 888 .d888888 888 888
Y88b 888 888 d88P 888 888 888 888 d88P
"Y88888 88888P" 888 "Y888888 88888P"
::::::::::::::::::::::::::::::::::::::::
dblab version v4.0.0-alpha.5-20230516-0225
::::::::::::::::::::::::::::::::::::::::
Installed to:
~/.dblab/dblab
Add it to $PATH:
export PATH=$PATH:~/.dblab/dblab
or move:
sudo mv ~/.dblab/dblab /usr/local/bin/dblab
::::::::::::::::::::::::::::::::::::::::
To start, run:
dblab init
nik@niks-air ~ % export DBLAB_CLI_VERSION=v123456vvv # test an incorrect version value
nik@niks-air ~ % curl -sSL https://gitlab.com/postgres-ai/database-lab/-/raw/nik-cli-setup-remove-v/engine/scripts/cli_install.sh | bash
Detected OS: darwin, architecture: arm64
curl: (22) The requested URL returned error: 404
dblab setup failure – cannot download binaries from https://storage.googleapis.com/database-lab-cli/123456vvv/dblab-darwin-arm64
Edited by Nikolay Samokhvalov