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

with -a support additional filter string when two or more suitable assets are discovered #272

Open
dkebler opened this issue Jan 31, 2025 · 1 comment

Comments

@dkebler
Copy link

dkebler commented Jan 31, 2025

There are some repo releases that come with more than one asset of suitable OS/architecture.

Example:
https://github.com/gohugoio/hugo/releases/tag/v0.142.0

In this project there is an "extended" binary asset as well as the "basic" asset.

When using dra -a dra only finds the first and doesn't even complain that there are two suitable assets.

  1. So at the very least it should complain that there are two or more suitable and not just download the first matching which it does now.
  2. If dra download supported say -f <string> then could be used to differentiate the two (or more). Maybe it should be treated like regex so you could use ! (not).

So in the case of the hugo repo

dra download -a -i -f extended gohugoio/hugo
dra download -a -i -f !extended gohugoio/hugo

I know it's possible to use untag and select but that means you have to first manually select the item which means it will fill in OS/arch. I didn't see any placeholder in that string for {OS} {arch} {type}

i.e. -s does not support this hugo_extended_{tag}_{OS}-{arch}.{type} which if it did then maybe that would be ok in place of a filter.


BTW thanks for this project!

I have created a number of scripts for this purpose over the years and used ideas from here
https://gist.github.com/steinwaywhw/a4cd19cda655b8249d908261a62687f8
and also used this python script
https://github.com/dvershinin/lastversion

but the single binary with no dependencies is super nice and it is available as a package in most distros except sadly alpine but I suppose the script you wrote will suffice, albeit with dependency on bash. So yea if not a big deal for your CI could you include alpine :).

@devmatteini
Copy link
Owner

Hi @dkebler! I'm glad you like dra!

as a package in most distros except sadly alpine but I suppose the script you wrote will suffice

I didn't have time yet to look into Alpine, but there is feature request open #265.


Now, for the other questions:

In this project there is an "extended" binary asset as well as the "basic" asset.

When using dra -a dra only finds the first and doesn't even complain that there are two suitable asset

  1. So at the very least it should complain that there are two or more suitable and not just download the first matching which it does now.

This is how automatic download works. You let dra choose what to download. It's meant to be non-interactive, and dra takes decisions on which asset to select on a set of rules for each OS+ARCH.

  1. If dra download supported say -f then could be used to differentiate the two (or more). Maybe it should be treated like regex so you could use ! (not).

As you already said, you should use selection download when you need to control which asset to download.

I know it's possible to use untag and select but that means you have to first manually select the item which means it will fill in OS/arch.

Do you need to download this asset in a script that works on different OS?
If yes you can pre compute the untagged asset names for each OS, and then in your script use the right one for the current platform.

For example, using bash:

#!/usr/bin/env bash

set -euo pipefail

OS=$(uname -s)
ASSET_NAME=""
case "$OS" in
  Linux) ASSET_NAME="hugo_extended_{tag}_linux-amd64.tar.gz" ;;
  Darwin) ASSET_NAME="hugo_extended_{tag}_darwin-universal.tar.gz" ;;
  MINGW* | Win*) ASSET_NAME="hugo_extended_{tag}_windows-amd64.zip" ;;
  *) echo "Unsupported operating system: $OS"; exit 1 ;;
esac


dra download -s "$ASSET_NAME" gohugoio/hugo

I didn't see any placeholder in that string for {OS} {arch} {type}

Unfortunately, I can't think of a good solution to include more placeholder like OS or ARCH. There are many different conventions like x86_64 and amd64.

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

2 participants