feat: new parameter download-filter

This commit is contained in:
fuse314 2025-12-01 20:33:51 +00:00
parent e132301eee
commit a17d224780
3 changed files with 27 additions and 2 deletions

View file

@ -10,6 +10,7 @@ if ${VERBOSE:-false}; then set -x; fi
: ${TITLE:=$TAG}
: ${RELEASE_DIR:=dist/release}
: ${DOWNLOAD_LATEST:=false}
: ${DOWNLOAD_FILTER:=''}
: ${TMP_DIR:=$(mktemp -d)}
: ${GNUPGHOME:=$TMP_DIR}
: ${TEA_BIN:=$TMP_DIR/tea}
@ -19,6 +20,8 @@ if ${VERBOSE:-false}; then set -x; fi
: ${RETRY:=1}
: ${DELAY:=10}
IFS=',' read -a DL_FILTER <<< "$DOWNLOAD_FILTER"
RELEASE_NOTES_ASSISTANT_VERSION=v1.4.1 # renovate: datasource=forgejo-releases depName=forgejo/release-notes-assistant registryUrl=https://code.forgejo.org
TAG_FILE="$TMP_DIR/tag$$.json"
@ -202,6 +205,20 @@ wait_release() {
fi
}
maybe_download() {
if (( ${#DL_FILTER[@]} == 0 )); then
return 0
else
for flt in "${DL_FILTER[@]}"
do
if [[ "$flt" == "$1"]]; then
return 0
fi
done
fi
return 1
}
download() {
setup_api
(
@ -216,8 +233,12 @@ download() {
api GET repos/$REPO/releases/tags/"$TAG_URL" >"$TMP_DIR"/assets.json
fi
jq --raw-output '.assets[] | "\(.browser_download_url) \(.name)"' <"$TMP_DIR"/assets.json | while read url name; do # `name` may contain whitespace, therefore, it must be last
url=$(echo "$url" | sed "s#/download/${TAG}/#/download/${TAG_URL}/#")
curl --fail -H "Authorization: token $TOKEN" -o "$name" -L "$url"
if maybe_download "$name" ; then
url=$(echo "$url" | sed "s#/download/${TAG}/#/download/${TAG_URL}/#")
curl --fail -H "Authorization: token $TOKEN" -o "$name" -L "$url"
else
echo "Ignoring $name due to filter."
fi
done
)
}