-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild-workflow.zsh
executable file
·96 lines (73 loc) · 1.45 KB
/
build-workflow.zsh
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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
#!/usr/bin/env zsh
set -e
here="${${(%):-%x}:A:h}"
source "${here}/.env"
devmode=true
verbose=
log() {
echo "$@" > /dev/stderr
}
usage() {
cat <<EOS
build-workflow.zsh [options]
Usage:
build-workflow.zsh [-d] [-v]
build-workflow.zsh -h
Options:
-d also build .alfredworkflow file
-v verbose
-h show this help message and exit
EOS
}
while getopts ":dhv" opt; do
case $opt in
d)
devmode=false
;;
h)
usage
exit 0
;;
v)
verbose=-v
;;
\?)
log "invalid option: -$OPTARG"
exit 1
;;
esac
done
shift $((OPTIND-1))
cd "$here"
test -d "build" && {
log "cleaning ./build ..."
command rm $verbose -rf ./build/*
log
} || true
log "copying assets to ./build ..."
mkdir $verbose -p ./build
cd ./build
ln -s $verbose ../*.png .
ln -s $verbose ../info.plist .
ln -s $verbose ../README.md .
ln -s $verbose ../LICENCE.txt .
cd -
log
log "building executable(s) ..."
go build -v -o ./build/forklift .
log
$devmode || {
# Get the dist filename from the executable
zipfile="ForkLift-Favourites-${alfred_workflow_version}.alfredworkflow"
test -f "./dist/$zipfile" && {
log "removing existing .alfredworkflow file ..."
rm $verbose -f "./dist/$zipfile"
log
} || true
log "building $zipfile ..."
mkdir $verbose -p ./dist
cd ./build
zip $verbose "../dist/${zipfile}" *
log
}
log "all done"