From dd7521972967b6b167b44470dea0009c588344ca Mon Sep 17 00:00:00 2001 From: Fini Jastrow Date: Mon, 28 Nov 2022 12:45:26 +0100 Subject: [PATCH] Add script to download release artifacts Signed-off-by: Fini Jastrow --- bin/scripts/README.md | 1 + bin/scripts/fetch-archives.sh | 46 +++++++++++++++++++++++++++++++++++ 2 files changed, 47 insertions(+) create mode 100755 bin/scripts/fetch-archives.sh diff --git a/bin/scripts/README.md b/bin/scripts/README.md index d75b5f7d7..7c15aa547 100644 --- a/bin/scripts/README.md +++ b/bin/scripts/README.md @@ -7,6 +7,7 @@ Note: Usually you need to call the scripts in this directory while actually bein * `data/`: Contains plain text files used to generate the CSS and cheat sheet files * `data/sankey/`: Contains instructions on how to create the sankey glyph table manually [3] * `docker-entrypoint.sh`: This script is packaged into the docker container and is usually used to start patching [2] +* `fetch-archives.sh`: Script to download the release zip archives [4] * `fpfix.py`: Can be used to set isFixedPitch property in a font [x] * `generate-casks.sh`: Generates cask files for fonts from data in `patched-fonts/` and `archives/` [3] * `generate-css.sh`: Generates the Nerd Fonts CCS, which can be used to access the glyphs on a web page [1] diff --git a/bin/scripts/fetch-archives.sh b/bin/scripts/fetch-archives.sh new file mode 100755 index 000000000..ce7241911 --- /dev/null +++ b/bin/scripts/fetch-archives.sh @@ -0,0 +1,46 @@ +#!/usr/bin/env bash +# Nerd Fonts Version: 2.3.0-RC +# Script Version: 1.0.0 +# +# Iterates over all patched fonts directories and fetches the current release zip files. +# +# set -x +# +# Example run with pattern matching: +# ./archive-fonts heavydata +# Example with same font names for different paths +# ./archive-fonts gohu + +version="2.3.0-RC" + +LINE_PREFIX="# [Nerd Fonts] " +scripts_root_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/" +outputdir=$(realpath "${scripts_root_dir}../../archives") + +mkdir -p "$outputdir" + +cd "$scripts_root_dir/../../patched-fonts/" || { + echo >&2 "${LINE_PREFIX} Could not find patched fonts directory" + exit 1 +} + +# limit archiving to given pattern (first script param) or entire root folder if no param given: +if [ $# -eq 1 ] + then + pattern=$1 + search_pattern="*$1*.zip" + echo "$LINE_PREFIX Limiting archive to pattern '$pattern'" +else + pattern=".*" + search_pattern="*.zip" + echo "$LINE_PREFIX No limiting pattern given, will search entire folder" +fi + +find . -maxdepth 1 -iregex "\./$pattern" -type d | +while read -r filename +do + basename=$(basename "$filename") + echo >&2 "${LINE_PREFIX} Fetching v${version}/${basename}.zip" + curl --fail -Lso "${outputdir}/${basename}.zip" "https://github.com/ryanoasis/nerd-fonts/releases/download/v${version}/${basename}.zip" \ + || echo " => error fetching" +done