-
Notifications
You must be signed in to change notification settings - Fork 28
/
deploy.sh
executable file
·31 lines (27 loc) · 881 Bytes
/
deploy.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#!/bin/bash
set -e
if [ -z "$1" ]; then
if [[ "$OSTYPE" == "msys" ]]; then
FACTORIO_DIR="${APPDATA}/Factorio"
else
FACTORIO_DIR="${HOME}/.factorio"
fi
else
FACTORIO_DIR="$1"
fi
DIR="$(dirname "$(readlink -f "$0")")"
NAME=$(basename "${DIR}")
MODS="${FACTORIO_DIR}/mods"
REGEX=".*/LICENSE$\|.*changelog.txt\|.*\.lua$\|.*\.cfg$\|.*\.png$\|.*\.ogg$\|.*\.zip\|.*\.json$\|.*\.md$"
MODNAME=$(jq -r .name "${DIR}/info.json")
VERSION=$(jq -r .version "${DIR}/info.json")
ZIPNAME="${MODNAME}_${VERSION}.zip"
ZIP_CMD="zip"
if [[ "$OSTYPE" == "msys" ]]; then
ZIP_CMD="7z a -tzip"
fi
function prepend() { while read line; do echo "${1}${line}"; done; }
FILELIST=$(git ls-files | grep "${REGEX}" | prepend "${NAME}/")
(cd "${DIR}/.." && rm -rf "${ZIPNAME}" &&
echo ${FILELIST} | xargs ${ZIP_CMD} "${ZIPNAME}" &&
unzip -l "${ZIPNAME}" && mv "${ZIPNAME}" "${MODS}")