casey / just

🤖 Just a command runner
https://just.systems
Creative Commons Zero v1.0 Universal
17.59k stars 399 forks source link

Consider removing version from release filenames because it breaks github paths #1956

Open nyurik opened 2 months ago

nyurik commented 2 months ago

Github has a useful hack to get the latest released file: https://github.com/casey/just/releases/latest/download/<filename>. So running this command

curl -LI https://github.com/casey/just/releases/latest/download/just-1.25.2-aarch64-unknown-linux-musl.tar.gz

at the moment shows all the needed redirects to the actual released file. But this URL will break very soon - as soon as you release a new version -- the problem is that it has a hardcoded version inside the filename, which breaks this pattern. The version has to be specified in both the "directory" and the "filename", and that makes it impossible to "just get the latest".

Please remove the version number from the filename to make it easier to download. Thx!

hustcer commented 2 months ago

It's quite common to include a version number in release artifacts, you can always get the latest release by:

curl -s https://api.github.com/repos/casey/just/releases/latest | grep browser_download_url | cut -d '"' -f 4 | grep aarch64-unknown-linux-musl
VladimirMarkelov commented 2 months ago

I am not sure, but isn't Windows package manager scoop wants a version number included into the archive name to detect whether an application needs updating and what the version is the latest? If so, it would keep the version number in the file name.

nyurik commented 2 months ago

@hustcer I know some repos do it - my point is that it is redundant (version used in two places in the same URL), and makes it harder to get in automated environment without relying on things like jq. Plus it makes github's /latest endpoint useless.

Thanks for the code sample, but it is highly unstable and hacky because it relies on github API returning json in a prety-printed format - which can change at any moment. Not a reliable solution for any CI. I would suggest this approach using jq

curl -sL https://api.github.com/repos/casey/just/releases/latest | jq -r '.assets | map(.browser_download_url) | .[] | select(. | endswith("-x86_64-unknown-linux-musl.tar.gz"))'

@VladimirMarkelov thx, I was not aware of that - but it seems this should be fairly easy to fix for them, esp if we raise it as an issue?

VladimirMarkelov commented 2 months ago

@nyurik I'm sorry, I do not know detail how scoop works, so I am unsure whether there is a workaround. I just see that the just package for scoop includes version in both places: path and file name. It is a line from autoupdate "script": "https://github.com/casey/just/releases/download/$version/just-$version-x86_64-pc-windows-msvc.zip"

hustcer commented 2 months ago

Thanks for the code sample, but it is highly unstable and hacky because it relies on github API returning json in a prety-printed format - which can change at any moment. Not a reliable solution for any CI.

@nyurik If I were you, I would use Nushell with setup-nu action and run command like:

http get https://api.github.com/repos/casey/just/releases/latest | get assets.browser_download_url | where $it =~ 'x86_64-unknown-linux-musl.tar.gz' | get 0

It's stable and doesn't depend on any external commands. This is a bit of a high barrier to use, though, and requires basic Nushell skills