aboutsummaryrefslogtreecommitdiffstats
path: root/deploy.sh
blob: 7b7f1e5903cfeab86786a9180357c2ef4a343219 (plain) (blame)
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#!/usr/bin/env bash
set -euo pipefail

INCLUDES=(
  "customize.sh"
  "module.prop"
  "system"
)

# Welche Dateien/Ordner sollen ausgeschlossen werden?
EXCLUDES=(
)

PROP_FILE="module.prop"

trim() { sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//'; }

if [[ ! -f "$PROP_FILE" ]]; then
  echo "Fehler: $PROP_FILE nicht gefunden."
  exit 1
fi

if ! command -v zip >/dev/null 2>&1; then
  echo "Fehler: 'zip' ist nicht installiert."
  exit 1
fi

id=$(
  awk -F= '$1=="id"{print substr($0,index($0,"=")+1)}' "$PROP_FILE" | trim
)
version=$(
  awk -F= '$1=="version"{print substr($0,index($0,"=")+1)}' "$PROP_FILE" | trim
)

if [[ -z "${id}" || -z "${version}" ]]; then
  echo "Fehler: Konnte 'id' und/oder 'version' nicht aus $PROP_FILE lesen."
  exit 1
fi

mkdir -p release
zipfile="release/${id}-${version}.zip"

rm -f "$zipfile"

ZIP_EXCLUDES=()
for ex in "${EXCLUDES[@]}"; do
  ZIP_EXCLUDES+=("-x" "$ex/*" "-x" "$ex")
done

zip -r "$zipfile" "${INCLUDES[@]}" "${ZIP_EXCLUDES[@]}"

echo "Fertig: $zipfile"