forked from mikybars/build-alfred-workflow
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathentrypoint.sh
executable file
·67 lines (52 loc) · 1.01 KB
/
entrypoint.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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#!/usr/bin/env bash
set -euo pipefail
set -o noglob
WORKFLOW_DIR="$1"
EXCLUDE_PATTERNS="$2"
abort() {
echo $1 >&2
exit 1
}
check_info_plist() {
[[ -r "info.plist" ]] || abort "Missing file info.plist"
}
check_workflow_dir() {
[[ -d $WORKFLOW_DIR ]] || abort "Missing directory $WORKFLOW_DIR"
}
workflow_files() {
for file in info.plist icon.png LICENSE README README.md; do
[[ -f $file ]] && echo $file
done
}
exclude_args() {
echo "$EXCLUDE_PATTERNS" | xargs -n 1 -I{} echo "--exclude {}"
}
clean() {
rm -f $OUTPUT_FILE
}
zip_dir() {
local dir=$1
pushd $dir >/dev/null
zip \
$OUTPUT_FILE \
$(find .) \
$(exclude_args)
popd >/dev/null
}
zip_files() {
zip \
$OUTPUT_FILE \
$@ \
$(exclude_args)
}
set_output() {
local var_name=$1 value=$2
echo "::set-output name=${var_name}::${value}"
}
check_info_plist
check_workflow_dir
OUTPUT_FILE="${PWD}/$(/extract_name.py info.plist)"
clean
zip_dir $WORKFLOW_DIR
zip_files $(workflow_files)
set_output workflow_file "$(basename $OUTPUT_FILE)"