fetch-archives: Allow to specify a regex

[why]
Now where we have zip and tar.xz archives one might want to just fetch
one specific one. So we need to have a pattern not only for the
beginning of the file name.

[how]
Enable full regexes for the filtering.
For this we need to escape blanks in the pattern/regex, that a user
might specify (./fetch-archive.sh v2.2.2 'Some Font').

[note]
This is already then used for the casks workflow, as that only needs the
zips.

Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
This commit is contained in:
Fini Jastrow 2023-06-02 19:28:55 +02:00
parent 29c0d3f4e5
commit 5eebd95456
2 changed files with 5 additions and 4 deletions

View file

@ -23,7 +23,7 @@ jobs:
run: | run: |
cd bin/scripts cd bin/scripts
chmod u+x * chmod u+x *
./fetch-archives.sh latest ./fetch-archives.sh latest '*zip'
- name: Determine release tag - name: Determine release tag
id: releasetag id: releasetag
run: | run: |

View file

@ -15,6 +15,7 @@
# fetch-archives v2.2.2 # fetch-archives v2.2.2
# fetch-archives v2.2.2 Heavy # fetch-archives v2.2.2 Heavy
# fetch-archives latest HeavyDat # fetch-archives latest HeavyDat
# fetch-archives v3.1.0 'Ara.*zip' (just fetch the zip archive)
set -e set -e
@ -54,8 +55,8 @@ fi
echo "${LINE_PREFIX} Found ${num} artifacts" echo "${LINE_PREFIX} Found ${num} artifacts"
if [ $# -ge 2 ]; then if [ $# -ge 2 ]; then
pattern=$2 pattern=${2// /\\ }
echo "${LINE_PREFIX} Limiting archive to pattern '${pattern}'" echo "${LINE_PREFIX} Limiting archive to regex '${pattern}'"
else else
pattern="" pattern=""
echo "${LINE_PREFIX} No limiting pattern given" echo "${LINE_PREFIX} No limiting pattern given"
@ -67,7 +68,7 @@ fi
for assetname in "${files[@]}"; do for assetname in "${files[@]}"; do
assetname=${assetname:1:-1} assetname=${assetname:1:-1}
if [[ ! "${assetname}" =~ ^"${pattern}" ]]; then if [[ ! "${assetname}" =~ ${pattern} ]]; then
continue continue
fi fi
echo >&2 "${LINE_PREFIX} Fetching ${versiontag}/${assetname}" echo >&2 "${LINE_PREFIX} Fetching ${versiontag}/${assetname}"