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

Provide a cli command to download the latest release of the bin directly #192

Open
MurzNN opened this issue Mar 21, 2024 · 4 comments
Open

Comments

@MurzNN
Copy link

MurzNN commented Mar 21, 2024

Now in the readme, we have a recommendation to Download the bin from the releases page manually.

But for some users, and especially for automation in scripts, it's good to have a CLI command to do this directly, better as a one-liner.

@marcosnils
Copy link
Owner

SGTM! Any chance you'd like to open a PR for it? I can take care of uploading the script somewhere afterwards

@MurzNN
Copy link
Author

MurzNN commented Mar 21, 2024

I invented a not-one-lined script that does this:

#!/bin/bash

URL="marcosnils/bin"

LATEST_RELEASE=$(curl -s https://api.github.com/repos/$URL/releases/latest)
TAG_NAME=$(echo $LATEST_RELEASE | jq -r '.tag_name' | cut -c 2-)
FILENAME="bin_${TAG_NAME}_linux_amd64"

DOWNLOAD_URL=$(echo $LATEST_RELEASE | jq -r '.assets[] | select(.name | startswith("'"$FILENAME"'")) | .browser_download_url')

curl -s -L -o bin $DOWNLOAD_URL
chmod +x ./bin

It's complex because the release binary has the version name in the filename. If it be something static like just bin_linux_amd64 - it would be much easier to download by just like:

curl -s -L -o bin https://github.com/marcosnils/bin/releases/latest/download/bin_linux_amd64

@MurzNN
Copy link
Author

MurzNN commented Mar 21, 2024

One more example here: https://kubernetes.io/docs/tasks/tools/install-kubectl-linux/

   curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl"

@korpa
Copy link
Collaborator

korpa commented Mar 22, 2024

It's complex because the release binary has the version name in the filename. If it be something static like just bin_linux_amd64 - it would be much easier to download by just like:

curl -s -L -o bin https://github.com/marcosnils/bin/releases/latest/download/bin_linux_amd64

I really would like to see this version. @marcosnils: Any chance to remove the version from the filename?

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

No branches or pull requests

3 participants