12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273 |
- #!/usr/bin/env bash
- USAGE="Usage:\n\
- $(basename "$0") <version-number>\n\
- Arguments:\n\
- version-number: Version number to use for the archive.\n\
- There is currently no logic to infer or check this for you, make sure to check the \`releases\` directory to make sure your version is larger than existing versions and does not overwrite them.\n\
- Options:\n\
- -h: displays help message."
- PACKAGE_NAME="freie-fraktur"
- # Reads options
- while getopts "h" flag
- do
- case "$flag" in
- h)
- echo -e "$USAGE"
- exit 0
- ;;
- \?)
- echo "Invalid option: -$OPTARG" >&2
- exit 1
- ;;
- :)
- echo "Option -$OPTARG requires an argument." >&2
- exit 1
- ;;
- esac
- done
- # shifts pointer to read mandatory version number specification
- shift $((OPTIND - 1))
- VERSION="${1}"
- # checks for correct output file specification
- if [ -z "$VERSION" ]
- then
- echo "$(basename "$0"): no archive version specified."
- echo -e "$USAGE"
- exit 1
- fi
- echo "This is ./make_archive.sh working on the \`${PACKAGE_NAME}\` package."
- ARCHIVE_NAME="${PACKAGE_NAME}-${VERSION}"
- ARCHIVE_DIR="/tmp/${ARCHIVE_NAME}"
- SCRIPT_DIR="$(dirname "$0")/"
- RELEASE_DIR="${SCRIPT_DIR}../releases/"
- echo "Creating temporary archive directory under \`${ARCHIVE_DIR}\`."
- mkdir "${ARCHIVE_DIR}"
- cp "${SCRIPT_DIR}../README.md" "${ARCHIVE_DIR}"
- # `-L` is important here, as the data is recorded in datalad and otherwise only the (relative!) symlinks will be copied.
- cp -rL "${SCRIPT_DIR}../doc" "${ARCHIVE_DIR}"
- cp -rL "${SCRIPT_DIR}../fonts" "${ARCHIVE_DIR}"
- pushd "${ARCHIVE_DIR}" &> /dev/null
- echo "# Font Package Release \`${ARCHIVE_NAME}\`
- Note that this is a font package release, and does not include associated scripts or a package-wide license (individual font licences are to be found in the documentation directory).
- This message was autogenerated during archive creation.
- " | cat - README.md | tee README.md &> /dev/null
- popd &> /dev/null
- echo " ✔"
- echo "Creating release archive \`${ARCHIVE_NAME}.tar.xz\`."
- # `-C` is important here, as otherwise the full path would be encoded into the tar archive (i.e. including the `tmp/` prefix)
- tar cJf "${RELEASE_DIR}${ARCHIVE_NAME}.tar.xz" -C $(dirname ${ARCHIVE_DIR}) $(basename ${ARCHIVE_DIR})
- echo " ✔"
- echo "Cleaning up.."
- rm -rf "${ARCHIVE_DIR}"
- echo " 💛"
|